Jump to content

Energy, Brave etc REFILL on Level up


Recommended Posts

How would I implement this?

I use

What would I add?

$ir['exp_needed']=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*2.2);

if($ir['exp'] >= $ir['exp_needed'] && $ir['level']!=$set['max_level'])
if ($set['level_gain']>0) {$gain='You received $'.(($ir['level']+1)*$set['level_gain']); $gainsql=' `money`=`money`+'.(($ir['level']+1)*$set['level_gain']).',';}
$db->query("UPDATE `users` SET".$gainsql." `level`=`level`+1, `exp`=$expu, `energy`=`energy`+".$set['energy_gain'].", `brave`=`brave`+".$set['brave_gain'].", `maxenergy`=`maxenergy`+".$set['energy_gain'].", `maxbrave`=`maxbrave`+".$set['brave_gain'].", `hp`=`hp`+".$set['hp_gain'].", `maxhp`=`maxhp`+".$set['hp_gain']." WHERE `userid`=".$ir['userid']);
event_add($ir['userid'], 'You have leveled up you are now level <strong>'.($ir['level']+1).'</strong>'.$gain, $c);


$q=mysql_query("SELECT `cityname` FROM `cities` WHERE `cityminlevel`=".($ir['level']+1));
if (mysql_num_rows($q)>0) {
$unlocks='<strong>You can travel to:</strong><ul>';
while ($c=mysql_fetch-array($q)) {

echo '
<div align="center">
<table width="50%">
<strong>You have leveled up!</strong>
You are now level: '.($ir['level']+1).'


Link to comment
Share on other sites

something like...

$energyfill = $ir['maxenergy'] - $ir['energy'];
$bravefill = $ir['maxbrave'] - $ir['brave'];
$db->query("UPDATE users set brave=brave+$bravefill, energy=energy+$energyfill WHERE userid=$userid");


Something along them lines should work but that's probably the longer way round of doing it :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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