09.10.2014, 00:41
@Eth : You should know how normally callbacks are triggered and how hooking works. If you were clear with that and didn't understand the tutorial, let me know.
Yes and the main point of this tutorial is to avoid that error even if the user may not have it defined on their gamemode.
Quote:
|
The reason why CallLocalFunction is used is because the user may not have the default callback in their gamemode. If you delete OnPlayerEnterVehicle from your gamemode you will get compiling errors.
|
pawn Code:
//Callback hooked : OnFilterScriptInit
//My custom callback : MyCustomFSCall();
#include <a_samp>
new
rand_int;
public OnFilterScriptInit() {
print("Test : Started FS");
rand_int = 5;
if(rand_int == 5) {
return MyCustomFSCall();
}
#if defined Lib_OnFSInit
return Lib_OnFSInit();
#else
return 1;
#endif
}
#if defined _ALS_OnFilterScriptInit
#undef OnFilterScriptInit
#else
#define _ALS_OnFilterScriptInit
#endif
#define OnFilterScriptInit Lib_OnFSInit
#if defined Lib_OnFSInit
forward Lib_OnFSInit();
#endif
forward MyCustomFSCall();
public MyCustomFSCall() {
//Hooking it once more to use it again.
print("Test : Call 1");
#if defined Lib_MyCustomFSCall
return Lib_MyCustomFSCall();
#else
return 1;
#endif
}
#if defined _ALS_MyCustomFSCall
#undef MyCustomFSCall
#else
#define _ALS_MyCustomFSCall
#endif
#define MyCustomFSCall Lib_MyCustomFSCall
#if defined Lib_MyCustomFSCall
forward Lib_MyCustomFSCall();
#endif
//#Suppose this as an end of an include
//My FS
/*public MyCustomFSCall() {
//Here's it, once again I'm using this callback. If you're building an include, you don't have to
//call your same callback once again, if you do, you will have to hook it to call it again separately.
printf("Test : Call 2");
return 1;
}*/
//Even if that's not implemented on my FS, it won't give errors because it's already implemented on my include.
//To avoid the error if it's also implemented on this FS, I hooked it.


