Fixed spelling typo for HintTextMsg.
3 * Provides basic reserved slots.
4 * This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 public Plugin:myinfo =
29 name = "Reserved Slots",
30 author = "AlliedModders LLC",
31 description = "Provides basic reserved slots",
32 version = SOURCEMOD_VERSION,
33 url = "http://www.sourcemod.net/"
36 /* Maximum number of clients that can connect to server */
39 /* Handles to convars used by plugin */
40 new Handle:sm_reserved_slots;
41 new Handle:sm_hide_slots;
42 new Handle:sv_visiblemaxplayers;
44 public OnPluginStart()
46 LoadTranslations("reservedslots.phrases");
48 sm_reserved_slots = CreateConVar("sm_reserved_slots", "0", "Number of reserved player slots", 0, true, 0.0);
49 sm_hide_slots = CreateConVar("sm_hide_slots", "0", "If set to 1, reserved slots will hidden (subtracted from the max slot count)", 0, true, 0.0, true, 1.0);
50 sv_visiblemaxplayers = FindConVar("sv_visiblemaxplayers");
55 g_MaxClients = GetMaxClients();
58 public OnConfigsExecuted()
60 if (GetConVarBool(sm_hide_slots))
62 SetVisibleMaxSlots(GetClientCount(false), g_MaxClients - GetConVarInt(sm_reserved_slots));
66 public OnClientAuthorized(client, const String:auth[])
68 new reserved = GetConVarInt(sm_reserved_slots);
72 new clients = GetClientCount(false);
73 new limit = g_MaxClients - reserved;
74 new flags = GetUserFlagBits(client);
76 if (clients <= limit || IsFakeClient(client) || flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION)
78 if (GetConVarBool(sm_hide_slots))
80 SetVisibleMaxSlots(clients, limit);
86 /* Kick player because there are no public slots left */
87 KickClient(client, "%T", "Slot reserved", client);
91 public OnClientDisconnect_Post(client)
93 if (GetConVarBool(sm_hide_slots))
95 SetVisibleMaxSlots(GetClientCount(false), g_MaxClients - GetConVarInt(sm_reserved_slots));
99 SetVisibleMaxSlots(clients, limit)
101 new num = clients + 1;
103 if (clients == g_MaxClients)
106 } else if (clients < limit) {
110 SetConVarInt(sv_visiblemaxplayers, num);