I'm trying to create a script that will allow players to leech health under certain conditions and what I wrote does that just fine, only if you call the damage parameter it'll return some huge insane number that creates unstoppable juggernauts, not exactly my intentions. Is there any way to convert this into a normal usable number or am I missing something? Any help would be appreciated.
PHP Code:
public void OnClientPutInServer(int client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3], int damagecustom)
{
if (attacker <= 0 || attacker > MaxClients)
{
return Plugin_Continue;
}
int vHealth = GetClientHealth(attacker);
int color[4];
GetEntityRenderColor(attacker, color[0], color[1], color[2], color[3]);
PrintToChatAll("%N dealt %i damage.", attacker, damage);
if(attacker && color[0] == 210 && vitim != attacker)
{
if(TF2_GetPlayerClass(attacker) == TFClass_Heavy && vHealth < 300)
{
SetEntProp(attacker, Prop_Send, "m_iHealth", vHealth + damage, 1);
}
if(TF2_GetPlayerClass(attacker) == TFClass_Scout && vHealth < 150)
{
SetEntProp(attacker, Prop_Send, "m_iHealth", vHealth + damage, 1);
}
}
return Plugin_Continue;
}