open.mp forum
[Pawn] Hooks Problem - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] Hooks Problem (/showthread.php?tid=1743)



Hooks Problem - Kodokushi - 2021-03-08

Hi

I'm having a problem where a callback is not called in the modules (I'm using y_hooks). Using hooks with native callbacks this doesn't happen.



Code:
// GAMEMODE
forward OnPlayerChangeJob(playerid, pJob);
public OnPlayerChangeJob(playerid, pJob) {
}

OnPlayerChangeJob(playerid, pJob);

// MODULES
hook OnPlayerChangeJob(playerid, pJob) {
? ? SendClientMessage(playerid, -1, "CALLED!");
? ? return true;
}



RE: Hooks Problem - Y_Less - 2021-03-08

How are you calling the custom callback? You need to use `CallLocalFunction` for hooks to work.


RE: Hooks Problem - Kodokushi - 2021-03-08

It's solved, thanks.



Sorry for that stupid question. I was putting 'OnPlayerChangeJob' on gamemode.