Helpful Information
 
 
Category: vBulletin 3 Discussion
Can't get this working

I've attached the file here. This part is causing trouble:
$expneed = 50;
$expaddedneed = 0;
$tempexp = $exp;

while ($tempexp > 0)
{
$tempexp - $expneed;
$expaddedneed = $expaddedneed + 25;
if (($tempexp == 0) || ($tempexp > 0))
{$level++;}
$expneed = $expneed + $expaddedneed;
}
When I enter a value for exp that is not 0 then it doesn't work because I get a connection timed out every time. What am I doing wrong? :(

Also can anyone help making this part a little more efficient?
$lastuserid=$DB_site->query_first("SELECT MAX(userid) AS lastuser FROM user");

echo "<tr class='".getrowbg()."' valign='top'><td>";

$counter = 1;
while ($counter != ($lastuserid['lastuser']+1))
{$someuser=$DB_site->query_first("SELECT username FROM user WHERE userid=$counter");
if ($someuser[username]!="") {
echo "<a href=\"rpgadmin.php?action=edituser&ausername=$someuser[username]\">$someuser[username]</a><br>";
}
$counter++;
}

echo "</td></tr>";

If you are wanting to take something away use

$var -= $value;

this decreases $var by $value

you can also use += to increment

try

$expneed = 50;
$expaddedneed = 0;
$tempexp = $exp;

while ($tempexp > 0) {
$tempexp -= $expneed;
$expaddedneed = $expaddedneed + 25;
if (($tempexp == 0) || ($tempexp > 0)) {
$level++;
}
$expneed += $expaddedneed;

}

oh and this

echo "<tr class='".getrowbg()."' valign='top'><td>";

$users = $DB_site->query("SELECT username FROM user");

while ($user = $DB_site->fetch_array($users)) {
echo "<a href=\"rpgadmin.php?action=edituser&ausername=$user[username]\">$user[username]</a><br>";
}

echo "</td></tr>";

Thank you, that worked. :) With that and one slight other change the level up system is done. Now this part only needs to be added everywhere where exp can be changed namely when a user posts.

Edit: Heh the 2nd fix also list the users alphabetically (sp?). Another improvement. :)










privacy (GDPR)