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


Messages In This Thread
Hooking callbacks in plugins - by webcode421F - 18.04.2012, 14:23
Re: Hooking callbacks in plugins - by steki. - 18.04.2012, 14:35
Re: Hooking callbacks in plugins - by webcode421F - 18.04.2012, 16:08
Re: Hooking callbacks in plugins - by Gigi-The-Beast - 18.04.2012, 16:12
Re: Hooking callbacks in plugins - by webcode421F - 18.04.2012, 16:15

Forum Jump:


Users browsing this thread: 2 Guest(s)