#pragma semicolon 1
#pragma newdecls required
#include <sdktools>
static const int iGrenadeOffset[] = {15, 17, 16, 14, 18, 17};
public void OnPluginStart()
{
HookEvent("player_team", Event_Check, EventHookMode_PostNoCopy);
HookEvent("player_death", Event_Check, EventHookMode_PostNoCopy);
}
public void Event_Check(Event event, const char[] name, bool dontBroadcast)
{
if(!CountAliveTs()) for(int i = 1; i <= MaxClients; i++) if(IsValidPlayer(i)) RemoveAllGrenades(i);
}
stock int CountAliveTs()
{
int num;
for(int i = 1; i <= MaxClients; i++) if(IsValidPlayer(i, 2)) num++;
return num;
}
stock bool IsValidPlayer(const int client, const int team = 3)
{
return IsClientInGame(client) && GetClientTeam(client) == team && IsPlayerAlive(client);
}
stock void RemoveAllGrenades(int client)
{
static int ent;
while(IsValidEdict((ent = GetPlayerWeaponSlot(client, 3))))
{
RemovePlayerItem(client, ent);
AcceptEntityInput(ent, "Kill");
}
for(int i; i < 6; i++) SetEntProp(client, Prop_Send, "m_iAmmo", 0, _, iGrenadeOffset[i]);
}