Jump to content
MakeWebGames

Gangster Legends Hook - Documentation


Dayo

Recommended Posts

Can more then one stat or link be returned? With the profileLink and profileStat hook?

@Dayo

I need to add the userAction hooks to my mods. To try and get other people to follow suit. But My Mod below takes full advantage of the UserAction hook. 

 

Edited by Sim
Link to comment
Share on other sites

<?php

new Hook("userAction", function ($data) {
  global $db, $user;


debug("id: " . $data['user']);
debug(var_dump($data));     
})

?>

 

There is a issue with using the userAction hook and login mod. It will create this error the first time you try to login. If you hit refresh, your be logged in with no error.

Lines 43 and 45 on login.inc.php. I am unsure if he userhook causes problems anywhere else as I only tried using it during logins so far. On several mods ND several different occasions. Not once have I not encountered this.

Screenshot_20200427-220111.png.04922f6fa0511660512d95cffa4a6cd2.png

 

Edit:

Here's the fix.

Replace lines 43 and 45

$this->user->id with $user->info->U_id

Now, I don't know why $this->user->id works when you hit refresh but doesn't first time trying to login in with the hook. 🙂

  • Like 1
Link to comment
Share on other sites

There was a problem with the userAction hook bank.SendMoney

It passed id as NULL.

Old code:

$actionHook = new hook("userAction");
            $action = array(
                "user" => $this->user->id, 
                "module" => "bank.sendMoney", 
                "id" => $user->info->id, 
                "success" => true, 
                "reward" => $money
            );

New code:

$actionHook = new hook("userAction");
            $action = array(
                "user" => $this->user->id, 
                "module" => "bank.sendMoney", 
                "id" => $user->info->U_id, 
                "success" => true, 
                "reward" => $money
            );

 

There is a problem with the jail userAction hook. It passes the users rank you are trying to break out or jail instead of there id.

On line 125 and line 151 code is:

$action = array(
                    "user" => $this->user->id, 
                    "module" => "jail", 
                    "id" => $user->info->US_rank, 
                    "success" => false, 
                    "reward" => 0
                );

 Can be replaced with this to fix:

$action = array(
                    "user" => $this->user->id, 
                    "module" => "jail", 
                    "id" => $id, 
                    "success" => false, 
                    "reward" => 0
                );

 

EDIT:

You spelled property like this on the property transfer hook. You definitely rushed these. :). At least you got m to thoroughly test your hooks. Don't worry I left a comment in my code. Lol

//I'm forced to spell wrong for my code to work properly since @Dayo don't know how to spell property properly 

 propety.transfer

Screenshot_20200503-180228.thumb.png.7a548409d71c053e2c861ea257a63184.png

Edited by Sim
  • Haha 1
Link to comment
Share on other sites

  • Dayo pinned this topic
  • 1 year later...
  • 3 months later...
new hook("profileStat", function ($profile) {
  global $user;
  if ($user->id == $profile->info->U_id) {
    return array(
      "stat" => profile->info->US_kills, 
      "text" => "Kills"
    );
  }
});

How can I add multiple stats to the profile from the hooks page. I tried some 2d arrays with no results.

 

Also @Dayo can you update the hooks documentation.  I know there is a new Hook or two? And thw other typos I found in hooks. Missing $action in action hooks, forgot $ in profileStat hooks as seen above

Link to comment
Share on other sites

  • 4 weeks later...

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