how many hooks?
#6

Quote:
Originally Posted by kvann
Посмотреть сообщение
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_Scripting\y_hooks>

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


// second.pwn
#include <YSI_Scripting\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_Scripting\y_hooks>

hook OnGameModeInit() {
    return 1;
}


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

hook OnGameModeInit() {
    return 1;
}
This, however, is fine.
pawn Код:
// first.pwn
#include <YSI\y_hooks>

hook OnGameModeInit() {
    return 1;
}


// second.pwn
#include "first.pwn"

hook OnGameModeInit() {
    return 1;
}
OR

pawn Код:
// gamemode.pwn
#include <a_samp>
#include <YSI\y_hooks>

#include "first.pwn"

hook OnGameModeInit() {
    return 1;
}


// first.pwn
#include "first.pwn"

hook OnGameModeInit() {
    return 1;
}

Both expressions, work, no need to include it each time.
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)