Merge pull request #3 from rtldg/func_button-ondamage

set the activator for func_button OnDamage output
This commit is contained in:
Herman Simensen 2021-03-29 15:49:41 +02:00 committed by GitHub
commit d321cec549
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -151,6 +151,14 @@ public void OnClientDisconnect(int client)
}
}
public void OnEntityCreated(int entity, const char[] classname)
{
if (StrEqual(classname, "func_button"))
{
SDKHook(entity, SDKHook_OnTakeDamage, Hook_Button_OnTakeDamage);
}
}
void LoadDHooks()
{
GameData gamedataConf = LoadGameConfigFile("eventfix.games");
@ -344,6 +352,15 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
}
}
public Action Hook_Button_OnTakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype, int& weapon, float damageForce[3], float damagePosition[3], int damagecustom)
{
// func_button fires the OnDamage output before setting m_hActivator to the attacker.
// This means m_hActivator can be unset or a previous attacker.
// This is a problem at bhop_badges level 13 and also the booster in the ladder room.
SetEntPropEnt(victim, Prop_Data, "m_hActivator", attacker);
return Plugin_Continue;
}
public any Native_GetClientEvents(Handle plugin, int numParams)
{
int client = GetNativeCell(1);
@ -400,4 +417,4 @@ public any Native_ClearClientEvents(Handle plugin, int numParams)
g_aPlayerEvents[client].Clear();
return true;
}
}