Closed ish12321 closed 4 years ago
Bump
Nobody will help you, because you didn't even read documentation. "Bump" will not work.
Sorry for the bump.
It will be good if we'll have stateful hooks in which you can pass userdata.
Any progress?
See plugins on ReAPI
I see no plugins in which we can get hookchain id in the callback.
#include <amxmodx>
#include <reapi>
new HookChain: g_hSpawn;
public plugin_init()
{
// You should get hook handler from native and remember his
g_hSpawn = RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn", .post = true));
// Simple cmd for test
register_clcmd("say /check", "toggler");
}
public toggler()
{
static bool: bToggle;
if(g_bToggle)
// It will disable hook
DisableHookChain(g_hSpawn);
else
// Well, you understand
EnableHookChain(g_hSpawn);
bToggle = !bToggle;
}
public CBasePlayer_Spawn()
{
// Was called when hook be ENABLED.
server_print("CALLED: -> CBasePlayer_Spawn()");
}
That way I know. Actually, I wished to call a hookchain only once and disable it. So, I wished if the hookchain id was in callback so there was no need of an extra variable.
Hey, I want to register a hookchain on plugin_init and after its first callback, I want to disable that hookchain. Now, since I'm using it for single time don't it good to register a variable for that. Is it possible that with some function I can get hookchain id in its callback ?