Jump to content
Sign in to follow this  
Dayo

Gangster Legends Hook - Documentation

Recommended Posts

Awesome. Thanks. Maybe add a new sub forum "Coding help / development works in progress"

 

Maybe "Show your work in progress or need help with GL code?"

Share this post


Link to post
Share on other sites
Posted (edited)

Inside the user action hook example, you forgot to include the  $data parameter.

I think this topic should be stickied as well. Afterall, any GL documentation is very important.

Edited by Sim

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...