Quote:
Originally Posted by 8guawong
b/c you are hooking client so the client will never be tank_boss
try
PHP Code:
new ent = -1; while ((ent = FindEntityByClassname(ent, "tank_boss")) != -1) { SDKHook(ent, SDKHook_OnTakeDamage, OnPropTakeDamage); }
|
Thanks ! it worked, but is there another method to hook this thing without using OnEntityCreated ?
Here is what I did :
PHP Code:
public void OnEntityCreated(int entity, const char[] classname)
{
int iEnt = -1;
while((iEnt = FindEntityByClassname(iEnt, "tank_boss")) != -1)
{
SDKHook(iEnt, SDKHook_OnTakeDamage, OnPropTakeDamage);
}
}
public Action OnPropTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
int iEnt = -1;
iEnt = FindEntityByClassname(iEnt, "tank_boss");
if(iEnt == victim)
{
damage *= 2.0;
return Plugin_Changed;
}
return Plugin_Changed;
}
And here is what happens with this code (look the dmg I've done)
I noticed something about that :
PHP Code:
public Action OnPropTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
int iEnt = -1;
iEnt = FindEntityByClassname(iEnt, "tank_boss");
if(iEnt == victim)
{
PrintToChatAll("%N attacked the tank", attacker);
return Plugin_Changed;
}
return Plugin_Changed;
}
with this code, for some reason it print 10 times the "Square attacked the tank" so maybe it has something with the damage I did
Oh and if you do that :
PHP Code:
public Action OnPropTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
int iEnt = -1;
iEnt = FindEntityByClassname(iEnt, "tank_boss");
if(iEnt == victim)
{
SetVariantInt(9999);
AcceptEntityInput(iEnt, "RemoveHealth");
}
return Plugin_Changed;
}
You lose you ears
__________________