how many hooks?
#5

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
Well if you include it in the very main file, and include your filterscripts/includes after it will be running for every script.
That's not true. The main file rarely needs y_hooks, however each include/module that uses hooks should include either y_hooks or y_unique as the last include (preferrably y_hooks so you don't have to worry about if it has been included earlier or not). The main hooking functionality only gets included the first time, all following inclusions just increase the value of UNIQUE_SYMBOL from y_unique to avoid collisions between hook names.

Also, here's a quick example why it should be included as the last file in each include/module:

pawn Код:
// first.pwn
#include <YSI_Coding\y_hooks>

hook OnGameModeInit() { // compiles as @yH_OnGameModeInit@001
    return 1;
}


// second.pwn
#include <YSI_Coding\y_hooks>
#include "first.pwn"

hook OnGameModeInit() { // also compiles as @yH_OnGameModeInit@001
    return 1;
}
This causes a "symbol already defined" error.


pawn Код:
// first.pwn
#include <YSI_Coding\y_hooks>

hook OnGameModeInit() { // compiles as @yH_OnGameModeInit@000
    return 1;
}


// second.pwn
#include "first.pwn"
#include <YSI_Coding\y_hooks>

hook OnGameModeInit() { // compiles as @yH_OnGameModeInit@001
    return 1;
}
This, however, is fine.
Reply


Messages In This Thread
how many hooks? - by PepsiCola23 - 17.02.2019, 12:17
Re: how many hooks? - by ShadowMortar - 17.02.2019, 12:20
Re: how many hooks? - by PepsiCola23 - 17.02.2019, 12:37
Re: how many hooks? - by TheToretto - 17.02.2019, 12:53
Re: how many hooks? - by kristo - 17.02.2019, 13:17
Re: how many hooks? - by TheToretto - 17.02.2019, 14:17
Re: how many hooks? - by kristo - 17.02.2019, 14:43
Re: how many hooks? - by TheToretto - 17.02.2019, 14:47

Forum Jump:


Users browsing this thread: 1 Guest(s)