From 5840846119790d3bb96a4be8909e502cfd7e54ec Mon Sep 17 00:00:00 2001 From: jenz Date: Thu, 23 Mar 2023 19:47:48 +0100 Subject: [PATCH] added missing phrase file and hopefully fixed errors thrown by mapchooser --- .../scripting/mapchooser_extended.sp | 41 +++--- .../scripting/nominations_extended.sp | 118 +++++++++--------- .../translations/nominations.phrases.txt | 71 +++++++++++ 3 files changed, 158 insertions(+), 72 deletions(-) create mode 100644 mapchooser_extended/translations/nominations.phrases.txt diff --git a/mapchooser_extended/scripting/mapchooser_extended.sp b/mapchooser_extended/scripting/mapchooser_extended.sp index 3aa4973..75d58f9 100755 --- a/mapchooser_extended/scripting/mapchooser_extended.sp +++ b/mapchooser_extended/scripting/mapchooser_extended.sp @@ -1242,10 +1242,14 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE) RemoveStringFromArray(g_NextMapList, map); /* Notify Nominations that this map is now free */ - Call_StartForward(g_NominationsResetForward); - Call_PushString(map); - Call_PushCell(GetArrayCell(g_NominateOwners, i)); - Call_Finish(); + //2023-03-23 edit to prevent index going out of range + if (GetArraySize(g_NominateOwners) > i) + { + Call_StartForward(g_NominationsResetForward); + Call_PushString(map); + Call_PushCell(GetArrayCell(g_NominateOwners, i)); + Call_Finish(); + } } /* Clear out the rest of the nominations array */ @@ -1256,10 +1260,14 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE) /* These maps shouldn't be excluded from the vote as they weren't really nominated at all */ /* Notify Nominations that this map is now free */ - Call_StartForward(g_NominationsResetForward); - Call_PushString(map); - Call_PushCell(GetArrayCell(g_NominateOwners, i)); - Call_Finish(); + //2023-03-23 edit to prevent index going out of range + if (GetArraySize(g_NominateOwners) > i) + { + Call_StartForward(g_NominationsResetForward); + Call_PushString(map); + Call_PushCell(GetArrayCell(g_NominateOwners, i)); + Call_Finish(); + } } /* There should currently be 'nominationsToAdd' unique maps in the vote */ @@ -2620,14 +2628,17 @@ void CheckMapRestrictions(bool time = false, bool players = false) if (remove) { - Call_StartForward(g_NominationsResetForward); - Call_PushString(map); - Call_PushCell(GetArrayCell(g_NominateOwners, i)); - Call_Finish(); + if (GetArraySize(g_NominateOwners) > i) + { + Call_StartForward(g_NominationsResetForward); + Call_PushString(map); + Call_PushCell(GetArrayCell(g_NominateOwners, i)); + Call_Finish(); - RemoveFromArray(g_NominateList[client], i); - RemoveFromArray(g_NominateOwners, i); - g_NominateCount--; + RemoveFromArray(g_NominateList[client], i); + RemoveFromArray(g_NominateOwners, i); + g_NominateCount--; + } } } } diff --git a/mapchooser_extended/scripting/nominations_extended.sp b/mapchooser_extended/scripting/nominations_extended.sp index b63412a..c24152d 100755 --- a/mapchooser_extended/scripting/nominations_extended.sp +++ b/mapchooser_extended/scripting/nominations_extended.sp @@ -696,15 +696,15 @@ void AttemptNominate(int client, const char[] filter = "") void AttemptAdminNominate(int client, const char[] filter = "") { - if(!client) - return; + if(!client) + return; - Menu menu = g_AdminMapMenu; - if(filter[0]) - menu = BuildAdminMapMenu(filter); + Menu menu = g_AdminMapMenu; + if(filter[0]) + menu = BuildAdminMapMenu(filter); - SetMenuTitle(menu, "%T", "Nominate Title", client); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + SetMenuTitle(menu, "%T", "Nominate Title", client); + DisplayMenu(menu, client, MENU_TIME_FOREVER); } void AttemptAdminRemoveMap(int client, const char[] filter = "") @@ -932,58 +932,62 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p } case MenuAction_Select: { - if(g_Player_NominationDelay[param1] > GetTime()) + //2023-03-22 edit since client sometimes is 0 which fucks up mapchooser + if (param1 > 0 && param1 <= MaxClients && IsClientConnected(param1) && IsClientInGame(param1)) { - 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; + 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)); + + GetClientName(param1, name, MAX_NAME_LENGTH); + + if(AreRestrictionsActive() && ( + GetMapCooldownTime(map) > GetTime() || + GetMapTimeRestriction(map) || + GetMapPlayerRestriction(map) || + GetMapVIPRestriction(map, param1))) + { + PrintToChat(param1, "[NE] You cant nominate this map right now."); + return 0; + } + + NominateResult result = NominateMap(map, false, param1); + + if (result == Nominate_InvalidMap) + { + PrintToChat(param1, "[NE] You already nominated the map %s", map); + return 0; + } + + /* Dont need to check for InvalidMap because the menu did that already */ + if(result == Nominate_AlreadyInVote) + { + PrintToChat(param1, "[NE] %t", "Map Already Nominated"); + return 0; + } + else if(result == Nominate_VoteFull) + { + PrintToChat(param1, "[NE] %t", "Max Nominations"); + return 0; + } + + //SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED); + + if(result == Nominate_Added) + PrintToChatAll("[NE] %t", "Map Nominated", name, map); + else if(result == Nominate_Replaced) + PrintToChatAll("[NE] %t", "Map Nomination Changed", name, map); + + LogMessage("%s nominated %s", name, map); + g_Player_NominationDelay[param1] = GetTime() + GetConVarInt(g_Cvar_NominateDelay); } - - static char map[PLATFORM_MAX_PATH]; - char name[MAX_NAME_LENGTH]; - GetMenuItem(menu, param2, map, sizeof(map)); - - GetClientName(param1, name, MAX_NAME_LENGTH); - - if(AreRestrictionsActive() && ( - GetMapCooldownTime(map) > GetTime() || - GetMapTimeRestriction(map) || - GetMapPlayerRestriction(map) || - GetMapVIPRestriction(map, param1))) - { - PrintToChat(param1, "[NE] You cant nominate this map right now."); - return 0; - } - - NominateResult result = NominateMap(map, false, param1); - - if (result == Nominate_InvalidMap) - { - PrintToChat(param1, "[NE] You already nominated the map %s", map); - return 0; - } - - /* Dont need to check for InvalidMap because the menu did that already */ - if(result == Nominate_AlreadyInVote) - { - PrintToChat(param1, "[NE] %t", "Map Already Nominated"); - return 0; - } - else if(result == Nominate_VoteFull) - { - PrintToChat(param1, "[NE] %t", "Max Nominations"); - return 0; - } - - //SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED); - - if(result == Nominate_Added) - PrintToChatAll("[NE] %t", "Map Nominated", name, map); - else if(result == Nominate_Replaced) - PrintToChatAll("[NE] %t", "Map Nomination Changed", name, map); - - LogMessage("%s nominated %s", name, map); - g_Player_NominationDelay[param1] = GetTime() + GetConVarInt(g_Cvar_NominateDelay); } case MenuAction_DrawItem: diff --git a/mapchooser_extended/translations/nominations.phrases.txt b/mapchooser_extended/translations/nominations.phrases.txt new file mode 100644 index 0000000..d5233f9 --- /dev/null +++ b/mapchooser_extended/translations/nominations.phrases.txt @@ -0,0 +1,71 @@ +"Phrases" +{ + "Already Nominated" + { + "en" "You have already nominated a map." + } + + "Max Nominations" + { + "en" "The maximum allowed nominations has been reached." + } + + "Map Already In Vote" + { + "#format" "{1:s}" + "en" "Map '{1}' already in the nominations list." + } + + "Map Inserted" + { + "#format" "{1:s}" + "en" "Map '{1}' added to the nominations list." + } + + "Map Already Nominated" + { + "en" "The map you chose has already been nominated." + } + + "Map Nominated" + { + "#format" "{1:s},{2:s}" + "en" "{1} has nominated {2}." + } + + "Map Nomination Changed" + { + "#format" "{1:s},{2:s}" + "en" "{1} has changed their nomination to {2}." + } + + "Nominate Title" + { + "en" "Nominate Map:" + } + + "Can't Nominate Current Map" + { + "en" "The map you chose is the current map and cannot be nominated" + } + + "Map in Exclude List" + { + "en" "The map you chose was recently played and cannot be nominated" + } + + "Current Map" + { + "en" "Current Map" + } + + "Recently Played" + { + "en" "Recently Played" + } + + "Nominated" + { + "en" "Nominated" + } +}