ReservedSlots: give non-donators a chance to join a team before getting kicked

This commit is contained in:
hubdom 2020-12-27 21:56:23 +01:00
parent 1fd1248528
commit cf1299454a

View File

@ -156,8 +156,8 @@ public void AsyncHasSteamIDReservedSlotCallback(const char[] sSteam32ID, int Res
stock bool KickValidClient(const char[] sName, const char[] sSteam32ID, AdminId admin, int Immunity) stock bool KickValidClient(const char[] sName, const char[] sSteam32ID, AdminId admin, int Immunity)
{ {
int HighestValue[3] = {-1, ...}; int HighestValue[4] = {-1, ...};
int HighestValueClient[3] = {0, ...}; int HighestValueClient[4] = {0, ...};
for(int client = 1; client <= MaxClients; client++) for(int client = 1; client <= MaxClients; client++)
{ {
@ -180,11 +180,11 @@ stock bool KickValidClient(const char[] sName, const char[] sSteam32ID, AdminId
#endif #endif
/* Spectators /* Spectators
* Sort by idle time and also kick donators if IdleTime > 30 * Sort by idle time and kick non-donators if IdleTime > 10
*/ */
if(GetClientTeam(client) <= CS_TEAM_SPECTATOR) if(GetClientTeam(client) <= CS_TEAM_SPECTATOR)
{ {
if(!Donator || IdleTime > 30) if(!Donator && IdleTime > 10)
{ {
if(IdleTime > HighestValue[0]) if(IdleTime > HighestValue[0])
{ {
@ -193,6 +193,20 @@ stock bool KickValidClient(const char[] sName, const char[] sSteam32ID, AdminId
} }
} }
} }
/* Spectators
* Sort by idle time and also kick donators if IdleTime > 30
*/
if(GetClientTeam(client) <= CS_TEAM_SPECTATOR)
{
if(Donator && IdleTime > 30)
{
if(IdleTime > HighestValue[0])
{
HighestValue[1] = IdleTime;
HighestValueClient[1] = client;
}
}
}
/* Spectators */ /* Spectators */
/* Dead non-donator with IdleTime > 30 /* Dead non-donator with IdleTime > 30
@ -202,8 +216,8 @@ stock bool KickValidClient(const char[] sName, const char[] sSteam32ID, AdminId
{ {
if(IdleTime > 30 && IdleTime > HighestValue[1]) if(IdleTime > 30 && IdleTime > HighestValue[1])
{ {
HighestValue[1] = IdleTime; HighestValue[2] = IdleTime;
HighestValueClient[1] = client; HighestValueClient[2] = client;
} }
} }
/* Dead non-donator with IdleTime > 30 */ /* Dead non-donator with IdleTime > 30 */
@ -215,8 +229,8 @@ stock bool KickValidClient(const char[] sName, const char[] sSteam32ID, AdminId
{ {
if(IdleTime > 30 && IdleTime > HighestValue[2]) if(IdleTime > 30 && IdleTime > HighestValue[2])
{ {
HighestValue[2] = IdleTime; HighestValue[3] = IdleTime;
HighestValueClient[2] = client; HighestValueClient[3] = client;
} }
} }
/* Alive non-donator with IdleTime > 30 */ /* Alive non-donator with IdleTime > 30 */