Port reservedslots.
This commit is contained in:
		
							parent
							
								
									65dfd3cdd1
								
							
						
					
					
						commit
						16330d1c4c
					
				| @ -48,12 +48,12 @@ new g_adminCount = 0; | |||||||
| new bool:g_isAdmin[MAXPLAYERS+1]; | new bool:g_isAdmin[MAXPLAYERS+1]; | ||||||
| 
 | 
 | ||||||
| /* Handles to convars used by plugin */ | /* Handles to convars used by plugin */ | ||||||
| new Handle:sm_reserved_slots; | ConVar sm_reserved_slots; | ||||||
| new Handle:sm_hide_slots; | ConVar sm_hide_slots; | ||||||
| new Handle:sv_visiblemaxplayers; | ConVar sv_visiblemaxplayers; | ||||||
| new Handle:sm_reserve_type; | ConVar sm_reserve_type; | ||||||
| new Handle:sm_reserve_maxadmins; | ConVar sm_reserve_maxadmins; | ||||||
| new Handle:sm_reserve_kicktype; | ConVar sm_reserve_kicktype; | ||||||
| 
 | 
 | ||||||
| enum KickType | enum KickType | ||||||
| { | { | ||||||
| @ -73,8 +73,8 @@ public OnPluginStart() | |||||||
| 	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); | 	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); | ||||||
| 	sm_reserve_kicktype = CreateConVar("sm_reserve_kicktype", "0", "How to select a client to kick (if appropriate)", 0, true, 0.0, true, 2.0); | 	sm_reserve_kicktype = CreateConVar("sm_reserve_kicktype", "0", "How to select a client to kick (if appropriate)", 0, true, 0.0, true, 2.0); | ||||||
| 	 | 	 | ||||||
| 	HookConVarChange(sm_reserved_slots, SlotCountChanged); | 	sm_reserved_slots.AddChangeHook(SlotCountChanged); | ||||||
| 	HookConVarChange(sm_hide_slots, SlotHideChanged); | 	sm_hide_slots.AddChangeHook(SlotHideChanged); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| public OnPluginEnd() | public OnPluginEnd() | ||||||
| @ -85,17 +85,17 @@ public OnPluginEnd() | |||||||
| 
 | 
 | ||||||
| public OnMapStart() | public OnMapStart() | ||||||
| { | { | ||||||
| 	if (GetConVarBool(sm_hide_slots)) | 	if (sm_hide_slots.BoolValue) | ||||||
| 	{ | 	{ | ||||||
| 		SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - GetConVarInt(sm_reserved_slots)); | 		SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - sm_reserved_slots.IntValue); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| public OnConfigsExecuted() | public OnConfigsExecuted() | ||||||
| { | { | ||||||
| 	if (GetConVarBool(sm_hide_slots)) | 	if (sm_hide_slots.BoolValue) | ||||||
| 	{ | 	{ | ||||||
| 		SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - GetConVarInt(sm_reserved_slots)); | 		SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - sm_reserved_slots.IntValue); | ||||||
| 	}	 | 	}	 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -108,9 +108,9 @@ public Action:OnTimedKick(Handle:timer, any:client) | |||||||
| 	 | 	 | ||||||
| 	KickClient(client, "%T", "Slot reserved", client); | 	KickClient(client, "%T", "Slot reserved", client); | ||||||
| 	 | 	 | ||||||
| 	if (GetConVarBool(sm_hide_slots)) | 	if (sm_hide_slots.BoolValue) | ||||||
| 	{				 | 	{				 | ||||||
| 		SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - GetConVarInt(sm_reserved_slots)); | 		SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - sm_reserved_slots.IntValue); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	return Plugin_Handled; | 	return Plugin_Handled; | ||||||
| @ -118,7 +118,7 @@ public Action:OnTimedKick(Handle:timer, any:client) | |||||||
| 
 | 
 | ||||||
| public OnClientPostAdminCheck(client) | public OnClientPostAdminCheck(client) | ||||||
| { | { | ||||||
| 	new reserved = GetConVarInt(sm_reserved_slots); | 	new reserved = sm_reserved_slots.IntValue; | ||||||
| 
 | 
 | ||||||
| 	if (reserved > 0) | 	if (reserved > 0) | ||||||
| 	{ | 	{ | ||||||
| @ -126,13 +126,13 @@ public OnClientPostAdminCheck(client) | |||||||
| 		new limit = GetMaxHumanPlayers() - reserved; | 		new limit = GetMaxHumanPlayers() - reserved; | ||||||
| 		new flags = GetUserFlagBits(client); | 		new flags = GetUserFlagBits(client); | ||||||
| 		 | 		 | ||||||
| 		new type = GetConVarInt(sm_reserve_type); | 		new type = sm_reserve_type.IntValue; | ||||||
| 		 | 		 | ||||||
| 		if (type == 0) | 		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 (sm_hide_slots.BoolValue) | ||||||
| 				{ | 				{ | ||||||
| 					SetVisibleMaxSlots(clients, limit); | 					SetVisibleMaxSlots(clients, limit); | ||||||
| 				} | 				} | ||||||
| @ -172,7 +172,7 @@ public OnClientPostAdminCheck(client) | |||||||
| 				g_isAdmin[client] = true; | 				g_isAdmin[client] = true; | ||||||
| 			} | 			} | ||||||
| 			 | 			 | ||||||
| 			if (clients > limit && g_adminCount < GetConVarInt(sm_reserve_maxadmins)) | 			if (clients > limit && g_adminCount < sm_reserve_maxadmins.IntValue) | ||||||
| 			{ | 			{ | ||||||
| 				/* Server is full, reserved slots aren't and client doesn't have reserved slots access */ | 				/* Server is full, reserved slots aren't and client doesn't have reserved slots access */ | ||||||
| 				 | 				 | ||||||
| @ -198,9 +198,9 @@ public OnClientPostAdminCheck(client) | |||||||
| 
 | 
 | ||||||
| public OnClientDisconnect_Post(client) | public OnClientDisconnect_Post(client) | ||||||
| { | { | ||||||
| 	if (GetConVarBool(sm_hide_slots)) | 	if (sm_hide_slots.BoolValue) | ||||||
| 	{		 | 	{		 | ||||||
| 		SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - GetConVarInt(sm_reserved_slots)); | 		SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - sm_reserved_slots.IntValue); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	if (g_isAdmin[client]) | 	if (g_isAdmin[client]) | ||||||
| @ -210,30 +210,30 @@ public OnClientDisconnect_Post(client) | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| public SlotCountChanged(Handle:convar, const String:oldValue[], const String:newValue[]) | public SlotCountChanged(ConVar convar, const String:oldValue[], const String:newValue[]) | ||||||
| { | { | ||||||
| 	/* Reserved slots or hidden slots have been disabled - reset sv_visiblemaxplayers */ | 	/* Reserved slots or hidden slots have been disabled - reset sv_visiblemaxplayers */ | ||||||
| 	new slotcount = GetConVarInt(convar); | 	new slotcount = convar.IntValue; | ||||||
| 	if (slotcount == 0) | 	if (slotcount == 0) | ||||||
| 	{ | 	{ | ||||||
| 		ResetVisibleMax(); | 		ResetVisibleMax(); | ||||||
| 	} | 	} | ||||||
| 	else if (GetConVarBool(sm_hide_slots)) | 	else if (sm_hide_slots.BoolValue) | ||||||
| 	{ | 	{ | ||||||
| 		SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - slotcount); | 		SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - slotcount); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| public SlotHideChanged(Handle:convar, const String:oldValue[], const String:newValue[]) | public SlotHideChanged(ConVar convar, const String:oldValue[], const String:newValue[]) | ||||||
| { | { | ||||||
| 	/* Reserved slots or hidden slots have been disabled - reset sv_visiblemaxplayers */ | 	/* Reserved slots or hidden slots have been disabled - reset sv_visiblemaxplayers */ | ||||||
| 	if (!GetConVarBool(convar)) | 	if (!convar.BoolValue) | ||||||
| 	{ | 	{ | ||||||
| 		ResetVisibleMax(); | 		ResetVisibleMax(); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - GetConVarInt(sm_reserved_slots)); | 		SetVisibleMaxSlots(GetClientCount(false), GetMaxHumanPlayers() - sm_reserved_slots.IntValue); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -248,17 +248,17 @@ SetVisibleMaxSlots(clients, limit) | |||||||
| 		num = limit; | 		num = limit; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	SetConVarInt(sv_visiblemaxplayers, num); | 	sv_visiblemaxplayers.IntValue = num; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ResetVisibleMax() | ResetVisibleMax() | ||||||
| { | { | ||||||
| 	SetConVarInt(sv_visiblemaxplayers, -1); | 	sv_visiblemaxplayers.IntValue = -1; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| SelectKickClient() | SelectKickClient() | ||||||
| { | { | ||||||
| 	new KickType:type = KickType:GetConVarInt(sm_reserve_kicktype); | 	new KickType:type = KickType:sm_reserve_kicktype.IntValue; | ||||||
| 	 | 	 | ||||||
| 	new Float:highestValue; | 	new Float:highestValue; | ||||||
| 	new highestValueId; | 	new highestValueId; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user