here simple code.
required sdkhooks
PHP Code:
#include <sdkhooks>
new Handle:mp_friendlyfire = INVALID_HANDLE;
new bool:friendlyfire = false;
public OnPluginStart()
{
if((mp_friendlyfire = FindConVar("mp_friendlyfire")) == INVALID_HANDLE)
{
SetFailState("Missing mp_friendlyfire");
}
HookConVarChange(mp_friendlyfire, convar_changed);
// Plugin loaded during game...
if((friendlyfire = GetConVarBool(mp_friendlyfire)))
{
convar_changed(mp_friendlyfire, "0", "1");
}
}
public convar_changed(Handle:convar, const String:oldValue[], const String:newValue[])
{
if(convar == mp_friendlyfire)
{
decl bool:oldv;
oldv = StringToInt(oldValue) != 0;
if((friendlyfire = GetConVarBool(mp_friendlyfire)) != oldv)
{
if(friendlyfire)
{
for(new i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i))
{
OnClientPutInServer(i);
}
}
}
else
{
for(new i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i))
{
SDKUnhook(i, SDKHook_OnTakeDamage, OnTakeDamage);
}
}
}
}
}
}
public OnClientPutInServer(client)
{
friendlyfire ? SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage):0;
}
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
if(victim != attacker)
{
decl String:clsname[30];
GetEntityClassname(inflictor, clsname, sizeof(clsname));
if(StrEqual(clsname, "hegrenade_projectile", false))
{
if(GetClientTeam(victim) == GetClientTeam(attacker))
{
return Plugin_Handled;
}
}
}
return Plugin_Continue;
}
*edit
updated, try that code dam, lame code...
*edit, better one...
__________________