SA-MP Forums Archive
Modular scripting and hooking - 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)
+--- Thread: Modular scripting and hooking (/showthread.php?tid=616716)



Modular scripting and hooking - venomlivno8 - 09.09.2016

main.pwn

pawn Код:
#include <a_samp>

#include "utils/players/data.pwn"

main() {
    printf(" Script started ! ");
}

public OnGameModeInit() {

    #if defined plydata_OnGameModeInit
        printf(" Called plydata_OnGameModeInit ");
        plydata_OnGameModeInit();
    #endif

    return 1;
}

#if defined _ALS_OnGameModeInit
    #undef OnGameModeInit
#else
    #define _ALS_OnGameModeInit
#endif
#define OnGameModeInit plydata_OnGameModeInit
#if defined plydata_OnGameModeInit
    forward plydata_OnGameModeInit();
#endif
data.pwn

pawn Код:
public plydata_OnGameModeInit() {
    printf(" data_OnGameModeInit() ");
    return 1;
}
Is this the right method of hooking or not?


Re: Modular scripting and hooking - Vince - 09.09.2016

The idea behind hooking is that you don't call the hooked function explicitly. Assuming that main.pwn is your main script, there shouldn't be anything there. The data.pwn should contain another normal OnGameModeInit and the ALS stuff should come after that.


Re: Modular scripting and hooking - venomlivno8 - 09.09.2016

Can you please explain that a little bit? Since it's not explained elsewhere. I'm new to hooking, I read the tutorials but I don't get it.


Re: Modular scripting and hooking - Marricio - 09.09.2016

y_hooks makes it very simple for you, it is very user friendly. Check this page:

http://ysi.wikia.com/wiki/Library:YSI%5Cy_hooks