Jump to content
MakeWebGames

Upgrade Mod - Not working [Redux]


stevenrfc
 Share

Recommended Posts

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 :)

Link to comment
Share on other sites

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.

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.

 Share

×
×
  • Create New...