This is for CSGO correct?
Edit:
If it is for CSGO you can try this
PHP Code:
#pragma semicolon 1
#define DEBUG
#define PLUGIN_AUTHOR "hAlexrr"
#define PLUGIN_VERSION "1.0"
#include <sourcemod>
#include <sdktools>
#include <emitsoundany>
#include <cstrike>
#pragma newdecls required
ConVar sm_players_alive_clutch;
Handle g_hTimer;
int g_iTeamT;
int g_iTeamCT;
int g_iOpponents;
bool g_bInClutch;
public Plugin myinfo =
{
name = "Player Clutched",
author = PLUGIN_AUTHOR,
description = "Gives an announcement when a player clutches the round",
version = PLUGIN_VERSION,
url = "NUN"
};
public void OnPluginStart()
{
sm_players_alive_clutch = CreateConVar("sm_players_alive_clutch", "3", "The amount of players needed to be alive on the opposite team for it to be considered a clutch");
HookEvent("round_end", Event_RoundEnd);
}
public void OnMapStart()
{
//// Vortex - https://forums.alliedmods.net/showthread.php?t=299964
PrecacheSoundAny("weapons/party_horn_01.wav"); // End
if(g_hTimer == INVALID_HANDLE)
g_hTimer = CreateTimer(0.5, getAlivePlayers, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}
public Action getAlivePlayers(Handle timer)
{
int CT, T;
for (int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i))
{
if(GetClientTeam(i) == CS_TEAM_CT)
CT++;
else if(GetClientTeam(i) == CS_TEAM_T)
T++;
}
}
g_iTeamCT = CT;
g_iTeamT = T;
if(g_iTeamT == 1 && g_iTeamCT >= sm_players_alive_clutch.IntValue && !g_bInClutch)
{
g_bInClutch = true;
g_iOpponents = g_iTeamCT;
} else if(g_iTeamCT == 1 && g_iTeamT >= sm_players_alive_clutch.IntValue && !g_bInClutch)
{
g_bInClutch = true;
g_iOpponents = g_iTeamT;
}
}
public Action Event_RoundEnd(Event event, char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if(g_bInClutch && g_iOpponents >= sm_players_alive_clutch.IntValue)
{
PrintToChatAll("[\x06NOTIFY\x01] Player %N has clutched a 1v%i", g_iOpponents);
CreateParticle(client, "weapon_confetti_balloons", 5.0);
g_bInClutch = false;
g_iTeamCT = 0;
g_iTeamT = 0;
g_iOpponents = 0;
}
}
// Vortex - https://forums.alliedmods.net/showthread.php?t=299964
stock void CreateParticle(int ent, char[] particleType, float time)
{
int particle = CreateEntityByName("info_particle_system");
char name[64];
if (IsValidEdict(particle))
{
float position[3];
GetEntPropVector(ent, Prop_Send, "m_vecOrigin", position);
TeleportEntity(particle, position, NULL_VECTOR, NULL_VECTOR);
GetEntPropString(ent, Prop_Data, "m_iName", name, sizeof(name));
DispatchKeyValue(particle, "targetname", "tf2particle");
DispatchKeyValue(particle, "parentname", name);
DispatchKeyValue(particle, "effect_name", particleType);
DispatchSpawn(particle);
SetVariantString(name);
AcceptEntityInput(particle, "SetParent", particle, particle, 0);
ActivateEntity(particle);
AcceptEntityInput(particle, "start");
CreateTimer(time, DeleteParticle, particle);
}
EmitSoundToAllAny("weapons/party_horn_01.wav");
}
public Action DeleteParticle(Handle timer, any particle)
{
if (IsValidEntity(particle))
{
char classN[64];
GetEdictClassname(particle, classN, sizeof(classN));
if (StrEqual(classN, "info_particle_system", false))
{
RemoveEdict(particle);
}
}
} // End
I have not testing it BTW