floor lvl help

votter

New Member
Messages
34
Reaction score
0
Points
0
PHP:
<?php
$woodcuttexp = $Exp['woodcuttingexp'];
$newwoodcuttinglvl = $Levels['woodcuttinglvl'] + 1;
$level = $newwoodcuttinglvl;
if (floor($woodcuttexp > 320)){
echo '<font color="yellow">You have reached woodcutting lvl ' . $level . ' </font><br />';
mysql_query("UPDATE `Levels` SET `woodcuttinglvl` = '$newwoodcuttinglvl' WHERE `userid` = '$user[id]' LIMIT 1")
or die(mysql_error());
} else {
echo '';
}
?>
Is what I am trying, but I can't the the floor to work right, it just keeps updating, anybody know how I can fix the floor?
 
Last edited:

marshian

New Member
Messages
526
Reaction score
9
Points
0
floor() just makes an integer of the given float/double by dropping anything behind the decimal sign. So floor(32) = 32, floor(32.1) = 32, floor(32.999) = 32
 

votter

New Member
Messages
34
Reaction score
0
Points
0
ah ok, know how I could get it to work so once they get to 300 or past it, it will update the level once and then stop?

[closed]
 
Last edited:

marshian

New Member
Messages
526
Reaction score
9
Points
0
PHP:
<?php
$woodcuttexp = $Exp['woodcuttingexp'];
$newwoodcuttinglvl = $Levels['woodcuttinglvl'] + 1;
$level = $newwoodcuttinglvl;
if ($woodcuttexp > 320){
echo '<font color="yellow">You have reached woodcutting lvl ' . $level . ' </font><br />';
mysql_query("UPDATE `Levels` SET `woodcuttinglvl` = '$newwoodcuttinglvl' WHERE `userid` = '$user[id]' LIMIT 1")
or die(mysql_error());
// Set XP to 0 here!
} else {
echo '';
}
?>

^ look at the comment
 

votter

New Member
Messages
34
Reaction score
0
Points
0
I don't want the exp to keep going to 0 though, Thanks all for the help. :D.
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
If you keep the same statment ($woodcuttexp > 320) and the same code in the if-clause without resetting the xp, the woodcutting lvl will increase by 1 each time you visit that page...
 
Top