icsulescu Posted August 16, 2010 Share Posted August 16, 2010 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? Quote Link to comment Share on other sites More sharing options...
Zeggy Posted August 16, 2010 Share Posted August 16, 2010 Is there an error? Quote Link to comment Share on other sites More sharing options...
icsulescu Posted August 16, 2010 Author Share Posted August 16, 2010 Is there an error? No error ... and the all the pages of the game are blank when I upload this hook. Quote Link to comment Share on other sites More sharing options...
Zeggy Posted August 16, 2010 Share Posted August 16, 2010 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; Quote Link to comment Share on other sites More sharing options...
icsulescu Posted August 16, 2010 Author Share Posted August 16, 2010 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 :(. Quote Link to comment Share on other sites More sharing options...
Zeggy Posted August 16, 2010 Share Posted August 16, 2010 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); Quote Link to comment Share on other sites More sharing options...
icsulescu Posted August 16, 2010 Author Share Posted August 16, 2010 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. 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.