hi i have virtual pet site scripts and on the adopt script there are limits and it rounds the cost of the pet you want to adopt automatically also something about checking to see if the pet was disowned or not, i would like for the user to be able to purchase the pet whenever the have the virtual credits. can some one please tell me and or shoe me how to edit this script to do that?? thanx in advance!!
CODE
<?php
$rank_check = 1;
$page_title = "Adoption Center";
if ($act == "disown2")
{
include "global.inc.php";
$findPet = fetch("SELECT FROM user_pets2 WHERE owner = '$userid' AND adoption = '0' AND id = '$disown' AND game = '$game'");
if (!$findPet[id])
{
die(header(error("adopt.php?game=$game&act=disown","That is not your MiniMini!")));
}
$cost2adopt = rand(round(($findPet[level] 100) .7), round(($findPet[level] 100) * 1.3));
mysql_query("UPDATE user_pets2 SET adoption=1 WHERE owner = '$userid' AND adoption = '0' AND id = '$disown' AND game = '$game'");
mysql_query("UPDATE user_pets2 SET cost2adopt=$cost2adopt WHERE owner = '$userid' AND adoption = '1' AND id = '$disown' AND game = '$game'");
die(header(error("adopt.php?game=$game&act=disown","$findPet[name] has been UnAssisted! ")));
}
if ($act == "adopt3")
{
include "header.inc.php";
// Start Check
$checking = "adoption";
$limit1 = 3600;
$limit = $timestamp - $limit1;
$findCheck = fetch("SELECT * FROM checking2 WHERE userid = '$userid' AND check_what = '$checking' AND timestamp > '$limit' AND game = '$game'");
if ($findCheck[id])
{
die("$openHTML<p>You can only Assist a MiniMini every $limit1 seconds. <a href=$base_url/adopt.php?game=$game>Back</a></p>$closeHTML");
}
if (!$findCheck[id])
{
mysql_query("DELETE FROM checking2 WHERE userid = '$userid' AND check_what = '$checking' AND game = '$game'");
mysql_query("INSERT INTO checking2 (userid,check_what,timestamp,game) VALUES ('$userid','$checking','$timestamp','$game')");
}
// End Check
$findPet = fetch("SELECT * FROM user_pets2 WHERE adoption = '1' AND id = '$id' AND game = '$game'");
if (!$findPet[id])
{
die(header(error("adopt.php?game=$game&act=adopt2&id=$id","That MiniMini currently does not want Assistance!")));
}
if ($points < $findPet[cost2adopt])
{
die(header(error("adopt.php?game=$game&act=adopt2&id=$id","You do not have enough $pointsVar to Assist this MiniMini.")));
}
points($game,"$username", "-$findPet[cost2adopt]");
mysql_query("UPDATE user_pets2 SET adoption=0 WHERE id = '$id' AND game = '$game'");
mysql_query("UPDATE user_pets2 SET owner=$userid WHERE id = '$id' AND game = '$game'");
die(header(error("mypets.php?game=$game","You are now the Assistant of $findPet[name]!!!!")));
}
include "header.inc.php";
echo $openHTML;
print "<p align=center>The MiniMini Assistant Center. <br>
</a></a> <a href=mypets.php?game=$game>Your Current MiniMini</a></p>";
if (!$act)
{
echo "<p>Welcome to the MiniMini Assistant Center, here you can find MiniMini that are currently looking for Assistants, or you can UnAssist a MiniMini so they can find a new Assistant. So please choose what you want to do below.</p>";
ECHO <<<END
<P align=center>
<TABLE BGCOLOR="$tableBorder" CELLSPACING=1 CELLPADDING=0 WIDTH=300>
<TR BGCOLOR="$topAndBottomBG">
<TD HEIGHT=50>
<CENTER><FONT SIZE="+3" COLOR="$topAndBottomText"><B><a href=adopt.php?game=$game&act=adopt class=white>Assist a MiniMini</a></B></FONT></CENTER>
</TD>
</TR>
</TABLE>
</P>
<P align=center>
<TABLE BGCOLOR="$tableBorder" CELLSPACING=1 CELLPADDING=0 WIDTH=300>
<TR BGCOLOR="$topAndBottomBG">
<TD HEIGHT=50>
<CENTER><FONT SIZE="+3" COLOR="$topAndBottomText"><B><a href=adopt.php?game=$game&act=disown class=white>UnAssist a MiniMini</a></B></FONT></CENTER>
</TD>
</TR>
</TABLE>
</P>
END;
}
if ($act == "adopt")
{
$findResults = mysql_query("SELECT * FROM user_pets2 WHERE adoption = '1' AND game = '$game' ORDER BY rand() DESC LIMIT 3");
$numResults = mysql_num_rows($findResults);
if ($numResults == 3)
{
$itemList = "<i>There are no MiniMini who need an Assistant right now!</i>";
}
if ($numResults != 0)
{
while ($getResults = mysql_fetch_array($findResults))
{
$findSpecies = fetch("SELECT * FROM pets2 WHERE id = '$getResults[species]' AND game = '$game'");
$itemList = "
<TD WIDTH=250>
<CENTER><a href=adopt.php?game=$game&act=adopt2&id=$getResults[id]>
<img src=images/user_images/opg$game/pets/pet$findSpecies[id].gif><br>
$getResults[name]</a><br>
The $findSpecies[name]<br>
Level: $getResults[level]<br>
Cost: $getResults[cost2adopt]</CENTER>
</TD>
";
$x = 1;
}
$itemList = "<table><tr bgcolor=#ffffff>$itemList</tr></table>";
}
ECHO <<<END
<CENTER><FONT SIZE="+2"><B>--Assist a MiniMini--</B></FONT></CENTER>
<CENTER>$itemList</CENTER>
END;
}
if ($act == "adopt2")
{
$array = fetch("SELECT * FROM user_pets2 WHERE id = '$id' AND adoption = '1' AND game = '$game'");
print "<center><table><tr>
<td width=200>
";
$id = $array[id];
$getPet = fetch("SELECT * FROM pets2 WHERE id = '$array[species]' AND game = '$game'");
if ($array[hunger] == 0) { $hungerLevel = "Dead"; }
if ($array[hunger] == 1) { $hungerLevel = "Extremely Starving"; }
if ($array[hunger] == 2) { $hungerLevel = "Very Starving"; }
if ($array[hunger] == 3) { $hungerLevel = "Starving"; }
if ($array[hunger] == 4) { $hungerLevel = "Realllly Hungry"; }
if ($array[hunger] == 5) { $hungerLevel = "Pretty Hungry"; }
if ($array[hunger] == 6) { $hungerLevel = "Hungry"; }
if ($array[hunger] == 7) { $hungerLevel = "Not Hungry"; }
if ($array[hunger] == 8) { $hungerLevel = "Stuffed"; }
if ($array[hunger] == 9) { $hungerLevel = "Bloated"; }
if ($array[hunger] == 10) { $hungerLevel = "Fat"; }
if (($array[hunger] > 10) OR ($array[hunger] < 0)) { $hungerLevel = "Unknown ($array[hunger])"; }
$percentHealth = ($array[current_hp] / $array[max_hp]) * 100;
if ($percentHealth > 0)
{
$healthLine = "<font color=red>$array[current_hp]/$array[max_hp]</font>";
}
if ($percentHealth > 35)
{
$healthLine = "<font color=orange>$array[current_hp]/$array[max_hp]</font>";
}
if ($percentHealth > 75)
{
$healthLine = "<font color=green>$array[current_hp]/$array[max_hp]</font>";
}
echo "
<p align=center>
<img src=$base_url/images/user_images/opg$game/pets/pet$getPet[id].gif></p>
</p>
</td>
<td width=175>
<p>
<b>$array[name]</b> the $getPet[name]!<br>
Level: $array[level]<br>
Health: <b>$healthLine</b><br>
Strength: $array[strength]<br>
Intelligence: $array[intelligence]<br>
Speed: $array[speed]<br>
Defense: $array[defense]<br>
Hunger: $hungerLevel
</p>
</td></tr></table>
<table>
<tr>
<td width=300>
<p align=center>
<TABLE BGCOLOR=\"$tableOutline\" CELLSPACING=1 CELLPADDING=0 WIDTH=275>
<TR BGCOLOR=\"$topAndBottomBG\">
<TD HEIGHT=30>
<CENTER><FONT SIZE=\"+2\" COLOR=\"$topAndBottomText\"><B><a href=adopt.php?game=$game&act=adopt3&id=$id><font color=$topAndBottomText>Assist for $array[cost2adopt] $pointsVar!</font></a></B></FONT></CENTER>
</TD>
</TR>
</TABLE>
</td>
<td>
<TABLE BGCOLOR=\"$tableOutline\" CELLSPACING=1 CELLPADDING=0 WIDTH=125>
<TR BGCOLOR=\"$topAndBottomBG\">
<TD HEIGHT=30>
<CENTER><FONT SIZE=\"+2\" COLOR=\"$topAndBottomText\"><B><a href=adopt.php?game=$game&act=adopt><font color=$topAndBottomText>Back</font></a></B></FONT></CENTER>
</TD>
</TR>
</TABLE>
</td></tr></table></p>";
print "</center>";
}
if ($act == "disown")
{
$findPets = mysql_query("SELECT * FROM user_pets2 WHERE owner = '$userid' AND adoption = '0' AND game = '$game' ORDER BY id");
echo "<p>Please choose the MiniMini you would like to UnAssist:</p><form action=adopt.php?game=$game&act=disown2 method=post><select name=disown><option value=\"\">Choose A MiniMini";
while ($array = mysql_fetch_array($findPets))
{
$getPet = fetch("SELECT * FROM pets2 WHERE id = '$array[species]' AND game = '$game'");
print "<option value=$array[id]>$array[name] the $getPet[name] (Level $array[level])";
}
print "</select><br><input type=submit value=\"UnAssist the MiniMini\" onClick=\"if ( !confirm ('Are you sure you want to UnAssist this MiniMini?') ) { return false; }\">";
}
echo $closeHTML;
?>
CODE