Thread: Cash System
View Single Post
  #14  
Old 11-19-2009, 07:34 AM
Arianna's Avatar
Arianna Arianna is offline
Dev Staff
 
Join Date: Sep 2009
Posts: 334
Gender: Female
Credits: 21,056
Arianna will become famous soon enough
Default RE: Cash System

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 Code:
<?

// 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_adoptablesADD  `priceINT10 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(120000);
// 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
?>
Reply With Quote