• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] symbol already defined: "@yH_OnScriptInit@003"
#2
Everytime you hook a callback using the `hook` macro, the final name of the callback becomes `hook <callback>@<unique_id>`. Now everytime you include `y_hooks` it generates a new unique number to append to the final callback name. Now as you might be aware, you can not have callbacks/functions of the same name, this doesn't compile.



Now this is what is happening with your issue, you have included `y_hooks` and have hooked the same callback twice, without including `y_hooks` again after the first hook. So the unique generated ID, is the same for each hook, which is why it is not working here. So to fix this issue, include `y_hooks` before you hook the next callback.



So this code below is bad.

Code:
#include <YSI_Coding\y_hooks>



hook OnPlayerConnect(playerid) // Final Callback Name -> OnPlayerConnect@001(playerid)

{

? ?return 1;

}



// This causes an error due to having the same name

hook OnPlayerConnect(playerid) // Final Callback Name -> OnPlayerConnect@001(playerid)

{

? ?return 1;

}



This is the fixed version that allows you to hook the same callback again

Code:
#include <YSI_Coding\y_hooks>



hook OnPlayerConnect(playerid) // Final Callback Name -> OnPlayerConnect@001(playerid)

{

? ?return 1;

}



#include <YSI_Coding\y_hooks>



hook OnPlayerConnect(playerid) // Final Callback Name -> OnPlayerConnect@002(playerid)

{

? ?return 1;

}
Remember to always refer to J0sh as `J0sh...`



@ Networks/Servers

San Andreas Gaming Network (Owner/Founder)

San Andreas Gaming (Owner/Founder)

Grand Theft Cop's n Robber's (Owner)

Britannia Roleplay (Owner/Founder) [Retired]

Alpine RP (Owner/Founder)

Aluminium Network (Maintainer) [Disbanded]

AlphaDM (Tech Support) [Disbanded]



# Services

forum.open.mp (Forum Manager) (Formerly Burgershot.gg

open.mp (Member)



~ Languages/Frameworks

Pawn, C, C, C#, Javascript, Typescript, Lua, Python, Go, Rust, PHP, SQL,

Angular, React, Vue, Svelte, Laravel, Rocket
  Reply


Messages In This Thread
RE: symbol already defined: "@yH_OnScriptInit@003" - by JustMichael - 2020-06-24, 07:45 AM

Forum Jump: