1.1 --- a/plugins/reservedslots.sp Fri Nov 09 23:46:05 2007 +0000
1.2 +++ b/plugins/reservedslots.sp Sat Nov 10 02:00:04 2007 +0000
1.3 @@ -61,11 +61,25 @@
1.4 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);
1.5 sv_visiblemaxplayers = FindConVar("sv_visiblemaxplayers");
1.6 sm_reserve_type = CreateConVar("sm_reserve_type", "0", "Method of reserving slots", 0, true, 0.0, true, 1.0);
1.7 +
1.8 + HookConVarChange(sm_reserved_slots, SlotsChanged);
1.9 + HookConVarChange(sm_hide_slots, SlotsChanged);
1.10 +}
1.11 +
1.12 +public OnPluginEnd()
1.13 +{
1.14 + /* If the plugin has been unloaded, reset visiblemaxplayers. In the case of the server shutting down this effect will not be visible */
1.15 + SetConVarInt(sv_visiblemaxplayers, g_MaxClients);
1.16 }
1.17
1.18 public OnMapStart()
1.19 {
1.20 g_MaxClients = GetMaxClients();
1.21 +
1.22 + if (GetConVarBool(sm_hide_slots))
1.23 + {
1.24 + SetVisibleMaxSlots(GetClientCount(false), g_MaxClients - GetConVarInt(sm_reserved_slots));
1.25 + }
1.26 }
1.27
1.28 public OnConfigsExecuted()
1.29 @@ -115,6 +129,7 @@
1.30
1.31 if (target)
1.32 {
1.33 + /* Kick public player to free the reserved slot again */
1.34 CreateTimer(0.1, OnTimedKick, GetClientUserId(target));
1.35 }
1.36 }
1.37 @@ -135,6 +150,15 @@
1.38 }
1.39 }
1.40
1.41 +public SlotsChanged(Handle:convar, const String:oldValue[], const String:newValue[])
1.42 +{
1.43 + /* Reserved slots or hidden slots have been disabled - reset sv_visiblemaxplayers */
1.44 + if (StringToInt(newValue) == 0)
1.45 + {
1.46 + SetConVarInt(sv_visiblemaxplayers, g_MaxClients);
1.47 + }
1.48 +}
1.49 +
1.50 SetVisibleMaxSlots(clients, limit)
1.51 {
1.52 new num = clients + 1;