Added amb1623 - More reserved slots kick types.

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402092
This commit is contained in:
Matt Woodrow 2008-04-22 22:50:27 +00:00
parent d0286c1391
commit 47f8d0eef5

View File

@ -55,6 +55,14 @@ new Handle:sm_hide_slots;
new Handle:sv_visiblemaxplayers; new Handle:sv_visiblemaxplayers;
new Handle:sm_reserve_type; new Handle:sm_reserve_type;
new Handle:sm_reserve_maxadmins; new Handle:sm_reserve_maxadmins;
new Handle:sm_reserve_kicktype;
enum KickType
{
Kick_HighestPing,
Kick_HighestTime,
Kick_Random,
};
public OnPluginStart() public OnPluginStart()
{ {
@ -65,6 +73,7 @@ public OnPluginStart()
sv_visiblemaxplayers = FindConVar("sv_visiblemaxplayers"); sv_visiblemaxplayers = FindConVar("sv_visiblemaxplayers");
sm_reserve_type = CreateConVar("sm_reserve_type", "0", "Method of reserving slots", 0, true, 0.0, true, 2.0); sm_reserve_type = CreateConVar("sm_reserve_type", "0", "Method of reserving slots", 0, true, 0.0, true, 2.0);
sm_reserve_maxadmins = CreateConVar("sm_reserve_maxadmins", "1", "Maximum amount of admins to let in the server with reserve type 2", 0, true, 0.0); sm_reserve_maxadmins = CreateConVar("sm_reserve_maxadmins", "1", "Maximum amount of admins to let in the server with reserve type 2", 0, true, 0.0);
sm_reserve_kicktype = CreateConVar("sm_reserve_kicktype", "0", "How to select a client to kick (if appropriate)", 0, true, 0.0, true, 2.0);
HookConVarChange(sm_reserved_slots, SlotsChanged); HookConVarChange(sm_reserved_slots, SlotsChanged);
HookConVarChange(sm_hide_slots, SlotsChanged); HookConVarChange(sm_hide_slots, SlotsChanged);
@ -230,15 +239,17 @@ SetVisibleMaxSlots(clients, limit)
SelectKickClient() SelectKickClient()
{ {
new Float:highestLatency; new KickType:type = KickType:GetConVarInt(sm_reserve_kicktype);
new highestLatencyId;
new Float:highestSpecLatency; new Float:highestValue;
new highestSpecLatencyId; new highestValueId;
new Float:highestSpecValue;
new highestSpecValueId;
new bool:specFound; new bool:specFound;
new Float:latency; new Float:value;
for (new i=1; i<=g_MaxClients; i++) for (new i=1; i<=g_MaxClients; i++)
{ {
@ -254,37 +265,46 @@ SelectKickClient()
continue; continue;
} }
latency = 0.0; value = 0.0;
if (IsClientInGame(i)) if (IsClientInGame(i))
{ {
latency = GetClientAvgLatency(i, NetFlow_Outgoing); if (type == Kick_HighestPing)
{
LogMessage("Latency : %f",latency); value = GetClientAvgLatency(i, NetFlow_Outgoing);
}
else if (type == Kick_HighestTime)
{
value = GetClientTime(i);
}
else
{
value = GetRandomFloat(0.0, 100.0);
}
if (IsClientObserver(i)) if (IsClientObserver(i))
{ {
specFound = true; specFound = true;
if (latency > highestSpecLatency) if (value > highestSpecValue)
{ {
highestSpecLatency = latency; highestSpecValue = value;
highestSpecLatencyId = i; highestSpecValueId = i;
} }
} }
} }
if (latency >= highestLatency) if (value >= highestValue)
{ {
highestLatency = latency; highestValue = value;
highestLatencyId = i; highestValueId = i;
} }
} }
if (specFound) if (specFound)
{ {
return highestSpecLatencyId; return highestSpecValueId;
} }
return highestLatencyId; return highestValueId;
} }