Jump to content
MakeWebGames

mineshaft.php


newttster

Recommended Posts

I have been able to get this to work in so far as it adds the silver flakes and reduces the digs by one. I have tried umpteen different ways to try and get the mine_exp to update and it won't. I realize that I need a qualifier in there stating that if the $randsf > 0 it should add the exp ... so far I haven't been able to get that to work. The fields I have for this are mine_exp, mine_level, and mine_max. Mine_max is supposed stays at 100 and each time there is a successful mine the exp_mine is supposed to increment by one. If the mine_exp exceeds the mine_max then it should add 1 level to mine_level. Any ideas or suggestions?

 

function mine_one()
{
global $db,$ir,$c,$userid,$h;
$randsf=rand(0,10);
$gain=(1);
if($ir['digs']<=0)
{
echo"<center>You don't have any digs left. Come back at reset.</center>";
$h->endpage();
exit;
}
if($ir['mine_exp']>$ir['mine_max'])
{
$db->query("UPDATE `users` SET `mine_level`=`mine_level` + 1 WHERE `userid`=  '$userid'");
}
else
{
$db->query("UPDATE `users` SET `mine_exp`=`mine_exp` + ". $gain .",`digs`=`digs`-1 WHERE `userid` = '$userid'");
item_add($userid, 566, $randsf);
echo "<center>You begin mining in the Level 1 mineshaft and found '$randsf' silver flake(s).</center><br />";
echo"<center><a href='mineshaft.php?action=mineone'>Mine Again</a></center><br />
<a href='mineshaft.php'>Back</a></center>";
}
}
$h->endpage();
?>
Edited by newttster
Link to comment
Share on other sites

for starters

$db->query("UPDATE `users` SET `mine_level`=`mine_level` + 1 WHERE `userid`= = '$userid'");

should be

$db->query("UPDATE `users` SET `mine_level`=`mine_level` + 1 WHERE `userid`= '$userid'");

That was a mistype on my part when adding the code here. Fixed. The other issues I still have not been able to fix though.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...