Jump to content
MakeWebGames

Recommended Posts

Posted

I can't get my level system to update my level... I dunno why?? No errors at all... Yes, I have a table called "levels" with manually entered exp and level.

 

function check_level() {
global $db, $ir, $userid;
 $row = $db->fetch_row($db->query('SELECT `level`, `exp` FROM `users` WHERE `userid` = '. $ir['userid']));
 $lev = $db->fetch_row($db->query('SELECT `level`, `exp` FROM `levels` WHERE `level` = '. $row['level']));
if($row['exp'] == $lev['exp'])
{
  $db->query("UPDATE `users` SET `level` = `level` + 1 WHERE `userid` = $userid");
}
}
Posted

Re: Level System

 

function check_level()	{
global $ir;
$row = mysql_query('SELECT `level`,`exp` FROM `users` WHERE `userid` = '.$ir['userid']);
$row = mysql_fetch_assoc($row);
$lev = mysql_query('SELECT `level`,`exp` FROM `levels` WHERE `level` = '.$row['level']);
$lev = mysql_fetch_assoc($lev);
if($row['exp'] >= $lev['exp'])	{
	mysql_query('UPDATE `users` SET `level` = `level` + 1 WHERE `userid` = '.$ir['userid']);
}
}

 

Maybe..

Posted

Re: Level System

Okay so when I did more testing on this I noticed that when I level my exp bar jump down to half way... 50% then works its way back up.. I fixed that... but now.. It won't level again?? Help? sorry... :-(

 

function check_level()
{
global $ir;
$row = mysql_query('SELECT `level`,`exp` FROM `users` WHERE `userid` = '.$ir['userid']);
$row = mysql_fetch_assoc($row);
$lev = mysql_query('SELECT `level`,`exp` FROM `levels` WHERE `level` = '.$row['level']);
$lev = mysql_fetch_assoc($lev);
if($row['exp'] >= $lev['exp'])
{
$expu=$row['exp']-$lev['exp'];
$row['exp']=$expu;
mysql_query('UPDATE `users` SET `level` = `level` + 1, `exp` = $expu WHERE `userid` = '.$ir['userid']);
}
}
Posted

Re: Level System

Sorry for the triple posts but I'm keeping you up to date with what i've changed... I've figured out the problems I think? I just need help with this... The first SQL Update works.. It won't run the next one.... I tried doing in all on one line. When I do that it doesn't update the level then...

With this code here... It updates the level fine... Just doesn't set the exp back to 0.

 

function check_level()
{
global $ir;
$row = mysql_query('SELECT `level`,`exp` FROM `users` WHERE `userid` = '.$ir['userid']);
$row = mysql_fetch_assoc($row);
$lev = mysql_query('SELECT `level`,`exp` FROM `levels` WHERE `level` = '.$row['level']);
$lev = mysql_fetch_assoc($lev);
if($row['exp'] >= $lev['exp'])
{
mysql_query('UPDATE `users` SET `level` = `level` + 1, `exp` = `0` WHERE `userid` = '.$ir['userid']);
mysql_query('UPDATE `users` SET `exp` = `0` WHERE `userid` = '.$ir['userid']);
}
}
Posted

Re: Level System

 

Just thinking do you have a table called level?

Yeah he does i helped him yestoday do this, but then i felt tired, meh went to bed at 9pm meh got up at half 2pm lol

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