Jump to content
MakeWebGames

Energy, Brave etc REFILL on Level up


Naffer20

Recommended Posts

How would I implement this?

I use

What would I add?

<?php
$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'])
{
$expu=$ir['exp']-$ir['exp_needed'];
$ir['exp']=$expu;
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);

$unlocks='<em>None</em>';

$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)) {
$unlocks=$unlocks.'<li>'.$c['cityname'].'</li>';
}
$unlocks=$unlocks.'</ul>';
}

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

}


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

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