YSI-Includes
YSI-Includes copied to clipboard
y_hooks function type-check
Why?
Well.. I've just came across a really annoying issue which costed me time and was like finding a needle in a haystack in a big game mode that are separated in different modules (y_hooks is one of the main dependency)
The code below is VALID and SHOULD compile, I don't see why it shouldn't but it's PRONE to typos and bugs which can cause your hooks functions to not get called.
// Playe -> Player (typo)
hook OnPlayeRegister(playerid) -> hook OnPlayerRegister(playerid)
Solution
I would trade compile type-check anytime as it would save hassle in the future.
- Implementation
// Func() forwarded? then allow the function too be hooked
hook forward Func();
// Func() is not forwarded? THROW an error.
hook public Func() {
return 1;
}
- Old version
// The code above is better than the code below which could lead to typos
// and could cost YOU hours in future if your gamemode is split into different modules
// and it's y_hooks dependant, a simple typo in 30+ files could cost you hours.
// it's like finding a needle in a haystack!
hook Func() {
return 1;
}