Jump to content
MakeWebGames

Help with small problem I am having!.


Razor42
 Share

Recommended Posts

Basically I have added this to glob_funcs:

function drinking_check()
{
$thug = mysql_query("SELECT `drinking_lvl`,`drinking_exp`,`drinking_expneed` FROM `users` WHERE (`userid`=".$_SESSION['userid'].")");
$s = mysql_fetch_array($thug);

$s['drinking_expneeded']=(int) (($s['drinking_lvl']+1)*($s['drinking_lvl']+1)*($s['drinking_lvl']+1)*2.2);
if($s['drinking_exp'] >= $s['drinking_expneed'])
{
$expu=$s['drinking_exp']-$s['drinking_expneed'];
$s['drinking_lvl']+=1;
$s['drinking_exp']=$expu;
$s['drunk_max']=+15;
mysql_query("UPDATE `users` SET `drinking_lvl`=`drinking_lvl`+1,`drinking_exp`=$expu WHERE (`userid`=".$_SESSION['userid'].")");
}
}

 

This code is to check that if they have reached the exp needed then they advance to the next level but currently when they reach the needed exp they do not advance a level instead they just stay at the same level and there exp just keeps going up.

Link to comment
Share on other sites

function drinking_check()
{
$thug = $db->query("SELECT `drinking_lvl`,`drinking_exp`,`drinking_expneed` FROM `users` WHERE (`userid`=".$_SESSION['userid'].")");
$r =$db_fetch_row($thug);

$s['drinking_expneeded']=(int) (($s['drinking_lvl']+1)*($s['drinking_lvl']+1)*($r['drinking_lvl']+1)*2.2);
if($r['drinking_exp'] >= $r['drinking_expneed'])
{
$expu=$s['drinking_exp']-$s['drinking_expneed'];
$r['drinking_lvl']+=1;
$r['drinking_exp']=$expp;
$r['drunk_max']=+15;
$db->query("UPDATE `users` SET `drinking_lvl`=`drinking_lvl`+1,`drinking_exp`=$expp WHERE (`userid`=".$_SESSION['userid'].")");
}
}

 

Try this?

Edited by Infamous
Mistake made.
Link to comment
Share on other sites

Think urban mafi is on to something there.

In general when debugging. It can be useful to do something like this

 

function drinking_check()
{
$thug = mysql_query("SELECT `drinking_lvl`,`drinking_exp`,`drinking_expneed` FROM `users` WHERE (`userid`=".$_SESSION['userid'].")");
echo "SELECT `drinking_lvl`,`drinking_exp`,`drinking_expneed` FROM `users` WHERE (`userid`=".$_SESSION['userid'].")";
$s = mysql_fetch_array($thug);

print_r($s);

$s['drinking_expneeded']=(int) (($s['drinking_lvl']+1)*($s['drinking_lvl']+1)*($s['drinking_lvl']+1)*2.2);
if($s['drinking_exp'] >= $s['drinking_expneed'])
{
echo '$s[\'drinking_exp\'] >= $s[\'drinking_expneed\'] is true';
$expu=$s['drinking_exp']-$s['drinking_expneed'];
$s['drinking_lvl']+=1;
$s['drinking_exp']=$expu;
$s['drunk_max']=+15;
mysql_query("UPDATE `users` SET `drinking_lvl`=`drinking_lvl`+1,`drinking_exp`=$ex  pu WHERE (`userid`=".$_SESSION['userid'].")");

echo "UPDATE `users` SET `drinking_lvl`=`drinking_lvl`+1,`drinking_exp`=$ex  pu WHERE (`userid`=".$_SESSION['userid'].")";
// or do 
// mysql_query("UPDATE `users` SET `drinking_lvl`=`drinking_lvl`+1,`drinking_exp`=$ex  pu WHERE (`userid`=".$_SESSION['userid'].")") or die(mysql_error());
}
}
Edited by Someone
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.

 Share

×
×
  • Create New...