renamed cvar to make more sense, set shared cooldowns on map start and map ends, removed global bool g_SaveCDOnMapEnd, added shared cooldowns as group in mapchooser_extended.cfg, giving leader nominations same priority as admin nominations, removed a lot of translation phrases to instead english only. removing mapstatus enabled, disabled, and the others. removed the whole fucking trie, prevent people from nominating maps nominated by leader or admin. re added the boost messages by removing translation files. added support in nominate and nomlist to indicate admin and leader nomination.

This commit is contained in:
jenz 2026-03-21 23:41:09 +01:00
parent 4c69c978b2
commit 9d3a9e6b89
3 changed files with 183 additions and 255 deletions

View File

@ -51,7 +51,6 @@
#include <sdktools> #include <sdktools>
#include <cstrike> #include <cstrike>
#include <multicolors> #include <multicolors>
#include <PlayerManager>
#include <nominations_extended> #include <nominations_extended>
#include <rockthevote_extended> #include <rockthevote_extended>
#include <AFKManager> #include <AFKManager>
@ -140,11 +139,10 @@ bool g_WaitingForVote;
bool g_MapVoteCompleted; bool g_MapVoteCompleted;
bool g_ChangeMapInProgress; bool g_ChangeMapInProgress;
bool g_HasIntermissionStarted = false; bool g_HasIntermissionStarted = false;
bool g_SaveCDOnMapEnd = true;
bool g_RtvInitiated = 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_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_mapFileSerial = -1;
int g_iPlayerCount_excludeSpec; int g_iPlayerActiveRequired;
int g_iMapsFromCasualPool; int g_iMapsFromCasualPool;
int g_iPlayerAFKTime; int g_iPlayerAFKTime;
@ -298,8 +296,8 @@ public void OnPluginStart()
delete cvar2; delete cvar2;
ConVar cvar1; 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_playerExcludeSpec); 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_iPlayerCount_excludeSpec = cvar1.IntValue; g_iPlayerActiveRequired = cvar1.IntValue;
delete cvar1; delete cvar1;
ConVar cvar; ConVar cvar;
@ -444,9 +442,9 @@ public void Cvar_mapsFromCasualPool(ConVar convar, const char[] oldValue, const
g_iMapsFromCasualPool = convar.IntValue; g_iMapsFromCasualPool = convar.IntValue;
} }
public void Cvar_playerExcludeSpec(ConVar convar, const char[] oldValue, const char[] newValue) public void Cvar_playerActiveRequired(ConVar convar, const char[] oldValue, const char[] newValue)
{ {
g_iPlayerCount_excludeSpec = convar.IntValue; g_iPlayerActiveRequired = convar.IntValue;
} }
public void Cvar_playerAFKTime(ConVar convar, const char[] oldValue, const char[] newValue) public void Cvar_playerAFKTime(ConVar convar, const char[] oldValue, const char[] newValue)
@ -553,15 +551,16 @@ public void OnMapStart()
return; return;
} }
g_Config.Rewind(); g_Config.Rewind();
//this does not detect obvioulsy when there is more or less than 15 players active because its the mapstart
// nobody has connected yet. OnMapEnd also does not work for checking this. so no point setting it to false here. //2026 march 18th: set cooldown on all maps that share a cooldown with this one including itself.
/* static char map[PLATFORM_MAX_PATH];
if(InternalAreRestrictionsActive(true)) GetCurrentMap(map, PLATFORM_MAX_PATH);
g_SaveCDOnMapEnd = true; int Cooldown = InternalGetMapCooldown(map);
else g_OldMapList.SetValue(map, Cooldown, true);
g_SaveCDOnMapEnd = false;
*/ Cooldown = GetTime() + InternalGetMapCooldownTime(map) - RoundToFloor(GetGameTime());
g_SaveCDOnMapEnd = true; g_TimeMapList.SetValue(map, Cooldown, true);
SetSharedCooldowns(map);
} }
public void OnConfigsExecuted() public void OnConfigsExecuted()
@ -611,6 +610,45 @@ public void OnConfigsExecuted()
InitializeOfficialMapList(); InitializeOfficialMapList();
} }
public void SetSharedCooldowns(char[] map)
{
if (g_Config && g_Config.JumpToKey("_sharedcooldowns"))
{
if (!g_Config.GotoFirstSubKey(false))
{
g_Config.Rewind();
return;
}
do
{
char section[128];
g_Config.GetSectionName(section, sizeof(section));
// Quick check: does this group contain the map?
if (g_Config.JumpToKey(map))
{
g_Config.GoBack(); // back to group level
if (g_Config.GotoFirstSubKey(false))
{
//First entry is the cooldown duration
char cooldown[16];
g_Config.GetSectionName(cooldown, sizeof(cooldown));
// Remaining entries are map names
while (g_Config.GotoNextKey(false))
{
char mapname[128];
g_Config.GetSectionName(mapname, sizeof(mapname));
int Cooldown = GetTime() + TimeStrToSeconds(cooldown) - RoundToFloor(GetGameTime());
g_TimeMapList.SetValue(mapname, Cooldown, true);
}
g_Config.GoBack(); // back to the group key
}
}
} while(g_Config.GotoNextKey());
g_Config.Rewind();
}
}
public void OnMapEnd() public void OnMapEnd()
{ {
g_iNextmapState = 0; g_iNextmapState = 0;
@ -634,14 +672,15 @@ public void OnMapEnd()
int Cooldown; int Cooldown;
GetCurrentMap(map, PLATFORM_MAX_PATH); GetCurrentMap(map, PLATFORM_MAX_PATH);
if(g_SaveCDOnMapEnd)
{
Cooldown = InternalGetMapCooldown(map); Cooldown = InternalGetMapCooldown(map);
g_OldMapList.SetValue(map, Cooldown, true); g_OldMapList.SetValue(map, Cooldown, true);
Cooldown = GetTime() + InternalGetMapCooldownTime(map) - RoundToFloor(GetGameTime()); Cooldown = GetTime() + InternalGetMapCooldownTime(map) - RoundToFloor(GetGameTime());
g_TimeMapList.SetValue(map, Cooldown, true); g_TimeMapList.SetValue(map, Cooldown, true);
}
//2026 march 18th: set cooldown on all maps that share cooldown with this one.
//why do it again? because obviously people will make the mistake of giving the map its own specific cooldown despite being part of a sharedcooldown group.
SetSharedCooldowns(map);
StringMapSnapshot OldMapListSnapshot = g_OldMapList.Snapshot(); StringMapSnapshot OldMapListSnapshot = g_OldMapList.Snapshot();
for(int i = 0; i < OldMapListSnapshot.Length; i++) for(int i = 0; i < OldMapListSnapshot.Length; i++)
@ -733,15 +772,6 @@ public Action Command_SetNextmap(int client, int args)
SetNextMap(map); SetNextMap(map);
g_iNextmapState = 2; //admin set the next map g_iNextmapState = 2; //admin set the next map
g_MapVoteCompleted = true; g_MapVoteCompleted = true;
//checking on MapStart and MapEnd is not good enough. Players are not considered alive and on teams at those points in time.
//therefore instead applying the bool here after the mapvote completed.
/*
if(InternalAreRestrictionsActive(false))
g_SaveCDOnMapEnd = true;
else
g_SaveCDOnMapEnd = false;
*/
g_SaveCDOnMapEnd = true;
return Plugin_Handled; return Plugin_Handled;
} }
@ -1062,7 +1092,6 @@ public Action Timer_fall_back_map_switch(Handle hTimer, Handle dp)
} }
else else
{ {
char map_line[256]; char map_line[256];
File f = OpenFile("cfg/defaultmap.cfg", "r"); File f = OpenFile("cfg/defaultmap.cfg", "r");
if (f != null) if (f != null)
@ -1218,6 +1247,11 @@ public Handle get_most_nominated_maps(bool create_next_vote)
{ {
nominate_count_for_particular_map = 1999; nominate_count_for_particular_map = 1999;
} }
else if (Leader_Is(i))
{
//from now on giving leader nominations same priority as admin nominations.
nominate_count_for_particular_map = 1999;
}
else else
{ {
int nominate_worth = GetPlayerWorthRTV_boost_(i); int nominate_worth = GetPlayerWorthRTV_boost_(i);
@ -1332,7 +1366,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
// Check if a vote is in progress first // Check if a vote is in progress first
if(IsVoteInProgress()) if(IsVoteInProgress())
{ {
CPrintToChatAll("[MCE] %t", "Cannot Start Vote", FAILURE_TIMER_LENGTH); PrintToChatAll("[MCE] Vote already in progress. Retrying in %i seconds.", FAILURE_TIMER_LENGTH);
Handle data; Handle data;
g_RetryTimer = CreateDataTimer(1.0, Timer_StartMapVote, data, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT); g_RetryTimer = CreateDataTimer(1.0, Timer_StartMapVote, data, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT);
//LogMessage("Mapchooser_extended_avg: called Timer_StartMapVote"); //LogMessage("Mapchooser_extended_avg: called Timer_StartMapVote");
@ -1581,7 +1615,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
int clients[MAXPLAYERS + 1]; int clients[MAXPLAYERS + 1];
int count = 0; int count = 0;
//here we pick clients to show the vote to, we dont show it to autismbots and nosteamers. //here we pick clients to show the vote to, we dont show it to autismbots.
for (int i = 0; i < MaxClients; i++) for (int i = 0; i < MaxClients; i++)
{ {
Format(player_mapvote[i], 128, ""); Format(player_mapvote[i], 128, "");
@ -1602,7 +1636,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
Call_Finish(); Call_Finish();
LogAction(-1, -1, "Voting for next map has started."); LogAction(-1, -1, "Voting for next map has started.");
CPrintToChatAll("[MCE] %t", "Nextmap Voting Started"); PrintToChatAll("[MCE] Voting for next map has started.");
} }
public Action Timer_Countdown(Handle timer) public Action Timer_Countdown(Handle timer)
@ -1779,19 +1813,15 @@ public void Handler_VoteFinishedGeneric(char[] map,
g_HasVoteStarted = false; g_HasVoteStarted = false;
g_MapVoteCompleted = true; g_MapVoteCompleted = true;
//checking on MapStart and MapEnd is not good enough. Players are not considered alive and on teams at those points in time.
//therefore instead applying the bool here after the mapvote completed.
g_SaveCDOnMapEnd = true;
//PrintToChatAll("map: %s", map); //PrintToChatAll("map: %s", map);
if (g_ChangeTime == MapChange_MapEnd) if (g_ChangeTime == MapChange_MapEnd)
{ {
CPrintToChatAll("[MCE] %t", "Extend Voting Failed", map_votes, num_votes); PrintToChatAll("[MCE] Extend voting finished. The map was not extended. (Received %i/%i of votes)", map_votes, num_votes);
g_MapVoteCompleted = false; //this was only the extend or dont extend vote, still need actual mapvote. g_MapVoteCompleted = false; //this was only the extend or dont extend vote, still need actual mapvote.
} }
else else
{ {
//CPrintToChatAll("[MCE] %t", "Nextmap Voting Finished", map, map_votes, num_votes);
PrintToChatAll("[MCE] Map voting has finished. The next map will be %s. (Received %i votes out of %i)", map, map_votes, num_votes); PrintToChatAll("[MCE] Map voting has finished. The next map will be %s. (Received %i votes out of %i)", map, map_votes, num_votes);
LogAction(-1, -1, "Voting for next map has finished. Nextmap: %s.", map); LogAction(-1, -1, "Voting for next map has finished. Nextmap: %s.", map);
} }
@ -1892,7 +1922,7 @@ public void Handler_MapVoteFinished(Handle menu,
break; break;
} }
CPrintToChatAll("[MCE] %t", "Tie Vote", GetArraySize(mapList)); PrintToChatAll("[MCE] The top %i maps had the same number of votes.\nA revote is needed!", GetArraySize(mapList));
//LogMessage("Mapchooser_extended_avg reached WarningType_Revote 1"); //LogMessage("Mapchooser_extended_avg reached WarningType_Revote 1");
SetupWarningTimer(WarningType_Revote, view_as<MapChange>(g_ChangeTime), mapList); SetupWarningTimer(WarningType_Revote, view_as<MapChange>(g_ChangeTime), mapList);
//PrintToChatAll("SetupWarningTimer 7"); //PrintToChatAll("SetupWarningTimer 7");
@ -1918,7 +1948,7 @@ public void Handler_MapVoteFinished(Handle menu,
break; break;
} }
CPrintToChatAll("[MCE] %t", "Revote Is Needed", required_percent); PrintToChatAll("[MCE] No map has received more than %i of the vote.\nSo, which map will win? A revote is needed!", required_percent);
//LogMessage("Mapchooser_extended_avg reached WarningType_Revote 2"); //LogMessage("Mapchooser_extended_avg reached WarningType_Revote 2");
SetupWarningTimer(WarningType_Revote, view_as<MapChange>(g_ChangeTime), mapList); SetupWarningTimer(WarningType_Revote, view_as<MapChange>(g_ChangeTime), mapList);
//PrintToChatAll("SetupWarningTimer 8"); //PrintToChatAll("SetupWarningTimer 8");
@ -3325,7 +3355,7 @@ stock bool InternalAreRestrictionsActive(bool skip_player_check)
} }
} }
if (ActivePlayerCount <= g_iPlayerCount_excludeSpec && !skip_player_check) if (ActivePlayerCount <= g_iPlayerActiveRequired && !skip_player_check)
{ {
return false; return false;
} }

View File

@ -54,9 +54,6 @@ public Plugin myinfo =
url = "https://forums.alliedmods.net/showthread.php?t=156974" url = "https://forums.alliedmods.net/showthread.php?t=156974"
}; };
Handle g_Cvar_ExcludeOld = INVALID_HANDLE;
Handle g_Cvar_ExcludeCurrent = INVALID_HANDLE;
Handle g_MapList = INVALID_HANDLE; Handle g_MapList = INVALID_HANDLE;
Handle g_AdminMapList = INVALID_HANDLE; Handle g_AdminMapList = INVALID_HANDLE;
Menu g_MapMenu; Menu g_MapMenu;
@ -64,14 +61,6 @@ Menu g_AdminMapMenu;
int g_mapFileSerial = -1; int g_mapFileSerial = -1;
int g_AdminMapFileSerial = -1; int g_AdminMapFileSerial = -1;
#define MAPSTATUS_ENABLED (1<<0)
#define MAPSTATUS_DISABLED (1<<1)
#define MAPSTATUS_EXCLUDE_CURRENT (1<<2)
#define MAPSTATUS_EXCLUDE_PREVIOUS (1<<3)
#define MAPSTATUS_EXCLUDE_NOMINATED (1<<4)
Handle g_mapTrie;
// Nominations Extended Convars // Nominations Extended Convars
Handle g_Cvar_MarkCustomMaps = INVALID_HANDLE; Handle g_Cvar_MarkCustomMaps = INVALID_HANDLE;
Handle g_Cvar_NominateDelay = INVALID_HANDLE; Handle g_Cvar_NominateDelay = INVALID_HANDLE;
@ -100,8 +89,6 @@ public void OnPluginStart()
g_MapList = CreateArray(arraySize); g_MapList = CreateArray(arraySize);
g_AdminMapList = CreateArray(arraySize); g_AdminMapList = CreateArray(arraySize);
g_Cvar_ExcludeOld = CreateConVar("sm_nominate_excludeold", "1", "Specifies if the current map should be excluded from the Nominations list", 0, true, 0.00, true, 1.0);
g_Cvar_ExcludeCurrent = CreateConVar("sm_nominate_excludecurrent", "1", "Specifies if the MapChooser excluded maps should also be excluded from Nominations", 0, true, 0.00, true, 1.0);
g_Cvar_InitialDelay = CreateConVar("sm_nominate_initialdelay", "60.0", "Time in seconds before first Nomination can be made", 0, true, 0.00); g_Cvar_InitialDelay = CreateConVar("sm_nominate_initialdelay", "60.0", "Time in seconds before first Nomination can be made", 0, true, 0.00);
g_Cvar_NominateDelay = CreateConVar("sm_nominate_delay", "3.0", "Delay between nominations", 0, true, 0.00, true, 60.00); g_Cvar_NominateDelay = CreateConVar("sm_nominate_delay", "3.0", "Delay between nominations", 0, true, 0.00, true, 60.00);
@ -125,8 +112,6 @@ public void OnPluginStart()
// Nominations Extended cvars // Nominations Extended cvars
CreateConVar("ne_version", MCE_VERSION, "Nominations Extended Version", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD); CreateConVar("ne_version", MCE_VERSION, "Nominations Extended Version", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
g_mapTrie = CreateTrie();
//DB //DB
if (!g_dDatabase) if (!g_dDatabase)
{ {
@ -310,7 +295,6 @@ public void OnConfigsExecuted()
g_NominationDelay = GetTime() + GetConVarInt(g_Cvar_InitialDelay); g_NominationDelay = GetTime() + GetConVarInt(g_Cvar_InitialDelay);
UpdateMapTrie();
UpdateMapMenus(); UpdateMapMenus();
} }
@ -320,61 +304,6 @@ void UpdateMapMenus()
g_AdminMapMenu = BuildAdminMapMenu(""); g_AdminMapMenu = BuildAdminMapMenu("");
} }
void UpdateMapTrie()
{
static char map[PLATFORM_MAX_PATH];
static char currentMap[PLATFORM_MAX_PATH];
ArrayList excludeMaps;
if(GetConVarBool(g_Cvar_ExcludeOld))
{
excludeMaps = CreateArray(ByteCountToCells(PLATFORM_MAX_PATH));
GetExcludeMapList(excludeMaps);
}
if(GetConVarBool(g_Cvar_ExcludeCurrent))
GetCurrentMap(currentMap, sizeof(currentMap));
ClearTrie(g_mapTrie);
for(int i = 0; i < GetArraySize(g_MapList); i++)
{
int status = MAPSTATUS_ENABLED;
GetArrayString(g_MapList, i, map, sizeof(map));
if(GetConVarBool(g_Cvar_ExcludeCurrent))
{
if(StrEqual(map, currentMap))
status = MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_CURRENT;
}
/* Dont bother with this check if the current map check passed */
if(GetConVarBool(g_Cvar_ExcludeOld) && status == MAPSTATUS_ENABLED)
{
if(FindStringInArray(excludeMaps, map) != -1)
status = MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_PREVIOUS;
}
SetTrieValue(g_mapTrie, map, status);
}
if(excludeMaps)
delete excludeMaps;
}
public void OnNominationRemoved(const char[] map, int client)
{
int status;
/* Is the map in our list? */
if(!GetTrieValue(g_mapTrie, map, status))
return;
/* Was the map disabled due to being nominated */
if((status & MAPSTATUS_EXCLUDE_NOMINATED) != MAPSTATUS_EXCLUDE_NOMINATED)
return;
SetTrieValue(g_mapTrie, map, MAPSTATUS_ENABLED);
}
public Action Command_Addmap(int client, int args) public Action Command_Addmap(int client, int args)
{ {
if(args == 0) if(args == 0)
@ -412,28 +341,6 @@ public Action Command_Addmap(int client, int args)
{ {
bool RestrictionsActive = AreRestrictionsActive(); bool RestrictionsActive = AreRestrictionsActive();
int status;
if(GetTrieValue(g_mapTrie, mapname, status))
{
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
{
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
CPrintToChat(client, "[NE] %t", "Cant Nominate Current Map");
if(RestrictionsActive && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
{
int Cooldown = GetMapCooldown(mapname);
CPrintToChat(client, "[NE] %t (%d)", "Map in Exclude List", Cooldown);
}
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
CPrintToChat(client, "[NE] %t", "Map Already Nominated");
return Plugin_Handled;
}
}
int TimeRestriction = GetMapTimeRestriction(mapname); int TimeRestriction = GetMapTimeRestriction(mapname);
if(RestrictionsActive && TimeRestriction) if(RestrictionsActive && TimeRestriction)
{ {
@ -472,8 +379,6 @@ public Action Command_Addmap(int client, int args)
return Plugin_Handled; return Plugin_Handled;
} }
SetTrieValue(g_mapTrie, mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
CReplyToCommand(client, "%t", "Map Inserted", mapname); CReplyToCommand(client, "%t", "Map Inserted", mapname);
LogAction(client, -1, "\"%L\" inserted map \"%s\".", client, mapname); LogAction(client, -1, "\"%L\" inserted map \"%s\".", client, mapname);
@ -548,18 +453,9 @@ public Action Command_AddExclude(int client, int args)
mode = StringToInt(buffer); mode = StringToInt(buffer);
} }
int status;
if(!GetTrieValue(g_mapTrie, mapname, status))
{
ReplyToCommand(client, "[NE] %t", "Map was not found", mapname);
return Plugin_Handled;
}
ShowActivity(client, "Excluded map \"%s\" from nomination", mapname); ShowActivity(client, "Excluded map \"%s\" from nomination", mapname);
LogAction(client, -1, "\"%L\" excluded map \"%s\" from nomination", client, mapname); LogAction(client, -1, "\"%L\" excluded map \"%s\" from nomination", client, mapname);
SetTrieValue(g_mapTrie, mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_PREVIOUS);
// native call to mapchooser_extended // native call to mapchooser_extended
ExcludeMap(mapname, cooldown, mode); ExcludeMap(mapname, cooldown, mode);
@ -592,8 +488,7 @@ public Action Command_AddExcludeTime(int client, int args)
mode = StringToInt(buffer); mode = StringToInt(buffer);
} }
int status; if (FindStringInArray(g_MapList, mapname) == -1)
if(!GetTrieValue(g_mapTrie, mapname, status))
{ {
ReplyToCommand(client, "[NE] %t", "Map was not found", mapname); ReplyToCommand(client, "[NE] %t", "Map was not found", mapname);
return Plugin_Handled; return Plugin_Handled;
@ -668,10 +563,8 @@ public Action Command_Nominate(int client, int args)
static char mapname[PLATFORM_MAX_PATH]; static char mapname[PLATFORM_MAX_PATH];
GetCmdArg(1, mapname, sizeof(mapname)); GetCmdArg(1, mapname, sizeof(mapname));
int status; if (FindStringInArray(g_MapList, mapname) == -1)
if(!GetTrieValue(g_mapTrie, mapname, status))
{ {
//CPrintToChat(client, "%t", "Map was not found", mapname);
ReplyToCommand(client, "Map was not found: %s", mapname); ReplyToCommand(client, "Map was not found: %s", mapname);
AttemptNominate(client, mapname); AttemptNominate(client, mapname);
return Plugin_Handled; return Plugin_Handled;
@ -690,26 +583,6 @@ public Action Command_Nominate(int client, int args)
if(!CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_KICK, true) && !Leader_Is(client)) if(!CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_KICK, true) && !Leader_Is(client))
{ {
bool RestrictionsActive = AreRestrictionsActive(); bool RestrictionsActive = AreRestrictionsActive();
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
{
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
ReplyToCommand(client, "Cant Nominate Current Map.");
//CPrintToChat(client, "[NE] %t", "Cant Nominate Current Map");
if(RestrictionsActive && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
{
int Cooldown = GetMapCooldown(mapname);
CPrintToChat(client, "[NE] %t (%d)", "Map in Exclude List", Cooldown);
}
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
CPrintToChat(client, "[NE] %t", "Map Already Nominated");
return Plugin_Handled;
}
bool VIPRestriction = GetMapVIPRestriction(mapname, client); bool VIPRestriction = GetMapVIPRestriction(mapname, client);
if(RestrictionsActive && VIPRestriction) if(RestrictionsActive && VIPRestriction)
{ {
@ -744,6 +617,32 @@ public Action Command_Nominate(int client, int args)
return Plugin_Handled; return Plugin_Handled;
} }
} }
//2026 march 20th: if map already is admin or leader nominated we dont allow it being nominated again
int arraySize = ByteCountToCells(PLATFORM_MAX_PATH);
ArrayList MapList = CreateArray(arraySize);
ArrayList OwnerList = CreateArray();
GetNominatedMapList(MapList, OwnerList);
for (int j = 0; j < GetArraySize(MapList); j++)
{
char mapIterated[128];
GetArrayString(MapList, j, mapIterated, sizeof(mapIterated));
if (StrEqual(mapname, mapIterated))
{
int owner = GetArrayCell(OwnerList, j);
if (!owner || Leader_Is(owner))
{
delete MapList;
delete OwnerList;
PrintToChat(client, "The map is already nominated by admin or leader.");
return Plugin_Handled;
}
}
}
delete MapList;
delete OwnerList;
NominateResult result = NominateMap(mapname, false, client); NominateResult result = NominateMap(mapname, false, client);
if (result == Nominate_InvalidMap) if (result == Nominate_InvalidMap)
@ -762,21 +661,17 @@ public Action Command_Nominate(int client, int args)
return Plugin_Handled; return Plugin_Handled;
} }
/* Map was nominated! - Disable the menu item and update the trie */
//SetTrieValue(g_mapTrie, mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
static char name[MAX_NAME_LENGTH]; static char name[MAX_NAME_LENGTH];
GetClientName(client, name, sizeof(name)); GetClientName(client, name, sizeof(name));
int nominate_worth = GetPlayerWorthRTV_boost_(client);
if(result == Nominate_Added) if(result == Nominate_Added)
{ {
int nominate_worth = GetPlayerWorthRTV_boost_(client); PrintToChatAll("[NE] %N has nominated %s (%i Nomination Boost).", client, mapname, nominate_worth);
PrintToChatAll("[NE] %t", "Map Nominated", name, mapname, nominate_worth);
} }
else if(result == Nominate_Replaced) else if(result == Nominate_Replaced)
{ {
PrintToChatAll("[NE] %t", "Map Nomination Changed", name, mapname); PrintToChatAll("[NE] %N has changed their nomination to %s (%i Nomination Boost).", client, mapname, nominate_worth);
} }
LogMessage("%s nominated %s", name, mapname); LogMessage("%s nominated %s", name, mapname);
@ -845,7 +740,14 @@ void AttemptNominate(int client, const char[] filter = "")
menu = BuildMapMenu(filter, client); menu = BuildMapMenu(filter, client);
int nominate_worth = GetPlayerWorthRTV_boost_(client); int nominate_worth = GetPlayerWorthRTV_boost_(client);
SetMenuTitle(menu, "%T", "Nominate Title", client, nominate_worth); if (Leader_Is(client))
{
SetMenuTitle(menu, "Nominate Map: (%i Nomination Boost Leader)", 999);
}
else
{
SetMenuTitle(menu, "Nominate Map: (%i Nomination Boost)", nominate_worth);
}
DisplayMenu(menu, client, MENU_TIME_FOREVER); DisplayMenu(menu, client, MENU_TIME_FOREVER);
} }
@ -858,7 +760,7 @@ void AttemptAdminNominate(int client, const char[] filter = "")
if(filter[0]) if(filter[0])
menu = BuildAdminMapMenu(filter); menu = BuildAdminMapMenu(filter);
SetMenuTitle(menu, "%T", "Nominate Title", client, 999); SetMenuTitle(menu, "Nominate Map: (%i Nomination Boost Admin)", 999);
DisplayMenu(menu, client, MENU_TIME_FOREVER); DisplayMenu(menu, client, MENU_TIME_FOREVER);
} }
@ -920,7 +822,6 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
for(int i = 0; i < GetArraySize(MapList); i++) for(int i = 0; i < GetArraySize(MapList); i++)
{ {
GetArrayString(MapList, i, map, sizeof(map)); GetArrayString(MapList, i, map, sizeof(map));
if(!filter[0] || StrContains(map, filter, false) != -1) if(!filter[0] || StrContains(map, filter, false) != -1)
{ {
//admin nominations must have most votes shrug //admin nominations must have most votes shrug
@ -929,7 +830,7 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
int nominate_count_for_particular_map = 0; int nominate_count_for_particular_map = 0;
sm.GetValue(map, nominate_count_for_particular_map); sm.GetValue(map, nominate_count_for_particular_map);
//if its console its admin nomination. if its nominated by leader it will also go to the vote just. //if its console its admin nomination. if its nominated by leader it will also go to the vote just.
if (!owner) if (!owner || Leader_Is(owner))
{ {
nominate_count_for_particular_map = 1999; nominate_count_for_particular_map = 1999;
} }
@ -1015,7 +916,18 @@ Menu BuildMapMenu(const char[] filter, int client)
for(int j = 0; j < GetArraySize(MapList); j++) for(int j = 0; j < GetArraySize(MapList); j++)
{ {
int owner = GetArrayCell(OwnerList, j); int owner = GetArrayCell(OwnerList, j);
if (client == owner) //display if normal nomination, leader nomination or admin nomination
if (!owner)
{
GetArrayString(MapList, j, map, sizeof(map));
sm.SetValue(map, 2);
}
else if (Leader_Is(owner))
{
GetArrayString(MapList, j, map, sizeof(map));
sm.SetValue(map, 3);
}
else if (client == owner)
{ {
GetArrayString(MapList, j, map, sizeof(map)); GetArrayString(MapList, j, map, sizeof(map));
sm.SetValue(map, 1); sm.SetValue(map, 1);
@ -1045,11 +957,19 @@ Menu BuildMapMenu(const char[] filter, int client)
{ {
int map_present = 0; int map_present = 0;
sm.GetValue(map, map_present); sm.GetValue(map, map_present);
// 1 -> nominated by client. 2 -> nominated by admin. 3 -> nominated by leader
if (map_present == 1) if (map_present == 1)
{ {
//PrintToChatAll("client %N here. map: %s", client, map);
StrCat(map, sizeof(map), " (Nominated)"); StrCat(map, sizeof(map), " (Nominated)");
} }
else if (map_present == 2)
{
StrCat(map, sizeof(map), " (Admin Nominated)");
}
else if (map_present == 3)
{
StrCat(map, sizeof(map), " (Leader Nominated)");
}
} }
if (g_bClientsIgnoring[client]) if (g_bClientsIgnoring[client])
{ {
@ -1126,13 +1046,12 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
//2023-03-22 edit since client sometimes is 0 which fucks up mapchooser //2023-03-22 edit since client sometimes is 0 which fucks up mapchooser
if (param1 > 0 && param1 <= MaxClients && IsClientConnected(param1) && IsClientInGame(param1)) if (param1 > 0 && param1 <= MaxClients && IsClientConnected(param1) && IsClientInGame(param1))
{ {
if(g_Player_NominationDelay[param1] > GetTime()) if (g_Player_NominationDelay[param1] > GetTime())
{ {
PrintToChat(param1, "[NE] Please wait %d seconds before you can nominate again", g_Player_NominationDelay[param1] - GetTime()); PrintToChat(param1, "[NE] Please wait %d seconds before you can nominate again", g_Player_NominationDelay[param1] - GetTime());
DisplayMenuAtItem(menu, param1, GetMenuSelectionPosition(), MENU_TIME_FOREVER); DisplayMenuAtItem(menu, param1, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
return 0; return 0;
} }
static char map[PLATFORM_MAX_PATH]; static char map[PLATFORM_MAX_PATH];
char name[MAX_NAME_LENGTH]; char name[MAX_NAME_LENGTH];
GetMenuItem(menu, param2, map, sizeof(map)); GetMenuItem(menu, param2, map, sizeof(map));
@ -1158,7 +1077,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
return 0; return 0;
} }
if(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_KICK, true) && !Leader_Is(param1)) if (!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_KICK, true) && !Leader_Is(param1))
{ {
if(AreRestrictionsActive() && ( if(AreRestrictionsActive() && (
GetMapTimeRestriction(map) || GetMapTimeRestriction(map) ||
@ -1190,51 +1109,69 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
PrintToChat(param1, "[NE] %t", "Max Nominations"); PrintToChat(param1, "[NE] %t", "Max Nominations");
return 0; return 0;
} }
//SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
if(result == Nominate_Added)
{
int nominate_worth = GetPlayerWorthRTV_boost_(param1); int nominate_worth = GetPlayerWorthRTV_boost_(param1);
PrintToChatAll("[NE] %t", "Map Nominated", name, map, nominate_worth);
if (result == Nominate_Added)
{
if (Leader_Is(param1))
{
PrintToChatAll("[NE] %N has nominated %s (%i Nomination Boost Leader).", param1, map, 999);
}
else
{
PrintToChatAll("[NE] %N has nominated %s (%i Nomination Boost).", param1, map, nominate_worth);
}
} }
else if(result == Nominate_Replaced) else if(result == Nominate_Replaced)
{ {
PrintToChatAll("[NE] %t", "Map Nomination Changed", name, map); if (Leader_Is(param1))
{
PrintToChatAll("[NE] %N has changed their nomination to %s (%i Nomination Boost Leader).", param1, map, 999);
} }
else
LogMessage("%s nominated %s", name, map); {
PrintToChatAll("[NE] %N has changed their nomination to %s (%i Nomination Boost).", param1, map, nominate_worth);
}
}
//LogMessage("%s nominated %s", name, map);
g_Player_NominationDelay[param1] = GetTime() + GetConVarInt(g_Cvar_NominateDelay); g_Player_NominationDelay[param1] = GetTime() + GetConVarInt(g_Cvar_NominateDelay);
} }
} }
case MenuAction_DrawItem: case MenuAction_DrawItem:
{ {
static char map[PLATFORM_MAX_PATH]; char map_before_fix[PLATFORM_MAX_PATH];
GetMenuItem(menu, param2, map, sizeof(map)); GetMenuItem(menu, param2, map_before_fix, sizeof(map_before_fix));
int status; char map[PLATFORM_MAX_PATH];
if(GetTrieValue(g_mapTrie, map, status)) if (SplitString(map_before_fix, " ", map, sizeof(map)) == -1)
{ {
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED) Format(map, sizeof(map), map_before_fix);
{
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
{
return ITEMDRAW_DISABLED;
} }
if(AreRestrictionsActive() && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS) //2026 march 20th: if map already is admin or leader nominated we itemdraw disable
{ int arraySize = ByteCountToCells(PLATFORM_MAX_PATH);
return ITEMDRAW_DISABLED; ArrayList MapList = CreateArray(arraySize);
} ArrayList OwnerList = CreateArray();
GetNominatedMapList(MapList, OwnerList);
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED) for (int j = 0; j < GetArraySize(MapList); j++)
{ {
char mapIterated[128];
GetArrayString(MapList, j, mapIterated, sizeof(mapIterated));
if (StrEqual(map, mapIterated))
{
int owner = GetArrayCell(OwnerList, j);
if (!owner || Leader_Is(owner))
{
delete MapList;
delete OwnerList;
return ITEMDRAW_DISABLED; return ITEMDRAW_DISABLED;
} }
} }
} }
delete MapList;
delete OwnerList;
if (GetMapCooldownTime(map) > GetTime()) if (GetMapCooldownTime(map) > GetTime())
{ {
return ITEMDRAW_DISABLED; return ITEMDRAW_DISABLED;
@ -1294,32 +1231,6 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
Format(buffer, sizeof(buffer), "%s (%T)", buffer, "VIP Restriction", param1); Format(buffer, sizeof(buffer), "%s (%T)", buffer, "VIP Restriction", param1);
} }
int status;
if(GetTrieValue(g_mapTrie, map, status))
{
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
{
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
{
Format(display, sizeof(display), "%s (%T)", buffer, "Current Map", param1);
return RedrawMenuItem(display);
}
if(RestrictionsActive && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
{
int Cooldown = GetMapCooldown(map);
Format(display, sizeof(display), "%s (%T %d)", buffer, "Recently Played", param1, Cooldown);
return RedrawMenuItem(display);
}
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
{
Format(display, sizeof(display), "%s (%T)", buffer, "Nominated", param1);
return RedrawMenuItem(display);
}
}
}
int Cooldown = GetMapCooldownTime(map); int Cooldown = GetMapCooldownTime(map);
if(Cooldown > GetTime()) if(Cooldown > GetTime())
{ {
@ -1406,13 +1317,6 @@ stock bool IsNominateAllowed(int client)
CReplyToCommand(client, "[NE] %t", "Next Map", map); CReplyToCommand(client, "[NE] %t", "Next Map", map);
return false; return false;
} }
/*
case CanNominate_No_VoteFull:
{
CReplyToCommand(client, "[NE] %t", "Max Nominations");
return false;
}
*/
} }
return true; return true;
@ -1455,8 +1359,6 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
return 0; return 0;
} }
SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
PrintToChat(param1, "[NE] %t", "Map Inserted", map); PrintToChat(param1, "[NE] %t", "Map Inserted", map);
LogAction(param1, -1, "\"%L\" inserted map \"%s\".", param1, map); LogAction(param1, -1, "\"%L\" inserted map \"%s\".", param1, map);
@ -1527,7 +1429,6 @@ public int Native_PushMapIntoNominationPool(Handle plugin, int numArgs)
ShiftArrayUp(g_MapList, 0); ShiftArrayUp(g_MapList, 0);
SetArrayString(g_MapList, 0, map); SetArrayString(g_MapList, 0, map);
UpdateMapTrie();
UpdateMapMenus(); UpdateMapMenus();
return 0; return 0;
@ -1551,7 +1452,6 @@ public int Native_PushMapsIntoNominationPool(Handle plugin, int numArgs)
delete maps; delete maps;
UpdateMapTrie();
UpdateMapMenus(); UpdateMapMenus();
return 0; return 0;
@ -1568,7 +1468,6 @@ public int Native_RemoveMapFromNominationPool(Handle plugin, int numArgs)
if ((idx = FindStringInArray(g_MapList, map)) != -1) if ((idx = FindStringInArray(g_MapList, map)) != -1)
RemoveFromArray(g_MapList, idx); RemoveFromArray(g_MapList, idx);
UpdateMapTrie();
UpdateMapMenus(); UpdateMapMenus();
return 0; return 0;
@ -1591,7 +1490,6 @@ public int Native_RemoveMapsFromNominationPool(Handle plugin, int numArgs)
delete maps; delete maps;
UpdateMapTrie();
UpdateMapMenus(); UpdateMapMenus();
return 0; return 0;

View File

@ -323,7 +323,7 @@ void AttemptRTV(int client)
if (g_Voted[client]) if (g_Voted[client])
{ {
ReplyToCommand(client, "[RTVE] %t", "Already Voted", Votes, g_VotesNeeded, GetPlayerWorthRTV_boost_(client)); ReplyToCommand(client, "[RTVE] You have already voted to Rock the Vote. (%i/%i Votes. (%i RTV boost))", Votes, g_VotesNeeded, GetPlayerWorthRTV_boost_(client));
return; return;
} }
@ -334,7 +334,7 @@ void AttemptRTV(int client)
Votes = get_voted_rtv(); Votes = get_voted_rtv();
PrintToChatAll("[RTVE] %t", "RTV Requested", name, Votes, g_VotesNeeded, GetPlayerWorthRTV_boost_(client)); PrintToChatAll("[RTVE] %s wants to rock the vote. (%i/%i RTV reached) (%i RTV boost).", name, Votes, g_VotesNeeded, GetPlayerWorthRTV_boost_(client));
if (Votes >= g_VotesNeeded) if (Votes >= g_VotesNeeded)
{ {