Reecey12345 Posted March 19, 2014 Share Posted March 19, 2014 Hey guys, would anybody be able to help me with adding rewards into my header? E.G, reach level 50 you gain 1 point and for every 50 level you gain 1 etc.. Cheers, to anybody who helps. Quote Link to comment Share on other sites More sharing options...
sniko Posted March 19, 2014 Share Posted March 19, 2014 # in checklevel (is that the correct name?) function, add if( ($ir['level'] % 50) == 0 ) { $strDbQry = "UPDATE `users` SET `crystals`=`crystals`+1 WHERE `userid`=". $_SESSION['userid']; $db->query($strDbQry); } Quote Link to comment Share on other sites More sharing options...
Reecey12345 Posted March 19, 2014 Author Share Posted March 19, 2014 Fab Sniko, tyvm:) Quote Link to comment Share on other sites More sharing options...
Reecey12345 Posted March 19, 2014 Author Share Posted March 19, 2014 if($ir['level']= 50) { $db->query("UPDATE users SET crystals=crystals+150 where userid=$userid"); } I tried it this way, i attempted it xD whats wrong with this maybe you could update it for me to the correct way or guide me with it:) Quote Link to comment Share on other sites More sharing options...
Guest Posted March 19, 2014 Share Posted March 19, 2014 if($ir['level']= 50) { $db->query("UPDATE users SET crystals=crystals+150 where userid=$userid"); } I tried it this way, i attempted it xD whats wrong with this maybe you could update it for me to the correct way or guide me with it:) That will only check if the level is 50, not if it's every 50 levels. Quote Link to comment Share on other sites More sharing options...
Reecey12345 Posted March 19, 2014 Author Share Posted March 19, 2014 This gives me an error on the page anyhow? I added after EOF; Quote Link to comment Share on other sites More sharing options...
sniko Posted March 19, 2014 Share Posted March 19, 2014 This gives me an error on the page anyhow? I added after EOF; Then you didn't put it in the check_level function Quote Link to comment Share on other sites More sharing options...
Reecey12345 Posted March 19, 2014 Author Share Posted March 19, 2014 So what would the exact line be for this? Quote Link to comment Share on other sites More sharing options...
sniko Posted March 19, 2014 Share Posted March 19, 2014 So what would the exact line be for this? -.- Okay, I'm done. Quote Link to comment Share on other sites More sharing options...
MNG Posted March 19, 2014 Share Posted March 19, 2014 So what would the exact line be for this? Not sure, I haven't played with the engine in awhile but try the classes.php or header.php Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted March 19, 2014 Share Posted March 19, 2014 It may be different for each person especially when you get adding to the global functions page or editing it. The function is called check_level. But make sure you add it in the right spot or else every page load some one does that is a common multiple of 50 it will just credit them instead of when the level up happens Quote Link to comment Share on other sites More sharing options...
Newbie Posted March 20, 2014 Share Posted March 20, 2014 (edited) dunno if this is right as cant test it but if wrong should give you a idea function check_level() { global $db; global $ir, $c, $userid; $ir['exp_needed'] = (int) (($ir['level'] + 1) * ($ir['level'] + 1) * ($ir['level'] + 1) * 2.2); if ($ir['exp'] >= $ir['exp_needed']) { $expu = $ir['exp'] - $ir['exp_needed']; $ir['level'] += 1; $ir['exp'] = $expu; $ir['energy'] += 2; $ir['brave'] += 2; $ir['maxenergy'] += 2; $ir['maxbrave'] += 2; $ir['hp'] += 50; $ir['maxhp'] += 50; $ir['exp_needed'] = (int) (($ir['level'] + 1) * ($ir['level'] + 1) * ($ir['level'] + 1) * 2.2); if( ($ir['level'] % 50) == 0 ) { $strDbQry = "UPDATE `users` SET `crystals`=`crystals`+1 WHERE `userid`=". $_SESSION['userid']; $db->query($strDbQry); } $db->query( "UPDATE `users` SET `level` = `level` + 1, exp = {$expu}, `energy` = `energy` + 2, `brave` = `brave` + 2, `maxenergy` = `maxenergy` + 2, `maxbrave` = `maxbrave` + 2, `hp` = `hp` + 50, `maxhp` = `maxhp` + 50 WHERE `userid` = {$userid}"); } } Edited March 20, 2014 by Newbie Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.