1
I want to create a general class that checks the experience of users in session.
Experience variables:
$level1 = 0;
$level2 = 50;
$level3 = 100;
...
My question and goal is to create something like:
if user tiver 0 exp, add lvl1
if user tiver 50 exp, add lvl2
if user tiver 100 exp, add lvl3
....
I started to create this way, but every time I do refresh it always adds +1 level. I wanted you to just add 1x when having that experience:
if($level) {
$level1 = 0;
$level2 = 50;
$level3 = 100;
$level4 = 150;
$level5 = 200;
$level6 = 250;
$level6 = 300;
if($exp == $level2) {
$update1 = "UPDATE users_steam SET level = level + '1' WHERE steamid = '$steamid'";
$result1 = $db->query($update1);
} else if($exp == $level3) {
$update2 = "UPDATE users_steam SET level = level + '1' WHERE steamid = '$steamid'";
$result2 = $db->query($update2);
}
}
How can I make it stop when I check the experience and add the new level?
Use Array should solve your problem.
– Guilherme Nascimento
Well, what might happen is that you’re not zeroing in on the experience. Example: I have a table that has current Exp and max Exp, when it reaches the max Exp I reset the current Exp, and increase the max Exp. This avoids this problem.
– Raizant
hum ok understood, it is a good solution, and how can I increase the security of this script and updates?
– user75549