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
@@ -54,9 +54,6 @@ public Plugin myinfo =
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_AdminMapList = INVALID_HANDLE;
Menu g_MapMenu;
@@ -64,14 +61,6 @@ Menu g_AdminMapMenu;
int g_mapFileSerial = -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
Handle g_Cvar_MarkCustomMaps = INVALID_HANDLE;
Handle g_Cvar_NominateDelay = INVALID_HANDLE;
@@ -100,8 +89,6 @@ public void OnPluginStart()
g_MapList = 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_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
CreateConVar("ne_version", MCE_VERSION, "Nominations Extended Version", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
g_mapTrie = CreateTrie();
//DB
if (!g_dDatabase)
{
@@ -310,7 +295,6 @@ public void OnConfigsExecuted()
g_NominationDelay = GetTime() + GetConVarInt(g_Cvar_InitialDelay);
UpdateMapTrie();
UpdateMapMenus();
}
@@ -320,61 +304,6 @@ void UpdateMapMenus()
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)
{
if(args == 0)
@@ -412,28 +341,6 @@ public Action Command_Addmap(int client, int args)
{
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);
if(RestrictionsActive && TimeRestriction)
{
@@ -472,8 +379,6 @@ public Action Command_Addmap(int client, int args)
return Plugin_Handled;
}
SetTrieValue(g_mapTrie, mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
CReplyToCommand(client, "%t", "Map Inserted", 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);
}
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);
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
ExcludeMap(mapname, cooldown, mode);
@@ -592,8 +488,7 @@ public Action Command_AddExcludeTime(int client, int args)
mode = StringToInt(buffer);
}
int status;
if(!GetTrieValue(g_mapTrie, mapname, status))
if (FindStringInArray(g_MapList, mapname) == -1)
{
ReplyToCommand(client, "[NE] %t", "Map was not found", mapname);
return Plugin_Handled;
@@ -668,10 +563,8 @@ public Action Command_Nominate(int client, int args)
static char mapname[PLATFORM_MAX_PATH];
GetCmdArg(1, mapname, sizeof(mapname));
int status;
if(!GetTrieValue(g_mapTrie, mapname, status))
if (FindStringInArray(g_MapList, mapname) == -1)
{
//CPrintToChat(client, "%t", "Map was not found", mapname);
ReplyToCommand(client, "Map was not found: %s", mapname);
AttemptNominate(client, mapname);
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))
{
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);
if(RestrictionsActive && VIPRestriction)
{
@@ -744,6 +617,32 @@ public Action Command_Nominate(int client, int args)
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);
if (result == Nominate_InvalidMap)
@@ -762,21 +661,17 @@ public Action Command_Nominate(int client, int args)
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];
GetClientName(client, name, sizeof(name));
int nominate_worth = GetPlayerWorthRTV_boost_(client);
if(result == Nominate_Added)
{
int nominate_worth = GetPlayerWorthRTV_boost_(client);
PrintToChatAll("[NE] %t", "Map Nominated", name, mapname, nominate_worth);
PrintToChatAll("[NE] %N has nominated %s (%i Nomination Boost).", client, mapname, nominate_worth);
}
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);
@@ -845,7 +740,14 @@ void AttemptNominate(int client, const char[] filter = "")
menu = BuildMapMenu(filter, 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);
}
@@ -858,7 +760,7 @@ void AttemptAdminNominate(int client, const char[] filter = "")
if(filter[0])
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);
}
@@ -920,7 +822,6 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
for(int i = 0; i < GetArraySize(MapList); i++)
{
GetArrayString(MapList, i, map, sizeof(map));
if(!filter[0] || StrContains(map, filter, false) != -1)
{
//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;
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 (!owner)
if (!owner || Leader_Is(owner))
{
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++)
{
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));
sm.SetValue(map, 1);
@@ -1045,11 +957,19 @@ Menu BuildMapMenu(const char[] filter, int client)
{
int map_present = 0;
sm.GetValue(map, map_present);
// 1 -> nominated by client. 2 -> nominated by admin. 3 -> nominated by leader
if (map_present == 1)
{
//PrintToChatAll("client %N here. map: %s", client, map);
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])
{
@@ -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
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());
DisplayMenuAtItem(menu, param1, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
return 0;
}
static char map[PLATFORM_MAX_PATH];
char name[MAX_NAME_LENGTH];
GetMenuItem(menu, param2, map, sizeof(map));
@@ -1158,7 +1077,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
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() && (
GetMapTimeRestriction(map) ||
@@ -1190,51 +1109,69 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
PrintToChat(param1, "[NE] %t", "Max Nominations");
return 0;
}
int nominate_worth = GetPlayerWorthRTV_boost_(param1);
//SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
if(result == Nominate_Added)
if (result == Nominate_Added)
{
int nominate_worth = GetPlayerWorthRTV_boost_(param1);
PrintToChatAll("[NE] %t", "Map Nominated", name, map, nominate_worth);
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)
{
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
{
PrintToChatAll("[NE] %N has changed their nomination to %s (%i Nomination Boost).", param1, map, nominate_worth);
}
}
LogMessage("%s nominated %s", name, map);
//LogMessage("%s nominated %s", name, map);
g_Player_NominationDelay[param1] = GetTime() + GetConVarInt(g_Cvar_NominateDelay);
}
}
case MenuAction_DrawItem:
{
static char map[PLATFORM_MAX_PATH];
GetMenuItem(menu, param2, map, sizeof(map));
char map_before_fix[PLATFORM_MAX_PATH];
GetMenuItem(menu, param2, map_before_fix, sizeof(map_before_fix));
int status;
if(GetTrieValue(g_mapTrie, map, status))
char map[PLATFORM_MAX_PATH];
if (SplitString(map_before_fix, " ", map, sizeof(map)) == -1)
{
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
Format(map, sizeof(map), map_before_fix);
}
//2026 march 20th: if map already is admin or leader nominated we itemdraw disable
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(map, mapIterated))
{
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
{
return ITEMDRAW_DISABLED;
}
if(AreRestrictionsActive() && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
{
return ITEMDRAW_DISABLED;
}
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
int owner = GetArrayCell(OwnerList, j);
if (!owner || Leader_Is(owner))
{
delete MapList;
delete OwnerList;
return ITEMDRAW_DISABLED;
}
}
}
delete MapList;
delete OwnerList;
if (GetMapCooldownTime(map) > GetTime())
{
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);
}
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);
if(Cooldown > GetTime())
{
@@ -1406,13 +1317,6 @@ stock bool IsNominateAllowed(int client)
CReplyToCommand(client, "[NE] %t", "Next Map", map);
return false;
}
/*
case CanNominate_No_VoteFull:
{
CReplyToCommand(client, "[NE] %t", "Max Nominations");
return false;
}
*/
}
return true;
@@ -1455,8 +1359,6 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
return 0;
}
SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
PrintToChat(param1, "[NE] %t", "Map Inserted", 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);
SetArrayString(g_MapList, 0, map);
UpdateMapTrie();
UpdateMapMenus();
return 0;
@@ -1551,7 +1452,6 @@ public int Native_PushMapsIntoNominationPool(Handle plugin, int numArgs)
delete maps;
UpdateMapTrie();
UpdateMapMenus();
return 0;
@@ -1568,7 +1468,6 @@ public int Native_RemoveMapFromNominationPool(Handle plugin, int numArgs)
if ((idx = FindStringInArray(g_MapList, map)) != -1)
RemoveFromArray(g_MapList, idx);
UpdateMapTrie();
UpdateMapMenus();
return 0;
@@ -1591,7 +1490,6 @@ public int Native_RemoveMapsFromNominationPool(Handle plugin, int numArgs)
delete maps;
UpdateMapTrie();
UpdateMapMenus();
return 0;