Hooking custom callbacks using y_hooks -
[XST]O_x - 02.03.2016
Is it possible to hook my own callbacks (not default SA:MP ones) using y_hooks?
Because right now the hooked callback doesn't get called at all, but the original one does.
What I mean is:
pawn Код:
//On gamemode
forward OnMyCustomCallbackGetsCalled();
public OnGameModeInit()
{
OnMyCustomCallbackGetsCalled(); //Call the callback
return 1;
}
public OnMyCustomCallbackGetsCalled()
{
//Gets called
return 1;
}
//On include
hook OnMyCustomCallbackGetsCalled()
{
//Doesn't get called
return 1;
}
Re: Hooking custom callbacks using y_hooks -
[XST]O_x - 02.03.2016
Bump
Re: Hooking custom callbacks using y_hooks -
[XST]O_x - 03.03.2016
Bump.
I also figured hooking some native callbacks doesn't work, such as OnTrailerUpdate, and OnGameModeExit
Re: Hooking custom callbacks using y_hooks -
SecretBoss - 03.03.2016
OnGameModeInit also doesn't work
y_hooks provide some callbacks if the callback is not listed I think it can't hook it
Re: Hooking custom callbacks using y_hooks -
Misiur - 03.03.2016
It's easy. Don't use OnMyCustomCallbackGetsCalled();, do
pawn Код:
CallLocalFunction("OnMyCustomCallbackGetsCalled", "");
Re: Hooking custom callbacks using y_hooks -
[XST]O_x - 03.03.2016
Quote:
Originally Posted by Misiur
It's easy. Don't use OnMyCustomCallbackGetsCalled();, do
pawn Код:
CallLocalFunction("OnMyCustomCallbackGetsCalled", "");
|
Aha. Beautiful. It's working now, thanks

But what about OnGameModeExit?
Re: Hooking custom callbacks using y_hooks -
Misiur - 03.03.2016
I'm not aware of it not working, are you using YSI 3 or 4?
Re: Hooking custom callbacks using y_hooks -
[XST]O_x - 03.03.2016
Quote:
Originally Posted by Misiur
I'm not aware of it not working, are you using YSI 3 or 4?
|
I've used YSI 3.1, and now 4.0. It didn't make any difference.
Re: Hooking custom callbacks using y_hooks -
Misiur - 03.03.2016
Have you checked if it is executing on GMX? Normal ctrl+c doesn't execute OGME at all.
Re: Hooking custom callbacks using y_hooks -
[XST]O_x - 04.03.2016
Quote:
Originally Posted by Misiur
Have you checked if it is executing on GMX? Normal ctrl+c doesn't execute OGME at all.
|
Every time I'm updating something in my gamemode I'm using gmx. That's the only way I'm resetting the server, and I know it doesn't get called because nothing gets saved to the database. I'll try moving the calling of the save function to the main OnGameModeExit and see if it works.