EDIT. Do not use the code below.
Some servers call round_start twice.
So I'll just leave the fix here in case somebody face with the same problem and don't want to call the trigger twice.
Code:
#pragma semicolon 1
#pragma newdecls required
float g_fConnectionTimeMin = 10.0;
float g_fConnectionTimeMax = 60.0;
float g_fConnectionTime;
public void OnPluginStart()
{
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
}
public Action Event_RoundStart(Event event, char[] name, bool dontBroadcast)
{
static float fTime = -0.1;
if (fTime < 0.0 || GetEngineTime() - fTime > 10.0)
{
g_fConnectionTime = g_fConnectionTimeMin;
CreateTimer(g_fConnectionTimeMin, Timer_CheckConnection, _, TIMER_FLAG_NO_MAPCHANGE);
}
fTime = GetEngineTime();
return Plugin_Continue;
}
public Action Timer_CheckConnection(Handle timer)
{
bool IsPlayerConnecting;
int i;
for (i = 1; i <= MaxClients; i++)
{
if (IsClientConnected(i) && !IsClientInGame(i))
{
IsPlayerConnecting = true;
break;
}
}
if (IsPlayerConnecting)
{
PrintToChatAll("[SM]: Waiting connecting players: %N", i);
if (g_fConnectionTime <= g_fConnectionTimeMax)
{
g_fConnectionTime += 5.0;
CreateTimer(5.0, Timer_CheckConnection, _, TIMER_FLAG_NO_MAPCHANGE);
}
else {
PrintToChatAll("[SM]: Timeout.");
OnAllClientsPostAdminCheck(); // timeout
}
}
else {
OnAllClientsPostAdminCheck();
}
}
void OnAllClientsPostAdminCheck()
{
PrintToChatAll("[SM]: Ready!");
}
__________________