Jump to content
MakeWebGames

Recommended Posts

Posted

Hi. I have a problem with EZrpg script. I tried to make a hook like this:

 

<?php
defined('IN_EZRPG') or exit;

$hooks->add_hook('header', 'set_power');

function hook_set_power(&$db, &$tpl, &$player, $args = 0)
{
   if ($args === 0 || LOGGED_IN == false)
   return $args;

   else
   {

   $power = ((($player->attack+player->defence)*0.31)-0.15);
   $finalpower= number_format($power, 2);

   $db->execute('UPDATE `<ezrpg>players` SET `power`=? WHERE `id`=?', array($finalpower, intval($args->id)));

   $tpl->assign('POWER', $finalpower);    
   }


   return $args;
}
?>

 

But it doesn't work ... :(. Can anyone help me with this?

Posted

Did you turn on error reporting/debug mode in config.php?

You need to add opening and closing braces to this line of code:

if ($args === 0 || LOGGED_IN == false)

return $args;

Posted
Did you turn on error reporting/debug mode in config.php?

Yes.

 

You need to add opening and closing braces to this line of code:

if ($args === 0 || LOGGED_IN == false)

return $args;

How? Like this:

if ($args === 0 || LOGGED_IN == false)

{

return $args;

}

? It didn't worked. Still all pages are blank :(.

Posted

Hmmm, that's strange.

And the game works fine when you remove this hook?

Change intval($args->id) to intval($player->id). $args does not contain player data for the header hook.

Edit: And dominion pointed this out to me, you're missing a $ sign:

$power = ((($player->attack+$player->defence)*0.31)-0.15);

Posted
Hmmm, that's strange.

And the game works fine when you remove this hook?

Change intval($args->id) to intval($player->id). $args does not contain player data for the header hook.

Edit: And dominion pointed this out to me, you're missing a $ sign:

$power = ((($player->attack+$player->defence)*0.31)-0.15);

Yes :). Now it works.

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