diff --git a/mapchooser_extended/scripting/mapchooser_extended.sp b/mapchooser_extended/scripting/mapchooser_extended.sp index a565d1af..11bf7c20 100644 --- a/mapchooser_extended/scripting/mapchooser_extended.sp +++ b/mapchooser_extended/scripting/mapchooser_extended.sp @@ -2286,7 +2286,7 @@ public int Native_GetMapGroupRestriction(Handle plugin, int numParams) { // Check if client has nominated a map in the same group and can change their nomination bool okay = false; - if(client > 0 && client < MaxClients) + if(client >= 1 && client <= MaxClients) { int index = FindValueInArray(g_NominateOwners, client); if(index != -1) @@ -2322,7 +2322,7 @@ public int Native_GetMapVIPRestriction(Handle plugin, int numParams) GetNativeString(1, map, len+1); // Check if client should bypass vip restrictions - if(client > 0 && client < MaxClients) + if(client >= 1 && client <= MaxClients) { // Client has bypass flag, dont return vip restrictions if(CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_CHEATS)) diff --git a/mapchooser_extended/scripting/nominations_extended.sp b/mapchooser_extended/scripting/nominations_extended.sp index 15e24178..6f90b3c4 100644 --- a/mapchooser_extended/scripting/nominations_extended.sp +++ b/mapchooser_extended/scripting/nominations_extended.sp @@ -903,14 +903,6 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p int mark = GetConVarInt(g_Cvar_MarkCustomMaps); bool official; - int status; - - if(!GetTrieValue(g_mapTrie, map, status)) - { - LogError("Menu selection of item not in trie. Major logic problem somewhere."); - return 0; - } - static char buffer[100]; static char display[150]; @@ -943,25 +935,29 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p Format(buffer, sizeof(buffer), "%s (%T)", buffer, "VIP Restriction", param1); } - if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED) + int status; + if(GetTrieValue(g_mapTrie, map, status)) { - if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT) + if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED) { - Format(display, sizeof(display), "%s (%T)", buffer, "Current Map", param1); - return RedrawMenuItem(display); - } + 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(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); + if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED) + { + Format(display, sizeof(display), "%s (%T)", buffer, "Nominated", param1); + return RedrawMenuItem(display); + } } } @@ -1076,6 +1072,20 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1, static char map[PLATFORM_MAX_PATH]; GetMenuItem(menu, param2, map, sizeof(map)); + if(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_CHEATS, true)) + { + if(AreRestrictionsActive() && ( + GetMapCooldownTime(map) > GetTime() || + GetMapTimeRestriction(map) || + GetMapPlayerRestriction(map) || + GetMapGroupRestriction(map, param1) >= 0 || + GetMapVIPRestriction(map, param1))) + { + PrintToChat(param1, "[NE] You can't nominate this map right now."); + return 0; + } + } + NominateResult result = NominateMap(map, true, 0); if(result > Nominate_Replaced) @@ -1097,18 +1107,7 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1, { if(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_CHEATS, true)) { - static char map[PLATFORM_MAX_PATH]; - GetMenuItem(menu, param2, map, sizeof(map)); - - int status; - if(GetTrieValue(g_mapTrie, map, status)) - { - if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED) - return ITEMDRAW_DISABLED; - } - - if(GetMapTimeRestriction(map) || GetMapPlayerRestriction(map) || GetMapGroupRestriction(map) >= 0) - return ITEMDRAW_DISABLED; + return Handler_MapSelectMenu(menu, action, param1, param2); } return ITEMDRAW_DEFAULT; @@ -1116,82 +1115,7 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1, case MenuAction_DisplayItem: { - if(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_CHEATS, true)) - { - static char map[PLATFORM_MAX_PATH]; - GetMenuItem(menu, param2, map, sizeof(map)); - - static char buffer[100]; - static char display[150]; - - strcopy(buffer, sizeof(buffer), map); - - bool RestrictionsActive = AreRestrictionsActive(); - - 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(RestrictionsActive && Cooldown > GetTime()) - { - int Seconds = Cooldown - GetTime(); - char time[16]; - CustomFormatTime(Seconds, time, sizeof(time)); - Format(display, sizeof(display), "%s (%T %s)", buffer, "Recently Played", param1, time); - return RedrawMenuItem(display); - } - - int TimeRestriction = GetMapTimeRestriction(map); - if(RestrictionsActive && TimeRestriction) - { - Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", TimeRestriction / 60, TimeRestriction % 60); - - return RedrawMenuItem(display); - } - - int PlayerRestriction = GetMapPlayerRestriction(map); - if(RestrictionsActive && PlayerRestriction) - { - if(PlayerRestriction < 0) - Format(display, sizeof(display), "%s (%T)", buffer, "Map Player Restriction", param1, "+", PlayerRestriction * -1); - else - Format(display, sizeof(display), "%s (%T)", buffer, "Map Player Restriction", param1, "-", PlayerRestriction); - - return RedrawMenuItem(display); - } - - int GroupRestriction = GetMapGroupRestriction(map); - if(RestrictionsActive && GroupRestriction >= 0) - { - Format(display, sizeof(display), "%s (%T)", buffer, "Map Group Restriction", param1, GroupRestriction); - return RedrawMenuItem(display); - } - } - - return 0; + return Handler_MapSelectMenu(menu, action, param1, param2); } }