open.mp forum
[Pawn] y_hooks - multi level hooking problem - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] y_hooks - multi level hooking problem (/showthread.php?tid=730)



y_hooks - multi level hooking problem - Luciano - 2019-07-24

I have the following files:



Code:
====== gamemodes/mymode.pwn?======

#include <a_samp>

#include <YSI_Coding\y_hooks>

#include .\src\first.pwn



public OnGameModeInit()

{

? ??printf("mymode.pwn");

}





======?gamemodes/src/first.pwn?======

#include <YSI_Coding\y_hooks>

#include .\src\second.pwn



hook OnGameModeInit()

{

? ? printf("first.pwn");

}







======?gamemodes/src/second.pwn?======

#include <YSI_Coding\y_hooks>



hook OnGameModeInit()

{

? ? printf("second.pwn");

}





I'm getting this error:?
Code:
.\first.pwn(6) : error 021: symbol already defined: "@yH_OnGameModeInit@002"



Is it possible to use hooks like this and if yes, what is my mistake?


RE: y_hooks - multi level hooking problem - Manyula - 2019-07-25

You're including y_hooks three times in one file. Make sure to include it only once in a file. Remember that every file that uses the hooks needs to include y_hooks.


RE: y_hooks - multi level hooking problem - Y_Less - 2019-07-26

You can include it multiple times. Just make sure it is always the last include in a file.