#include <amxmodx>
#include <reapi>
#if AMXX_VERSION_NUM < 183
new MaxClients;
#endif
// to /cstrike/sound
new const MUSIC_FILE[] = "lasthuman.wav"; // sound .wav
new bool: g_alreadyPlayed;
public plugin_precache()
{
precache_sound(MUSIC_FILE);
}
public plugin_init()
{
register_plugin("Last Players","0.2","alabamaster1337 & dev-cs");
register_event("HLTV", "HookEvent_Hltv", "a", "1=0", "2=0");
RegisterHookChain(RG_CBasePlayer_Killed, "HC_CBasePlayer_Killed_Post", true);
RegisterHookChain(RH_SV_DropClient, "HookDropClient", .post=true);
#if AMXX_VERSION_NUM < 183
MaxClients = get_maxplayers();
#endif
}
public HookEvent_Hltv()
g_alreadyPlayed = false;
public HookDropClient() {
if (!g_alreadyPlayed)
check_last_players();
}
// amx-x.ru
public HC_CBasePlayer_Killed_Post() {
if (!g_alreadyPlayed)
check_last_players();
}
public check_last_players() {
new players[TeamName], playerId[TeamName];
for (new id = 1; id <= MaxClients; id++)
{
if (is_user_alive(id) && (TEAM_UNASSIGNED < get_member(id, m_iTeam) < TEAM_SPECTATOR))
{
players[get_member(id, m_iTeam)]++;
playerId[get_member(id, m_iTeam)] = id;
}
}
if (players[TEAM_CT] == 1)
rg_send_audio(playerId[TEAM_CT], MUSIC_FILE);
if (players[TEAM_TERRORIST] == 1)
rg_send_audio(playerId[TEAM_TERRORIST], MUSIC_FILE);
g_alreadyPlayed = bool:(players[TEAM_CT] || players[TEAM_TERRORIST]);
}
}