stevenrfc Posted October 29, 2012 Posted October 29, 2012 Hello, :) i hope I've posted this in the right section. Anyway, my PHP skills aren't yet good enough to solve my problem and I'm wondering if anyone could help me with this. I tired to add this mod: http://makewebgames.io/showthread.php/33655-mccode-v2-Advanced(isher)-Level-Upgrade-Mod?highlight=level+upgrade I tried to convert it and implement it into my game but i seem to be having trouble. The Upgrade button isn't appearing next to level, so I made it so that it just always shows, just for now but when I click on it, the page upgrade.php appears but its just a white page that displays "Vote for Game | Donate to Game now for game benefits!" Anyway here is the code. upgrade.php (I've commented out the brave increase because in the game i want the brave to stay at a certain number) <?php if (!defined($_CONFIG['define_code'])) { echo 'This file cannot be accessed directly.'; exit; } $exp_needed=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*2.2); if($ir[exp] < $exp_needed) { die("You need more experience before you can upgrade!"); } else { $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); $db->query( "UPDATE `users` SET `level` = `level` + 1, exp = {$expu}, `energy` = `energy` + 2, `maxenergy` = `maxenergy` + 2, `hp` = `hp` + 50, `maxhp` = `maxhp` + 50 WHERE `userid` = {$userid}"); print"You Upgraded to Level <b>{$ir['<span class='highlight'>level</span>']}</b>!"; } $h->endpage(); global_func.php 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']) { $exp_needed=(int) (($ir['level']+1)*($ir['level']+1)*($ir['level']+1)*2.2); if($ir['exp'] >= $exp_needed) { global $upgrade; $upgrade = "Y"; } } } Code in template.php <b>Name:</b> <?php echo "$gn{$u} [{$ir['userid']}] $d"; ?><br /> <b><?php echo $set['main_currency']; ?>:</b> <?php echo "{$fm}"; ?><br /> <b>Level:</b> <?php echo "{$ir['level']}"; ?><br /> <b><?php echo $set['second_currency']; ?>:</b> <?php echo "{$cm} [<a href='".gen_url('exchange',true)."&spend=refill'><span style='font-weight: bold;'>R</span></a>]"; ?><br /> <?php if($upgrade == "Y") { print"<a href='" . gen_url('upgrade', true) . "'>[upgrade]</a> <br />"; } ?> [<a href='<?php echo gen_url('logout',true); ?>'>Emergency Logout</a>] Any help would be much appreciated, Thanks :) Quote
rulerofzu Posted October 29, 2012 Posted October 29, 2012 Is a button essential? ie do you need a player to manually upgrade If not then if($ir[exp] >= $exp_needed){ $ir['level']+=1; } will auto up the level. You can also throw in any upgrade requirements in there (ie it costs x amount of cash/crystals) or send an event stating they could not level. Quote
stevenrfc Posted October 29, 2012 Author Posted October 29, 2012 Well yes, preferably I would like to have the option where users can hold their levels. But i just can't seem to get this working and I'm not sure why :( Thanks for the reply mate :) Quote
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.