View Single Post
  #1  
Old 12-01-2009, 03:45 PM
Fireballchad Fireballchad is offline
Member
 
Join Date: Aug 2009
Posts: 49
Credits: 8,436
Fireballchad
Default Adoptables Shop - Working Again!

Ok I am 100% done with this version. I will make a new version with more features. But this one works and is running.
First you will need to install Sea's cash system.
http://www.rusnakweb.com/forum/showthread.php?tid=1333
Next follow my steps (I will try to do this so it makes since)
Around line 169 in your admin.php add this:
PHP Code:
   <input name='cba' type='radio' value='pricenum'>
Only when users pay this much BP
<
input name='price' type='text' id='price'>
 <
p>
    <
input name='shop' type='checkbox' id='shop' value='enabled'
   
Sell This In Your Shop!</p>
<
br
In your nadopt.php file add this around line 112:
PHP Code:
$price $_POST["price"];
$price secure($price);

$shop $_POST["shop"];
$shop secure($shop); 
Still in the same file change this:
PHP Code:
if($cba != "always" and $cba != "promo"  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.";

To This:
PHP Code:
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.";

Around Line 172 add this:
PHP Code:
//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.";
}
if(
$shop == "enabled"$shop2 "1"
Add $shop2 also add $price into the data base insert around line 251:
PHP Code:
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxnumcond','$morethannum','$usergroupcond','$usergroups','$alternates','$altoutlevel','$altchance','$shop2','$price')"); 
Insert this in doadopt.php around line 104:
PHP Code:
$price=@mysql_result($result,$i,"price"); 
In doadopt.php use this... Again it is done for my site so it may be wierd... and my coding isn't great lol... as in not neet
PHP 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++;
}

if (
$money $price$get ='';
else 
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','notfortrade','no')");
//This Line Above This Comment Was Moved From Around Line 138 Delete That One!
//Prevents From getting an adopt if no money.

if ($price == 0$get '';
else 
$get '<br> Thanks for buying your Bud! Now you have '.$newbalance.' coins!';
    
    if (
$money $price$get ='<br><br>There was an Error!<br>You Do Not Have Enough Coins';
else    
mysql_query("UPDATE `adopts_users` SET `money`='" $newbalance "' WHERE `username`='$loggedinname'");
// money buying addon
//prevents from going negative money.
$article_title "You got ".$name." successfully";
$article_content "<img src='".$eggimage."'><br>".$congrats1." ".$name.".  You can now manage ".$name." on the 
<a href='myadopts.php'>My Buds</a> page.<br><br><b><a href='myadopts.php?act=manage&id="
.$id."'>Click Here to Manage ".$name."</a><br>
<a href='myadopts.php?act=bbcode&id="
.$id."'>Click Here to get BBCodes / HTML Codes for ".$name."</a> ".$get." </b><br><br>"
Last But not least insert this into your data base under adopts_adoptables
Code:
`shop` tinyint(1) NOT NULL default 'NULL', and `price` int(10) NOT NULL default 'NULL'
Ok I hope it works for you
shop.php is attached it is adopt.php but shows items that cost money instead of being free and adopt.php now should show items that do not cost money.


Credit goes to Sea and Arianna for the code to get this working
Sorry for not fixing broken links and such!
Attached Files
File Type: php shop.php (8.0 KB, 3 views)
File Type: php adopt.php (8.1 KB, 3 views)
Reply With Quote