PDA

View Full Version : [Y_Hooks] Callback's name replacement


Dayrion
10/06/2017, 01:21 PM
Hello.
I've some problems with y_hooks. As you know, you can replace any name part of a callback by a diminutive to prevent the error of 32 characters.
This code is in the YSI's include:
// Create the default replacements.
DEFINE_HOOK_REPLACEMENT(Checkpoint, CP );
DEFINE_HOOK_REPLACEMENT(Container , Cnt);
DEFINE_HOOK_REPLACEMENT(Inventory , Inv);
DEFINE_HOOK_REPLACEMENT(Dynamic , Dyn);
DEFINE_HOOK_REPLACEMENT(TextDraw , TD );
DEFINE_HOOK_REPLACEMENT(Update , Upd);
DEFINE_HOOK_REPLACEMENT(Object , Obj);
DEFINE_HOOK_REPLACEMENT(Command , Cmd);
DEFINE_HOOK_REPLACEMENT(DynamicCP , DynamicCP);
DEFINE_HOOK_REPLACEMENT(Spawn, Spw);
The problem is, no one of my hook is called when I use replacement.
hook OnPlayerSpw(playerid)
{
printf("[DEBUGG] OnPlayerSpw CALLED");
return Y_HOOKS_CONTINUE_RETURN_1;
}
hook OnPlayerCmdPerformed(playerid, cmdtext[], success)
{
printf("OnPlayerCmdPerformed: '%s'", cmdtext);
return Y_HOOKS_CONTINUE_RETURN_1;
}
Of course, I did not modify the include (except adding 'DEFINE_HOOK_REPLACEMENT(Spawn, Spw)').
Have you some suggestions? Ideas or something?

Nicow
10/06/2017, 08:49 PM
This is really weird

OneDay
10/06/2017, 10:16 PM
Why you shorten them, they are not 32 character

Dayrion
10/06/2017, 11:47 PM
Why you shorten them, they are not 32 character

You don't know, certainly, how y_hooks works.
Let's show an example :
warning 200: symbol "@yH_OnPlayerEnterRaceCheckpoint" is truncated to 31 characters
So, to avoid this warning and prevent y_hooks to works perfectly; ****** made shortcut but they dont work for me.

Nicow
11/06/2017, 12:29 PM
It doesn't work with OnVehicleDmgStatusUpd (OnVehicleDamageStatusUpdate) neither

Dayrion
11/06/2017, 11:00 PM
I did some playing and may have found a bug in the scanner. For now, just don't shorten names that don't need it.

As Nicow said, we need it for OnVehicleDamageStatusUpdate. Any temporary fix or manipulation to do?
Thank you for your answer. :-[

Nicow
12/06/2017, 06:30 PM
Thank you for your answer, I saw your commit about fixes.inc support for y_hooks

So i tried to hook OnVehicleDamageStatusUpdate without fixes and without updating YSI/AMX and still the same issue
Then I tried to update YSI and amx, with and without fixes but same problem

Dayrion
13/06/2017, 01:43 AM
Try the version of YSI I just uploaded. I've tracked and patched some bugs. I won't say "FIXED", I can imagine some corner-cases where the fix might fail, but I'm not even sure how to construct a test for those cases.

Just tried and it worked!
hook OnVehicleDmgStatusUpd(vehicleid, playerid)
{
print("[DEBUG] OnVehicleDamageStatusUpdate called from hook.");
return Y_HOOKS_CONTINUE_RETURN_1;
}
----
DEFINE_HOOK_REPLACEMENT(Damage, Dmg);

If we get another problem about Y_Hooks, we will post there or on your GIT.
Thank you for your precious help.

Nicow
13/06/2017, 05:21 AM
Thanks a lot ! :)