renamed variable for skipping all restrictions on low pop and now also made it skip cooldowns as well as adding a new variable that decides how many players are required before applying cooldowns at all. also changed player counting not consider fakes, autism bots, afks and spec anymore to make it a lot simpler to understand.
This commit is contained in:
parent
6790e463fc
commit
ef537b8826
@ -53,7 +53,6 @@
|
||||
#include <multicolors>
|
||||
#include <nominations_extended>
|
||||
#include <rockthevote_extended>
|
||||
#include <AFKManager>
|
||||
#include <leader>
|
||||
|
||||
#pragma semicolon 1
|
||||
@ -142,9 +141,10 @@ bool g_HasIntermissionStarted = false;
|
||||
bool g_RtvInitiated = false;
|
||||
int g_iNextmapState = 0; //0 = nothing. 1 = rtv succesfull. 2 = admin used setnextmap. 3 = did not extend or used all extends. 4 = vote at end of map is going on.
|
||||
int g_mapFileSerial = -1;
|
||||
int g_iPlayerActiveRequired;
|
||||
int g_iSkipAllRestrictions;
|
||||
int g_iDontCooldownMap;
|
||||
int g_iClientCount;
|
||||
int g_iMapsFromCasualPool;
|
||||
int g_iPlayerAFKTime;
|
||||
|
||||
|
||||
int g_NominateCount = 0;
|
||||
@ -249,6 +249,7 @@ public void OnPluginEnd()
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
g_iClientCount = 0;
|
||||
LoadTranslations("mapchooser_extended.phrases");
|
||||
LoadTranslations("basevotes.phrases");
|
||||
LoadTranslations("common.phrases");
|
||||
@ -296,14 +297,14 @@ public void OnPluginStart()
|
||||
delete cvar2;
|
||||
|
||||
ConVar cvar1;
|
||||
HookConVarChange((cvar1 = CreateConVar("sm_active_players_required", "15", "Amount of players required to be considered active before any restrictions are enabled at all.")), Cvar_playerActiveRequired);
|
||||
g_iPlayerActiveRequired = cvar1.IntValue;
|
||||
HookConVarChange((cvar1 = CreateConVar("mce_skip_map_restrictions_player_count", "15", "Amount of players required for any restrictions are enabled.")), Cvar_playerActiveRequired);
|
||||
g_iSkipAllRestrictions = cvar1.IntValue;
|
||||
delete cvar1;
|
||||
|
||||
ConVar cvar;
|
||||
HookConVarChange((cvar = CreateConVar("sm_mapchooser_afk_time", "120", "Time in seconds until a player is considered as AFK and therefore excluded from player average")), Cvar_playerAFKTime);
|
||||
g_iPlayerAFKTime = cvar.IntValue;
|
||||
delete cvar;
|
||||
ConVar cvar4;
|
||||
HookConVarChange((cvar4 = CreateConVar("mce_enable_map_cooldowns_player_count", "30", "Amount of players required for applying cooldowns.")), Cvar_CooldownPlayerRequired);
|
||||
g_iDontCooldownMap = cvar4.IntValue;
|
||||
delete cvar4;
|
||||
|
||||
// MapChooser Extended cvars
|
||||
CreateConVar("mce_version", MCE_VERSION, "MapChooser Extended Version", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
|
||||
@ -444,12 +445,12 @@ public void Cvar_mapsFromCasualPool(ConVar convar, const char[] oldValue, const
|
||||
|
||||
public void Cvar_playerActiveRequired(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
g_iPlayerActiveRequired = convar.IntValue;
|
||||
g_iSkipAllRestrictions = convar.IntValue;
|
||||
}
|
||||
|
||||
public void Cvar_playerAFKTime(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
public void Cvar_CooldownPlayerRequired(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
g_iPlayerAFKTime = convar.IntValue;
|
||||
g_iDontCooldownMap = convar.IntValue;
|
||||
}
|
||||
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
@ -552,7 +553,8 @@ public void OnMapStart()
|
||||
}
|
||||
g_Config.Rewind();
|
||||
|
||||
//2026 march 18th: set cooldown on all maps that share a cooldown with this one including itself.
|
||||
if (g_iDontCooldownMap < g_iClientCount)
|
||||
{
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
GetCurrentMap(map, PLATFORM_MAX_PATH);
|
||||
int Cooldown = InternalGetMapCooldown(map);
|
||||
@ -560,8 +562,10 @@ public void OnMapStart()
|
||||
|
||||
Cooldown = GetTime() + InternalGetMapCooldownTime(map) - RoundToFloor(GetGameTime());
|
||||
g_TimeMapList.SetValue(map, Cooldown, true);
|
||||
//2026 march 18th: set cooldown on all maps that share a cooldown with this one including itself.
|
||||
SetSharedCooldowns(map);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnConfigsExecuted()
|
||||
{
|
||||
@ -667,7 +671,9 @@ public void OnMapEnd()
|
||||
g_WarningTimer = INVALID_HANDLE;
|
||||
g_RunoffCount = 0;
|
||||
|
||||
|
||||
g_iClientCount = GetClientCount(false);
|
||||
if (g_iDontCooldownMap < g_iClientCount)
|
||||
{
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
int Cooldown;
|
||||
|
||||
@ -710,6 +716,7 @@ public void OnMapEnd()
|
||||
|
||||
InternalStoreMapCooldowns();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClientPutInServer(int client)
|
||||
{
|
||||
@ -1615,7 +1622,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
|
||||
|
||||
int clients[MAXPLAYERS + 1];
|
||||
int count = 0;
|
||||
//here we pick clients to show the vote to, we dont show it to autismbots.
|
||||
//here we pick clients to show the vote to, we dont show it to autismbots & fakeclients.
|
||||
for (int i = 0; i <= MaxClients; i++)
|
||||
{
|
||||
Format(player_mapvote[i], 128, "");
|
||||
@ -2155,7 +2162,7 @@ void CreateNextVote()
|
||||
GetCurrentMap(map, PLATFORM_MAX_PATH);
|
||||
RemoveStringFromArray(tempMaps, map);
|
||||
|
||||
if(GetArraySize(tempMaps) > GetConVarInt(g_Cvar_ExcludeMaps) && InternalAreRestrictionsActive(false))
|
||||
if(GetArraySize(tempMaps) > GetConVarInt(g_Cvar_ExcludeMaps) && InternalAreRestrictionsActive())
|
||||
{
|
||||
StringMapSnapshot OldMapListSnapshot = g_OldMapList.Snapshot();
|
||||
for(int i = 0; i < OldMapListSnapshot.Length; i++)
|
||||
@ -2167,8 +2174,6 @@ void CreateNextVote()
|
||||
}
|
||||
|
||||
|
||||
//if(InternalAreRestrictionsActive(false))
|
||||
//{
|
||||
StringMapSnapshot TimeMapListSnapshot = g_TimeMapList.Snapshot();
|
||||
for(int i = 0; i < TimeMapListSnapshot.Length; i++)
|
||||
{
|
||||
@ -2234,16 +2239,16 @@ void CreateNextVote()
|
||||
pickedFromCasualPool++;
|
||||
break;
|
||||
}
|
||||
//march 31st 2026: mce_enable_map_restrictions_min_player_count now also skips all maps on cooldown
|
||||
if(!InternalAreRestrictionsActive())
|
||||
break;
|
||||
|
||||
if(InternalGetMapCooldownTime(map) > GetTime())
|
||||
continue;
|
||||
|
||||
if(!InternalAreRestrictionsActive(false))
|
||||
break;
|
||||
|
||||
if(InternalGetMapVIPRestriction(map))
|
||||
continue;
|
||||
|
||||
|
||||
if(InternalGetMapTimeRestriction(map) != 0)
|
||||
continue;
|
||||
|
||||
@ -2693,10 +2698,6 @@ public int Native_CanNominate(Handle plugin, int numParams)
|
||||
|
||||
public int Native_ExcludeMap(Handle plugin, int numParams)
|
||||
{
|
||||
//this is only called by .cfg files or admins. it should always be put on cooldown when they want to do that.
|
||||
//if(!InternalAreRestrictionsActive(false))
|
||||
// return true;
|
||||
|
||||
int len;
|
||||
GetNativeStringLength(1, len);
|
||||
|
||||
@ -2733,10 +2734,6 @@ public int Native_ExcludeMap(Handle plugin, int numParams)
|
||||
|
||||
public int Native_ExcludeMapTime(Handle plugin, int numParams)
|
||||
{
|
||||
//this is only called by .cfg files or admins. it should always be put on cooldown when they want to do that.
|
||||
//if(!InternalAreRestrictionsActive(false))
|
||||
// return true;
|
||||
|
||||
int len;
|
||||
GetNativeStringLength(1, len);
|
||||
|
||||
@ -2776,7 +2773,7 @@ public int Native_ExcludeMapTime(Handle plugin, int numParams)
|
||||
|
||||
public int Native_GetMapCooldown(Handle plugin, int numParams)
|
||||
{
|
||||
if(!InternalAreRestrictionsActive(false))
|
||||
if(!InternalAreRestrictionsActive())
|
||||
return 0;
|
||||
|
||||
int len;
|
||||
@ -2796,12 +2793,6 @@ public int Native_GetMapCooldown(Handle plugin, int numParams)
|
||||
|
||||
public int Native_GetMapCooldownTime(Handle plugin, int numParams)
|
||||
{
|
||||
//just respecting map cooldown time should not be so much work dx
|
||||
/*
|
||||
if(!InternalAreRestrictionsActive(false))
|
||||
return 0;
|
||||
*/
|
||||
|
||||
int len;
|
||||
GetNativeStringLength(1, len);
|
||||
|
||||
@ -3033,7 +3024,7 @@ public int Native_GetExtendsLeft(Handle plugin, int numParams)
|
||||
|
||||
public int Native_AreRestrictionsActive(Handle plugin, int numParams)
|
||||
{
|
||||
return InternalAreRestrictionsActive(false);
|
||||
return InternalAreRestrictionsActive();
|
||||
}
|
||||
|
||||
public int Native_SimulateMapEnd(Handle plugin, int numParams)
|
||||
@ -3302,18 +3293,7 @@ public void OnClientPostAdminCheck(int client)
|
||||
// >0 = More than MaxPlayers
|
||||
stock int InternalGetMapPlayerRestriction(const char[] map)
|
||||
{
|
||||
//int NumPlayers = GetClientCount(false);
|
||||
int NumPlayers = 0;
|
||||
//excluding non connected players, fakeclients, sourceTV, autism bots and AFKs from player count restriction
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client) && !IsClientSourceTV(client) && !is_bot_player[client]
|
||||
&& GetClientIdleTime(client) < g_iPlayerAFKTime)
|
||||
{
|
||||
NumPlayers++;
|
||||
}
|
||||
}
|
||||
|
||||
int NumPlayers = GetClientCount(false);
|
||||
int MinPlayers = InternalGetMapMinPlayers(map);
|
||||
int MaxPlayers = InternalGetMapMaxPlayers(map);
|
||||
|
||||
@ -3326,14 +3306,7 @@ stock int InternalGetMapPlayerRestriction(const char[] map)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
false means we never put the map on cooldown if time range is inside the no map restriction time or
|
||||
if less than the minimum active players for enabling map restrictions are on the server.
|
||||
|
||||
true means we put maps on Cooldown even if there was no map restrictions because of less than 15 active players (the number is a cvar, its not static)
|
||||
true still respects the time range with no map restrictions (23:30 to 10:30 right now) and wont apply cooldown there.
|
||||
*/
|
||||
stock bool InternalAreRestrictionsActive(bool skip_player_check)
|
||||
stock bool InternalAreRestrictionsActive()
|
||||
{
|
||||
if (!GetConVarBool(g_Cvar_NoRestrictionTimeframeEnable))
|
||||
return true;
|
||||
@ -3354,17 +3327,12 @@ stock bool InternalAreRestrictionsActive(bool skip_player_check)
|
||||
return false;
|
||||
}
|
||||
|
||||
int ActivePlayerCount = 0;
|
||||
for (int i = 0; i <= MaxClients; i++)
|
||||
{
|
||||
if (IsValidClient(i) && !IsFakeClient(i) && !IsClientSourceTV(i) && !is_bot_player[i] && GetClientIdleTime(i) < g_iPlayerAFKTime
|
||||
&& (GetClientTeam(i) == CS_TEAM_T || GetClientTeam(i) == CS_TEAM_CT))
|
||||
{
|
||||
ActivePlayerCount++;
|
||||
}
|
||||
}
|
||||
//if (IsValidClient(i) && !IsFakeClient(i) && !IsClientSourceTV(i) && !is_bot_player[i]
|
||||
// && (GetClientTeam(i) == CS_TEAM_T || GetClientTeam(i) == CS_TEAM_CT))
|
||||
|
||||
if (ActivePlayerCount <= g_iPlayerActiveRequired && !skip_player_check)
|
||||
// a lot more simplified again so its easier to understand.
|
||||
int NumPlayers = GetClientCount(false);
|
||||
if (NumPlayers <= g_iSkipAllRestrictions)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -327,47 +327,6 @@ public Action Command_Addmap(int client, int args)
|
||||
AttemptAdminNominate(client, mapname);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
/*
|
||||
int Cooldown1 = GetMapCooldownTime(mapname);
|
||||
if(Cooldown1 > GetTime())
|
||||
{
|
||||
int Seconds = Cooldown1 - GetTime();
|
||||
CPrintToChat(client, "[NE] %t", "Map Cooldown Time Error", Seconds / 3600, (Seconds % 3600) / 60);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if(!CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_KICK, true) )
|
||||
{
|
||||
bool RestrictionsActive = AreRestrictionsActive();
|
||||
|
||||
int TimeRestriction = GetMapTimeRestriction(mapname);
|
||||
if(RestrictionsActive && TimeRestriction)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate Time Error", TimeRestriction / 60, TimeRestriction % 60);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int AverageHourRestricted = GetAveragePlayerTimeOnServerMapRestriction(mapname);
|
||||
if (RestrictionsActive && AverageHourRestricted > 0)
|
||||
{
|
||||
PrintToChat(client, "%s requires +%i hours average. Use sm_houravg to check average.", mapname, AverageHourRestricted);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int PlayerRestriction = GetMapPlayerRestriction(mapname);
|
||||
if(RestrictionsActive && PlayerRestriction)
|
||||
{
|
||||
if(PlayerRestriction < 0)
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate MinPlayers Error", PlayerRestriction * -1);
|
||||
else
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate MaxPlayers Error", PlayerRestriction);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
NominateResult result = NominateMap(mapname, true, 0);
|
||||
|
||||
@ -570,8 +529,15 @@ public Action Command_Nominate(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
//July 2024 edit: any person who is potential leader can just skip all cooldowns and map restrictions. same for admins.
|
||||
if(!CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_KICK, true) && !Leader_Is(client))
|
||||
{
|
||||
bool RestrictionsActive = AreRestrictionsActive();
|
||||
|
||||
//restrictions not being active now also skips all the cooldowns.
|
||||
int Cooldown1 = GetMapCooldownTime(mapname);
|
||||
if(Cooldown1 > GetTime())
|
||||
if(RestrictionsActive && Cooldown1 > GetTime())
|
||||
{
|
||||
int Seconds = Cooldown1 - GetTime();
|
||||
CPrintToChat(client, "[NE] %t", "Map Cooldown Time Error", Seconds / 3600, (Seconds % 3600) / 60);
|
||||
@ -579,10 +545,6 @@ public Action Command_Nominate(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
//July 2024 edit: any person who is potential leader can just skip all cooldowns and map restrictions. same for admins.
|
||||
if(!CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_KICK, true) && !Leader_Is(client))
|
||||
{
|
||||
bool RestrictionsActive = AreRestrictionsActive();
|
||||
bool VIPRestriction = GetMapVIPRestriction(mapname, client);
|
||||
if(RestrictionsActive && VIPRestriction)
|
||||
{
|
||||
@ -973,11 +935,8 @@ Menu BuildMapMenu(const char[] filter, int client)
|
||||
}
|
||||
if (g_bClientsIgnoring[client])
|
||||
{
|
||||
if (GetMapCooldownTime(map) > GetTime())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(AreRestrictionsActive() && (
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetAveragePlayerTimeOnServerMapRestriction(map) > 0 ||
|
||||
@ -1071,15 +1030,10 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
|
||||
GetClientName(param1, name, MAX_NAME_LENGTH);
|
||||
|
||||
if (GetMapCooldownTime(map) > GetTime())
|
||||
{
|
||||
PrintToChat(param1, "[NE] You cant nominate this map right now.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_KICK, true) && !Leader_Is(param1))
|
||||
{
|
||||
if(AreRestrictionsActive() && (
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetAveragePlayerTimeOnServerMapRestriction(map) > 0 ||
|
||||
@ -1172,14 +1126,11 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
}
|
||||
delete MapList;
|
||||
delete OwnerList;
|
||||
if (GetMapCooldownTime(map) > GetTime())
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
|
||||
if(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_KICK, true) && !Leader_Is(param1))
|
||||
{
|
||||
if(AreRestrictionsActive() && (
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetAveragePlayerTimeOnServerMapRestriction(map) > 0 ||
|
||||
@ -1232,7 +1183,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
}
|
||||
|
||||
int Cooldown = GetMapCooldownTime(map);
|
||||
if(Cooldown > GetTime())
|
||||
if(RestrictionsActive && Cooldown > GetTime())
|
||||
{
|
||||
int Seconds = Cooldown - GetTime();
|
||||
char time[16];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user