Cash System

Forum
Last Post
Threads / Messages

Seapyramid

Premium Member
Premium Member
Joined
Feb 1, 2009
Messages
373
Points
0
Mysidian Dollar
10,535
OK.. I suck at tutorials but I will give this a try

Find
PHP:
                     if ($newclicks >= $requiredclicks and $requiredclicks != 0 and $requiredclicks != "") {
                          // We need to level this adoptable up...
                          
                          $query = "UPDATE " . $prefix . "owned_adoptables SET currentlevel='" . $nextlevel . "' WHERE aid='" . $id . "'";
                          mysql_query($query);
                          
                          // Now we check if we are enabling alternate images...
                          
                          // Get the ID of the parent type adoptable
                          $parentid = converttypetoparentid($type);
                          // Check if we are using alternate images or not...
                          $altstatus = getaltstatus($parentid, $id, $nextlevel);
                          
                          if ($altstatus == "yes") {
                              // We are enabling alternate images for this adoptable...
                              
                              $query = "UPDATE " . $prefix . "owned_adoptables SET usealternates='yes' WHERE aid='" . $id . "'";
                              mysql_query($query);
                          }
                          
                          // Now we can see if the adoptable's owner gets a reward...
                          // The reward function will take care of sending out any reward that exists...
                          
                          $rewardstatus = reward($id, $type, $nextlevel, $owner);
                      }
                      // End the if statement if we are leveling the adoptable up
                      $image = getcurrentimage($id);
                      
                      
                      $article_title = "You just gave " . $name . " one Maturity Training.<br />";
                      $article_content = $article_content . "<br /><br />";
                  }

on your levelup.php page. Directly below it add
PHP:
                  // ************************************************
                  
                  // Start Rewards
                  
                  // ************************************************  
                  
                  
                  //Get currency on level up
                  
                  $query = "SELECT * FROM `adopts_users` WHERE `username`='$loggedinname'";
                  $result = mysql_query($query);
                  $num = mysql_numrows($result);
                  
                  $i = 0;
                  while ($i < 1) {
                      $money = @mysql_result($result, $i, "money");
                      
                      // Change this number 10 to the number of currency you want users to earn on level up  
                      $newbalance = $money + 2;
                      
                      $i++;
                  }
                  
                  mysql_query("UPDATE `adopts_users` SET `money`='" . $newbalance . "' WHERE `username`='$loggedinname'");
                  
                  
                  $article_content = $article_content . "<div align='center'><br />You have earned 2 Gold Pieces for leveling up this Companion. <br />You now have  " . $newbalance . " Gold Pieces.</div>";

on this line in the above script
PHP:
$newbalance = $money + 2;
is where you change the amount to whatever you want it to be.

You will have to modify your adopts_users table and add a new field called money `money` int(11) NOT NULL default '0',

Lastly you will have to modify your register.php page
PHP:
	mysql_query("INSERT INTO ".$prefix."users VALUES ('', '$username', '$pass1','$email','3','1', '$date', '0','','','','','','0')");

If I didn't forget anything it should work.

Sea
 
Very nice seapyramid =D

This will even work with the next release of the forum, as it gives points for posts and what not which could be "converted" into "money".
 
I just came across an idea to show how much money a user has on their profile & in their sidefeed menu. What variable would I need to use for that?
 
Thanks, this works really well. :)

Now to figure out what to use the currency for lol.
 
rolf.. I do have a few games that are generic the can can be used on by those with a bit of knowledge... items systems are quite personalized to the site so I cant help you there. :)

Sea
 
lol well I managed to show the currency on profiles so at the moment it can just be used to show who clicks the most pets. :D
 
Wow, this is awesome. :D
I just installed it (very easy to, thanks!) and it's working amazingly. I might add something so pets can be 'bought', is that okay? I'll share it on here, when I'm finished. :)
 
Sure its ok :) Actaully I have a separte shop for that which also uses paypal ipn.. you might want to look at it http://mysticgrove.net/grove/shop_queen.php For just using the ingame coin to buy stuff I have http://mysticgrove.net/grove/shop_gnome.php for trinkets (kinda like mini pets I gues) & http://mysticgrove.net/grove/shop_merlin.php for useable items. I also currently have 3 gambling games in game coin can be used for with more planned :)

Much can be done with the coin system once it is in place :)

Sea
 
Ooh, awesome. :) I love how you have the trinket shop and stuff. :) I think that I'll work on the code when I have time, then. x3
 
I just made the thing to buy adoptables. It works well, except for I can't get it to set the price in the admin CP - it always defaults to then 10 that I've set. Here's what I did.
PHP:
<?

// FILE: admin.php
// okay, I'm a failure here. It only works if I insert it in phpmyadmin. help?
// After line 158 add:
	<p>Price: 
    <input name='price' type='text' id='price'>
    </p>

// reminder to me: there's a good code for a style switcher on line 119-213

// FILE: nadopt.php
// After line 136 add:
	$price = $_POST["price"];
	$price = secure($price);
	
// Change line 243 (about) to:
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxnumcond','$morethannum','$usergroupcond','$usergroups','$alternates','$altoutlevel','$altchance','$price')");

// in the table adopts_adoptables, use the sql query. Change the '10' to your default adoptable price.
ALTER TABLE  `adopts_adoptables` ADD  `price` INT( 10 ) NOT NULL DEFAULT  '10';

// we still have to alter two more things - the adopt.php page, and the doadopt.php page.
// FILE: adopt.php
// After line 96 add:
$price=@mysql_result($result,$i,"price");
// After line 152 add:
$price=@mysql_result($result,$i,"price");
// After line 174 add:
<p>I cost ".$price." coins!</p>
// And after line 179 add:
<input name='price' type='hidden' id='price' value='".$price."'>

// FILE: doadopt.php
// After line 102 add:
$price=@mysql_result($result,$i,"price");
// Insert this giant junk of code after:
$code = rand(1, 20000);
// Here's the code:
$query = "SELECT * FROM `adopts_users` WHERE `username`='$loggedinname'";
$result = mysql_query($query);
$num = mysql_numrows($result);

$i = 0;
while ($i < 1) {
$money = @mysql_result($result, $i, "money");
$newbalance = $money - $price;
$i++;
}

mysql_query("UPDATE `adopts_users` SET `money`='" . $newbalance . "' WHERE `username`='$loggedinname'");

$article_content = $article_content . "<div align='center'>Thanks for buying your adoptable! Now you have ".$newbalance." coins!</div>"; 

// I can't guarentee that this is right, but if you have any problems, please tell me. :D
?>
 
Sea, I hate to be annoying (xD) but have you any idea on the price of the adoptables not working? I thought I was following the same layout as other stuff, but somehow, I guess it isn't working. :p
 
Sorry,

I have been very busy, we just put the script rewrite/opt code on line this morning & preparing all the changes & setting it live was a big task. :) I will try to look at the code this week. Right now, I am tweaking bugs with the new lease & starting on the new full featured trading system coming next.

Sea
 
Ooh, that sounds awesome! And scary, too.
The trading system sounds awesome, too.
 
Hey Arianna I sort of got your cash thing working...
I will try to make a tut of what I did.
Yours worked sorta of but you missed a few things it needed...
I am currently trying to make it so if you dont have enough money then you cant buy it... As of right now it allows you to go negative...
PHP:
<?
//File admin.php
//After line 165 add:
<input name='cba' type='radio' value='pricenum'>
Only when users pay this much money: 
<input name='price' type='text' id='price'>
<br>

// FILE: nadopt.php
// After line 94 add: it will be this but with promo instead
    $price = $_POST["price"];
    $price = secure($price);
    
// Change line 243 (about) to: '$price' was added at the end
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxnumcond','$morethannum','$usergroupcond','$usergroups','$alternates','$altoutlevel','$altchance','$price')");

// in the table adopts_adoptables, use the sql query. 
ALTER TABLE  `adopts_adoptables` ADD  `price` INT( 10 ) NOT NULL DEFAULT  'NULL';
// I Hand entered this into my data base Default should be NULL I don't know if
// 'NULL' will work or not but fix it if it doesn't

// we still have to alter two more things - the adopt.php page, and the doadopt.php page.
// FILE: adopt.php
// After line 63 (about) add:
$price = $_GET["price"];
$price = secure($price);
// After line 96 add:
$price=@mysql_result($result,$i,"price");
// After line 152 add:
$price=@mysql_result($result,$i,"price");
// After line 174 add:
<p>I cost ".$price." coins!</p>
// And after line 179 add:
<input name='price' type='hidden' id='price' value='".$price."'>

// FILE: doadopt.php
//After Line 75 (about) add:
$price = $_GET["price"];
$price = secure($price);
// After line 102 add:
$price=@mysql_result($result,$i,"price");
// Insert this giant junk of code after:
$id=@mysql_result($result,$i,"aid"); 


$i++;
}

// Here's the code:
$query = "SELECT * FROM `adopts_users` WHERE `username`='$loggedinname'";
$result = mysql_query($query);
$num = mysql_numrows($result);

$i = 0;
while ($i < 1) {
$money = @mysql_result($result, $i, "money");
$newbalance = $money - $price;
$i++;
}

mysql_query("UPDATE `adopts_users` SET `money`='" . $newbalance . "' WHERE `username`='$loggedinname'");

$article_content = $article_content . "<div align='center'>Thanks for buying your adoptable! Now you have ".$newbalance." coins!</div>"; 

// Credit goes to 	Arianna I only helped fix some stuff... Still needs to be fixed!!!
?>
 
Maybe just check if ($newcash>=0) and then determine it via elseif. :)
 
PHP:
<?
//File admin.php
//After line 165 add:
<input name='cba' type='radio' value='pricenum'>
Only when users pay this much money: 
<input name='price' type='text' id='price'>
<br>

// FILE: nadopt.php
// After line 94 add: it will be this but with promo instead
    $price = $_POST["price"];
    $price = secure($price);
    
// Change line 243 (about) to: '$price' was added at the end
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxnumcond','$morethannum','$usergroupcond','$usergroups','$alternates','$altoutlevel','$altchance','$price')");


// Replace the orignal one of this with this new one.
if($cba != "always" and $cba != "promo"  and $cba != "pricenum" and $cba != "conditions"){
$error = "You did not choose a valid scenario when this adoptable can be adopted.  Please go back and either select the Always option, the Promo option or the Conditions option.";
}
// add this after the other ones that look like it around line 169
//If we are using money to buy this, we should have a amount in the box...
if($cba == "pricenum" and $price == ""){
$error = "You selected that this adoptable is available for adoption only with money, but you did not enter in a money amount.  Please go back and either change this setting or type in a valid amount.";
}
// in the table adopts_adoptables, use the sql query. 
ALTER TABLE  `adopts_adoptables` ADD  `price` INT( 10 ) NOT NULL DEFAULT  'NULL';
// I Hand entered this into my data base Default should be NULL I don't know if
// 'NULL' will work or not but fix it if it doesn't

// we still have to alter two more things - the adopt.php page, and the doadopt.php page.
// FILE: adopt.php
// After line 63 (about) add:
$price = $_GET["price"];
$price = secure($price);
// After line 96 add:
$price=@mysql_result($result,$i,"price");
// After line 152 add:
$price=@mysql_result($result,$i,"price");
// After the $i++; } put this
 $query = "SELECT * FROM `adopts_users` WHERE `username`='$loggedinname'";
                  $result = mysql_query($query);
                  $num = mysql_numrows($result);
                  
                  $i = 0;
                  while ($i < 1) {
                      $money = @mysql_result($result, $i, "money");
                                          
                      $i++;
				  }
				  if ($money >= $price) $get = "<input type='submit' name='Submit' value='Get Me'>";
	else $get = "Sorry Cant Get, Not Enough Coin!";
// After line 174 add:
<p>I cost ".$price." coins!</p>
<div align='center'><br />You have  " . $money . " coins </div>
// And after line 179 add:
<input name='price' type='hidden' id='price' value='".$price."'>
// Delete 
<input type='submit' name='Submit' value='Get Me'>
//Add inplace of that
".$get."
// FILE: doadopt.php
//After Line 75 (about) add:
$price = $_GET["price"];
$price = secure($price);
// After line 102 add:
$price=@mysql_result($result,$i,"price");
// Insert this giant junk of code after:
$id=@mysql_result($result,$i,"aid"); 


$i++;
}

// Here's the code:
$query = "SELECT * FROM `adopts_users` WHERE `username`='$loggedinname'";
$result = mysql_query($query);
$num = mysql_numrows($result);

$i = 0;
while ($i < 1) {
$money = @mysql_result($result, $i, "money");
$newbalance = $money - $price;
$i++;
}

mysql_query("UPDATE `adopts_users` SET `money`='" . $newbalance . "' WHERE `username`='$loggedinname'");

$article_content = $article_content . "<div align='center'>Thanks for buying your adoptable! Now you have ".$newbalance." coins!</div>"; 

// Credit goes to 	Arianna I only helped fix some stuff... WORKS NOW!!! I = Fireballchad
?>

Wow this is a messy tut.... sorry but I got it to take the submit button away when you don't have enough money.
Also in the admin you can change how much it cost to get the adoptable.
If you manage to install this it is wonderfull... or if someone does install it and makes a better tut that would be better!
you can see it work at Forumbuds
Also some of my code may be weird or not wonderful... because I am a very novice PHP coder lol.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top