Posts: 303
Threads: 20
Joined: Jul 2016
Reputation:
0
You can
Hook:1_OnPlayerSpawn(playerid)
{
return 1;
}
//
Hook:2_OnPlayerSpawn(playerid)
{
return 1;
}
...
Posts: 352
Threads: 37
Joined: Jun 2012
17.02.2019, 13:17
(
Последний раз редактировалось kristo; 17.02.2019 в 14:49.
)
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.
Posts: 352
Threads: 37
Joined: Jun 2012
These two lines alone show that you didn't even bother testing your code. If you did, you would've realised that you're wrong.