Hooking callbacks in plugins
#1

Hey guys

Lets say my plugin wants to get a notification when a player enters a vehicle: i want to hook the "OnPlayerEnterVehicle" callback.

I already know how to hook functions in plugins (by the way, thanks to user 0x5A656578 )
(http://forum.sa-mp.com/showthread.ph...ok+callbacks):

Код:
// This code overrids "SetPlayerPos"

AMX_NATIVE SetPlayerPos;

cell AMX_NATIVE_CALL MySetPlayerPos(AMX *amx, cell *params) 
{
    logprintf("SetPlayerPos called!");
    return SetPlayerPos(amx, params);
}



int index=0;
if(amx_FindNative(amx, "SetPlayerPos", &index) == AMX_ERR_NONE) 
{
   AMX_HEADER *hdr = reinterpret_cast<AMX_HEADER*>(amx->base);
   AMX_FUNCSTUBNT *natives = reinterpret_cast<AMX_FUNCSTUBNT*>(amx->base + hdr->natives);
   ::SetPlayerPos = reinterpret_cast<AMX_NATIVE>(natives[index].address);
   natives[index].address = reinterpret_cast<ucell>(MySetPlayerPos);
   logprintf("  SetPlayerPos found");
} 
else
{
   logprintf("  SetPlayerPos NOT found");
}
Although I have been searching for some days, I cant find ANYTHING.. That surprises me 0o
I am not sure if hooking callbacks is just another taboo topic here....
but I am really thankfull for a bit help.

Thank you,
webcode421F
Reply
#2

gdk.
Reply
#3

I guess that means "game developemt kit", right?
I can't find a link to this GDK.. And unfortunately I've never heard about it.

Can anyone post a link please?
Reply
#4

i think he meaned sampgdk - https://github.com/Zeex/sampgdk
Reply
#5

Aaah ok that seems to be interesting.
thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)