Try this:
PHP Code:
#include <sourcemod>
#include <sdkhooks>
#pragma newdecls required
public Plugin myinfo =
{
name = "Molotov Friendly Fire",
author = "Ilusion9",
description = "Enable only molotov damage for teammates and block everything else.",
version = "1.0",
url = "https://github.com/Ilusion9/"
};
bool g_IsPluginLoadedLate;
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
g_IsPluginLoadedLate = late;
}
public void OnPluginStart()
{
if (g_IsPluginLoadedLate)
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
{
OnClientPutInServer(i);
}
}
}
}
public void OnClientPutInServer(int client)
{
SDKHook(client, SDKHook_OnTakeDamage, SDK_OnTakeDamage);
SDKHook(client, SDKHook_TraceAttack, SDK_OnTraceAttack);
}
public Action SDK_OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3])
{
// inflictor is not a grenade, world damage or enemy team
if (inflictor <= MaxClients || !IsValidClient(attacker) || GetClientTeam(attacker) != GetClientTeam(victim))
{
return Plugin_Continue;
}
damage = 0.0;
damagetype |= DMG_PREVENT_PHYSICS_FORCE;
return Plugin_Changed;
}
public Action SDK_OnTraceAttack(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup)
{
// world damage or enemy team
if (!IsValidClient(attacker) || GetClientTeam(attacker) != GetClientTeam(victim))
{
return Plugin_Continue;
}
return Plugin_Handled;
}
bool IsValidClient(int client)
{
if (client < 1 || client > MaxClients || !IsClientInGame(client))
{
return false;
}
return true;
}
You can set the ff_ convars as you wish, but make sure the friendly fire is working
__________________