remove all those checks but mainly IsValidClient lol how insane is that function within a sdkhooks callback. A callback that wouldn't fire for some one not actually hooked... And guess what, you're hooking the client when they are put in the server... Something like this should work, and be immune.
PHP Code:
#pragma semicolon 1
#define PLUGIN_VERSION "1.1.0"
#include <sdkhooks>
#pragma newdecls required
public Plugin myinfo =
{
name = "TOG Bot Damage Immunity",
author = "That One Guy",
description = "Makes bot/replay clients immune to damage",
version = PLUGIN_VERSION,
url = "https://www.togcoding.com/togcoding/"
}
public void OnPluginStart()
{
CreateConVar("tbdi_version", PLUGIN_VERSION, "TOG Bot Damage Immunity - version number.", FCVAR_NOTIFY|FCVAR_DONTRECORD);
}
public void OnClientPutInServer(int client)
{
if (IsFakeClient(client) || IsClientReplay(client))
{
SDKHook(client, SDKHook_OnTakeDamage, Event_OnTakeDamage);
}
}
public void OnClientDisconnect(int client)
{
SDKUnhook(client, SDKHook_OnTakeDamage, Event_OnTakeDamage);
}
public Action Event_OnTakeDamage(int victim, int &attacker, int &inflictor, float &fDamage, int &damagetype, int &weapon, float a_fDmgForce[3], float a_fDmgPosition[3]/*, int damagecustom*/)
{
return Plugin_Stop;
}
m_takedamage 0 is a terrible solution since there are several plugins that modify that property.