added amb1181 - New reserve slot type
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402067
This commit is contained in:
parent
16bdac4635
commit
726aa68be9
@ -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[])
|
||||
|
Loading…
Reference in New Issue
Block a user