Fixed amb1154 and another kick bug with sm_reserve_type 1

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401682
This commit is contained in:
Matt Woodrow 2007-11-12 21:51:54 +00:00
parent 9284a90d41
commit 7063d310d3

View File

@ -90,10 +90,8 @@ public OnConfigsExecuted()
} }
} }
public Action:OnTimedKick(Handle:timer, any:value) public Action:OnTimedKick(Handle:timer, any:client)
{ {
new client = GetClientOfUserId(value);
if (!client || !IsClientInGame(client)) if (!client || !IsClientInGame(client))
{ {
return Plugin_Handled; return Plugin_Handled;
@ -101,6 +99,8 @@ public Action:OnTimedKick(Handle:timer, any:value)
KickClient(client, "%T", "Slot reserved", client); KickClient(client, "%T", "Slot reserved", client);
SetVisibleMaxSlots(GetClientCount(false), g_MaxClients - GetConVarInt(sm_reserved_slots));
return Plugin_Handled; return Plugin_Handled;
} }
@ -113,32 +113,45 @@ public OnClientPostAdminCheck(client)
new clients = GetClientCount(false); new clients = GetClientCount(false);
new limit = g_MaxClients - reserved; new limit = g_MaxClients - reserved;
new flags = GetUserFlagBits(client); new flags = GetUserFlagBits(client);
if (clients <= limit || IsFakeClient(client) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION) new type = GetConVarInt(sm_reserve_type);
if (type == 0)
{ {
if (GetConVarBool(sm_hide_slots)) if (clients <= limit || IsFakeClient(client) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
{ {
SetVisibleMaxSlots(clients, limit); if (GetConVarBool(sm_hide_slots))
{
SetVisibleMaxSlots(clients, limit);
}
return;
} }
new type = GetConVarInt(sm_reserve_type); /* Kick player because there are no public slots left */
CreateTimer(0.1, OnTimedKick, client);
if (type == 1) }
{ else
new target = SelectKickClient(); {
if (clients > limit)
if (target) {
if (flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
{ {
/* Kick public player to free the reserved slot again */ new target = SelectKickClient();
CreateTimer(0.1, OnTimedKick, GetClientUserId(target));
if (target)
{
/* Kick public player to free the reserved slot again */
CreateTimer(0.1, OnTimedKick, target);
}
}
else
{
/* Kick player because there are no public slots left */
CreateTimer(0.1, OnTimedKick, client);
} }
} }
return;
} }
/* Kick player because there are no public slots left */
CreateTimer(0.1, OnTimedKick, GetClientUserId(client));
} }
} }
@ -161,7 +174,7 @@ public SlotsChanged(Handle:convar, const String:oldValue[], const String:newValu
SetVisibleMaxSlots(clients, limit) SetVisibleMaxSlots(clients, limit)
{ {
new num = clients + 1; new num = clients;
if (clients == g_MaxClients) if (clients == g_MaxClients)
{ {
@ -186,7 +199,7 @@ SelectKickClient()
new Float:latency; new Float:latency;
for (new i=1; i<=g_MaxClients; i++) for (new i=1; i<=g_MaxClients; i++)
{ {
if (!IsClientConnected(i)) if (!IsClientConnected(i))
{ {
continue; continue;
@ -198,13 +211,17 @@ SelectKickClient()
{ {
continue; continue;
} }
latency = 0.0;
if (IsClientInGame(i)) if (IsClientInGame(i))
{ {
latency = GetClientAvgLatency(i, NetFlow_Both); latency = GetClientAvgLatency(i, NetFlow_Outgoing);
LogMessage("Latency : %f",latency);
if (IsClientObserver(i)) if (IsClientObserver(i))
{ {
specFound = true; specFound = true;
if (latency > highestSpecLatency) if (latency > highestSpecLatency)
@ -214,12 +231,8 @@ SelectKickClient()
} }
} }
} }
else
{
latency = 0.0;
}
if (latency > highestLatency) if (latency >= highestLatency)
{ {
highestLatency = latency; highestLatency = latency;
highestLatencyId = i; highestLatencyId = i;