Hooking callbacks in plugins - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (
https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: Hooking callbacks in plugins (
/showthread.php?tid=335434)
Hooking callbacks in plugins -
webcode421F - 18.04.2012
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
Re: Hooking callbacks in plugins -
steki. - 18.04.2012
gdk.
Re: Hooking callbacks in plugins -
webcode421F - 18.04.2012
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?
Re: Hooking callbacks in plugins -
Gigi-The-Beast - 18.04.2012
i think he meaned sampgdk -
https://github.com/Zeex/sampgdk
Re: Hooking callbacks in plugins -
webcode421F - 18.04.2012
Aaah ok that seems to be interesting.
thank you.