open.mp forum
[Pawn] y_hooks multiple includes - 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 multiple includes (/showthread.php?tid=642)



y_hooks multiple includes - iReal Worlds - 2019-06-07

I have a problem using y_hooks:

I have the main gamemode (main.pwn), and two "modules" that are included in it: "module1.inc" and "module2.inc".



In both of them, I have to use y_hooks. From what I knew, you had to reinclude y_hooks if you wanted to hook to the same function, so at top of each module, I have

Code:
#include "..\include\YSI\y_hooks.inc"

But I get a "symbol already defined" error in "module2" for the callbacks that have already been hooked to in the first one.


RE: y_hooks multiple includes - Y_Less - 2019-06-08

You're right it needs including in every file, but order is also important - it should be the last include in every file:



https://github.com/pawn-lang/YSI-Includes/blob/5.x/YSI_Coding/y_hooks/faqs.md#error-021-symbol-already-defined-yh_ongamemodeinit003


RE: y_hooks multiple includes - iReal Worlds - 2019-06-10

(2019-06-08, 12:55 AM)Y_Less Wrote: You're right it needs including in every file, but order is also important - it should be the last include in every file:



https://github.com/pawn-lang/YSI-Includes/blob/5.x/YSI_Coding/y_hooks/faqs.md#error-021-symbol-already-defined-yh_ongamemodeinit003

I know, but it already is. It is actually the only include in one of the files:



module1.inc:

Code:
#include "..\include\evf.inc"



#include "..\include\YSI\y_hooks.inc"



module2.inc:

Code:
#include "..\include\YSI\y_hooks.inc"



RE: y_hooks multiple includes - Y_Less - 2019-06-11

Ahh, don't write the `.inc` part.