zspawn and joinclass if afk for 1 minute and below mce_enable_map_cooldowns_player_count counted for real players
This commit is contained in:
parent
fefad5ce8a
commit
e74db611c4
@ -19,23 +19,40 @@ public void OnPluginStart()
|
|||||||
|
|
||||||
public Action CheckAfks(Handle timer)
|
public Action CheckAfks(Handle timer)
|
||||||
{
|
{
|
||||||
int real_players_cap = FindConVar("sm_exclude_specs_avghour").IntValue;
|
int real_players_cap = FindConVar("mce_enable_map_cooldowns_player_count").IntValue;
|
||||||
int real_players = 0;
|
int real_players = 0;
|
||||||
int real_spectator = 0;
|
|
||||||
for (int i = 0; i < MaxClients; i++)
|
for (int i = 0; i < MaxClients; i++)
|
||||||
{
|
{
|
||||||
if (IsValidClient(i) && !IsFakeClient(i) && !IsClientSourceTV(i))
|
if (IsValidClient(i) && !IsFakeClient(i) && !IsClientSourceTV(i))
|
||||||
{
|
{
|
||||||
real_players++;
|
real_players++;
|
||||||
if (GetClientTeam(i) <= CS_TEAM_SPECTATOR && GetClientIdleTime(i) > 600)
|
}
|
||||||
|
}
|
||||||
|
if (real_players < real_players_cap)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < MaxClients; i++)
|
||||||
|
{
|
||||||
|
if (IsValidClient(i) && !IsFakeClient(i) && !IsClientSourceTV(i) && GetClientTeam(i) <= CS_TEAM_SPECTATOR && GetClientIdleTime(i) > 60)
|
||||||
{
|
{
|
||||||
real_spectator = i;
|
ChangeClientTeam(i, CS_TEAM_T);
|
||||||
|
CreateTimer(1.0, zspawn, GetClientSerial(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (real_players < real_players_cap && real_spectator != 0)
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action zspawn(Handle hTimer, int Serial)
|
||||||
|
{
|
||||||
|
int client;
|
||||||
|
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||||
{
|
{
|
||||||
ChangeClientTeam(real_spectator, CS_TEAM_T);
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
if (IsValidClient(client))
|
||||||
|
{
|
||||||
|
FakeClientCommandEx(client, "joinclass");
|
||||||
|
FakeClientCommandEx(client, "say /zspawn");
|
||||||
}
|
}
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user