What I'm trying to do is register a private forward that accepts different functags.
For instance look at SDKHooks:
PHP Code:
funcenum SDKHookCB
{
...
// OnTakeDamagePost
public(victim, attacker, inflictor, Float:damage, damagetype),
public(victim, attacker, inflictor, Float:damage, damagetype, weapon, const Float:damageForce[3], const Float:damagePosition[3]),
...
}
This page tells me that
forwards are type-checked and that forward's parameter types must be known in advance, and if you push a mismatching type, the call will not complete.
In this scenario:
PHP Code:
public Native_HookForward(Handle:plugin, numParams)
{
AddToForward(g_Forward, plugin, Function:GetNativeCell(1)); // Here, check against a valid functag
}
How can I check the function's tag that I've passed to make sure I push the correct number of parameters in the forward call?
Suppose this is not possible, if I push more parameters than the function I've registered accepts, would it still work? Would it just ignore the extra params?
Example:
PHP Code:
enum MyHookType
{
MyHook_OnTick
}
funcenum MyHookCB
{
// OnTick
public(client),
public(client, tick)
}
// new Handle:g_hFwdOnTick[MAXPLAYERS+1];
// g_hFwdOnTick[client] = CreateForward(ET_Ignore, Param_Cell, Param_Cell);
public Native_MyHook(Handle:plugin, numParams)
{
new client = GetNativeCell(1);
// client checks here, throw native errors
new MyHookType:type = MyHookType:GetNativeCell(2);
switch (type)
{
case MyHook_OnTick:
{
AddToForward(g_hFwdOnTick[client], plugin, Function:GetNativeCell(3));
}
}
}
// native MyHook(client, MyHookType:type, MyHookCB:callback);