Hi guys, this plugin count players in L4D2, when they die, when they revive, it just let you how many left
The issue is when a game of, for example, 4 players someone become afk, it tells u that there is 5 survivors left, yet its only 4 survivors there
can someone point the issue
thanks
PHP Code:
#include <sourcemod>
#include <sdktools>
public Plugin:myinfo =
{
name = "Survivors_Counter",
author = "",
description = "Announce Survivors Number",
version = "1.0",
url = ""
}
public OnPluginStart()
{
HookEvent( "player_spawn", EVENT_PlayerSpawn );
HookEvent( "player_death", EVENT_PlayerDeath );
}
public EVENT_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId( GetEventInt( event, "userid" ));
if ( IsTeamSurvivor( client ))
{
new counT = CountSurvivor();
if ( counT > 0 )
{
PrintHintTextToAll( "%N Has Spawned\nAlive: %d", client, counT );
}
}
}
public EVENT_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId( GetEventInt( event, "userid" ));
if ( IsTeamSurvivor( client ))
{
new counT = CountSurvivor();
if ( counT > 0 )
{
PrintHintTextToAll( "%N Has Died\nLeft: %d", client, counT );
}
}
}
CountSurvivor()
{
new survivoR = 0;
for ( new i = 1; i <= MaxClients; i++ )
{
if ( IsTeamSurvivor( i ) && IsPlayerAlive( i ))
{
survivoR++;
}
}
return survivoR;
}
stock bool:IsTeamSurvivor( client )
{
if ( client < 1 || client > MaxClients ) return false;
if ( !IsClientConnected( client )) return false;
if ( !IsClientInGame( client )) return false;
if ( GetClientTeam( client ) != 2 ) return false;
return true;
}