Hooking custom callbacks using y_hooks
#1

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;
}
Reply
#2

Bump
Reply
#3

Bump.
I also figured hooking some native callbacks doesn't work, such as OnTrailerUpdate, and OnGameModeExit
Reply
#4

OnGameModeInit also doesn't work

y_hooks provide some callbacks if the callback is not listed I think it can't hook it
Reply
#5

It's easy. Don't use OnMyCustomCallbackGetsCalled();, do
pawn Код:
CallLocalFunction("OnMyCustomCallbackGetsCalled", "");
Reply
#6

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?
Reply
#7

I'm not aware of it not working, are you using YSI 3 or 4?
Reply
#8

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.
Reply
#9

Have you checked if it is executing on GMX? Normal ctrl+c doesn't execute OGME at all.
Reply
#10

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


Forum Jump:


Users browsing this thread: 2 Guest(s)