Thread: Cash System
View Single Post
  #20  
Old 11-30-2009, 12:23 AM
Fireballchad Fireballchad is offline
Member
 
Join Date: Aug 2009
Posts: 49
Credits: 8,207
Fireballchad
Default RE: Cash System

PHP Code:
<?
//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_adoptablesADD  `priceINT10 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.
Reply With Quote