From 726aa68be9c8aaaf4c46bb293e3ea91a66fed868 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Wed, 16 Apr 2008 07:35:52 +0000 Subject: [PATCH] added amb1181 - New reserve slot type --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402067 --- plugins/reservedslots.sp | 45 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/plugins/reservedslots.sp b/plugins/reservedslots.sp index efdf1e98..d0c97703 100644 --- a/plugins/reservedslots.sp +++ b/plugins/reservedslots.sp @@ -46,12 +46,15 @@ public Plugin:myinfo = /* Maximum number of clients that can connect to server */ new g_MaxClients; +new g_adminCount = 0; +new bool:g_isAdmin[MAXPLAYERS+1]; /* Handles to convars used by plugin */ new Handle:sm_reserved_slots; new Handle:sm_hide_slots; new Handle:sv_visiblemaxplayers; new Handle:sm_reserve_type; +new Handle:sm_reserve_maxadmins; public OnPluginStart() { @@ -60,7 +63,8 @@ public OnPluginStart() sm_reserved_slots = CreateConVar("sm_reserved_slots", "0", "Number of reserved player slots", 0, true, 0.0); 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); sv_visiblemaxplayers = FindConVar("sv_visiblemaxplayers"); - sm_reserve_type = CreateConVar("sm_reserve_type", "0", "Method of reserving slots", 0, true, 0.0, true, 1.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); HookConVarChange(sm_reserved_slots, SlotsChanged); HookConVarChange(sm_hide_slots, SlotsChanged); @@ -134,8 +138,8 @@ public OnClientPostAdminCheck(client) /* Kick player because there are no public slots left */ CreateTimer(0.1, OnTimedKick, client); } - else - { + else if (type == 1) + { if (clients > limit) { if (flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION) @@ -155,6 +159,35 @@ public OnClientPostAdminCheck(client) } } } + else if (type == 2) + { + if (flags & ADMFLAG_ROOT || flags & ADMFLAG_RESERVATION) + { + g_adminCount++; + g_isAdmin[client] = true; + } + + if (clients > limit && g_adminCount < GetConVarInt(sm_reserve_maxadmins)) + { + /* Server is full, reserved slots aren't and client doesn't have reserved slots access */ + + if (g_isAdmin[client]) + { + new target = SelectKickClient(); + + 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); + } + } + } } } @@ -164,6 +197,12 @@ public OnClientDisconnect_Post(client) { SetVisibleMaxSlots(GetClientCount(false), g_MaxClients - GetConVarInt(sm_reserved_slots)); } + + if (g_isAdmin[client]) + { + g_adminCount--; + g_isAdmin[client] = false; + } } public SlotsChanged(Handle:convar, const String:oldValue[], const String:newValue[])