Modular scripting and hooking
#1

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?
Reply
#2

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.
Reply
#3

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.
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: