SA-MP Forums Archive
[Tutorial] Hooking CallBack(s) - How to Hook any callback - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Hooking CallBack(s) - How to Hook any callback (/showthread.php?tid=386013)



Hooking CallBack(s) - How to Hook any callback - Swimor - 18.10.2012

Hooking CallBack(s) - How to Hook any callback

Hello all,
This tutorial is about hooking callback(s)-(any).

Let's start with simple example of OnFIlterScriptInit hook:
Код:
public OnFilterScriptInit()
{
	CallLocalFunction("RL@_OnFilterScriptInit", "");
	//Your code here!
}
#if defined _ALS_OnFilterScriptInit
	#undef OnFilterScriptInit
#else
	#define _ALS_OnFilterScriptInit
#endif
#define OnFilterScriptInit RL@_OnFilterScriptInit
forward RL@_OnFilterScriptInit();
First we need to call the public that we want no hook:
Код:
public OnFilterScriptInit()
{
	
}
Next we need to add this code to hook the callback:
Код:
#if defined _ALS_OnFilterScriptInit
	#undef OnFilterScriptInit
#else
	#define _ALS_OnFilterScriptInit
#endif
#define OnFilterScriptInit PRE_OnFilterScriptInit
And the last step, we need to forward the hook callbcack:
Код:
forward PRE_ OnFilterScriptInit();
Now, when OnFilterScript will called the hook public wiil called to.

Enjoy!




Re: Hooking CallBack(s) - How to Hook any callback - CoDeZ - 18.10.2012

Well since there is finally a tutorial about hooking
Can someone please tell me what does hooking mean?
What's the benefit of hooking a callback?


Re: Hooking CallBack(s) - How to Hook any callback - Glint - 19.10.2012

And why don't you use y_hooks it will save you from all the hassle anyways just hook TheCallback

and as ****** said this is not explained good, i think even you don't know what those codes do.


Re: Hooking CallBack(s) - How to Hook any callback - RenSoprano - 19.10.2012

Really I didn't understand nothing from this tutorial and what you are talking about. What ALS and PRE mean?


Re: Hooking CallBack(s) - How to Hook any callback - JaKe Elite - 19.10.2012

The tutorial is not explained well.

Anyway, use y_hook its more faster than ALS.


Re: Hooking CallBack(s) - How to Hook any callback - CoDeZ - 19.10.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
There's been a tutorial on hooking since the technique was first developed, people just don't bother searching. I may start deleting "tutorials" like this one that don't explain anything so that they don't bury the actually good ones.
Excuse me sir, but i did bother and searched, but i couldn't find exactly what does Hooking mean, i just found hooking methods without explaination.
If you can send me the tutorial through PM would be appreciated.


Re: Hooking CallBack(s) - How to Hook any callback - Amit_B - 19.10.2012

Quote:
Originally Posted by Romel
Посмотреть сообщение
The tutorial is not explained well.

Anyway, use y_hook its more faster than ALS.
And I can't see any single reason to post it after a few users have already done that. :X

Quote:
Originally Posted by ******
Посмотреть сообщение
There's been a tutorial on hooking since the technique was first developed, people just don't bother searching. I may start deleting "tutorials" like this one that don't explain anything so that they don't bury the actually good ones.
Please do so! (No offence Swimor, he just has pointed something important, and i'm agree with him)