Jump to content
MakeWebGames

Recommended Posts

Posted

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.

Posted

As I never used mccodes,

I believe its something to do with this part.

 

mysql_query("UPDATE `users` SET `drinking_lvl`=`drinking_lvl`+1,`drinking_exp`=$ex  pu WHERE (`userid`=".$_SESSION['userid'].")");
}
}
Posted (edited)
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.
Posted (edited)

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
Posted (edited)
 `drinking_lvl`=`drinking_lvl`+1,`drinking_exp`=$ex  pu 

try removing the space between the '$ex' and 'pu'

Edited by Dayo
Posted

The space isn't there on the file on the server for some reason it was just added when I uploaded the code here. Like Urban said I think it needs adding to globals not glob_funcs. Ill give it a try when I get on my laptop

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...