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;
} }
@ -114,6 +114,10 @@ public OnClientPostAdminCheck(client)
new limit = g_MaxClients - reserved; new limit = g_MaxClients - reserved;
new flags = GetUserFlagBits(client); new flags = GetUserFlagBits(client);
new type = GetConVarInt(sm_reserve_type);
if (type == 0)
{
if (clients <= limit || IsFakeClient(client) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION) if (clients <= limit || IsFakeClient(client) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
{ {
if (GetConVarBool(sm_hide_slots)) if (GetConVarBool(sm_hide_slots))
@ -121,24 +125,33 @@ public OnClientPostAdminCheck(client)
SetVisibleMaxSlots(clients, limit); SetVisibleMaxSlots(clients, limit);
} }
new type = GetConVarInt(sm_reserve_type); return;
}
if (type == 1) /* Kick player because there are no public slots left */
CreateTimer(0.1, OnTimedKick, client);
}
else
{
if (clients > limit)
{
if (flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
{ {
new target = SelectKickClient(); new target = SelectKickClient();
if (target) if (target)
{ {
/* Kick public player to free the reserved slot again */ /* Kick public player to free the reserved slot again */
CreateTimer(0.1, OnTimedKick, GetClientUserId(target)); CreateTimer(0.1, OnTimedKick, target);
} }
} }
else
return; {
}
/* Kick player because there are no public slots left */ /* Kick player because there are no public slots left */
CreateTimer(0.1, OnTimedKick, GetClientUserId(client)); CreateTimer(0.1, OnTimedKick, 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)
{ {
@ -199,9 +212,13 @@ 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))
{ {
@ -214,12 +231,8 @@ SelectKickClient()
} }
} }
} }
else
{
latency = 0.0;
}
if (latency > highestLatency) if (latency >= highestLatency)
{ {
highestLatency = latency; highestLatency = latency;
highestLatencyId = i; highestLatencyId = i;