mapchooser: fix admin nominate menu restrictions
This commit is contained in:
parent
99f34ca3d6
commit
3022d22197
@ -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
|
// Check if client has nominated a map in the same group and can change their nomination
|
||||||
bool okay = false;
|
bool okay = false;
|
||||||
if(client > 0 && client < MaxClients)
|
if(client >= 1 && client <= MaxClients)
|
||||||
{
|
{
|
||||||
int index = FindValueInArray(g_NominateOwners, client);
|
int index = FindValueInArray(g_NominateOwners, client);
|
||||||
if(index != -1)
|
if(index != -1)
|
||||||
@ -2322,7 +2322,7 @@ public int Native_GetMapVIPRestriction(Handle plugin, int numParams)
|
|||||||
GetNativeString(1, map, len+1);
|
GetNativeString(1, map, len+1);
|
||||||
|
|
||||||
// Check if client should bypass vip restrictions
|
// 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
|
// Client has bypass flag, dont return vip restrictions
|
||||||
if(CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_CHEATS))
|
if(CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_CHEATS))
|
||||||
|
@ -903,14 +903,6 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
|||||||
int mark = GetConVarInt(g_Cvar_MarkCustomMaps);
|
int mark = GetConVarInt(g_Cvar_MarkCustomMaps);
|
||||||
bool official;
|
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 buffer[100];
|
||||||
static char display[150];
|
static char display[150];
|
||||||
|
|
||||||
@ -943,6 +935,9 @@ 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_DISABLED) == MAPSTATUS_DISABLED)
|
||||||
{
|
{
|
||||||
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
|
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
|
||||||
@ -964,6 +959,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
|||||||
return RedrawMenuItem(display);
|
return RedrawMenuItem(display);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int Cooldown = GetMapCooldownTime(map);
|
int Cooldown = GetMapCooldownTime(map);
|
||||||
if(RestrictionsActive && Cooldown > GetTime())
|
if(RestrictionsActive && Cooldown > GetTime())
|
||||||
@ -1076,6 +1072,20 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
|||||||
static char map[PLATFORM_MAX_PATH];
|
static char map[PLATFORM_MAX_PATH];
|
||||||
GetMenuItem(menu, param2, map, sizeof(map));
|
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);
|
NominateResult result = NominateMap(map, true, 0);
|
||||||
|
|
||||||
if(result > Nominate_Replaced)
|
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))
|
if(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_CHEATS, true))
|
||||||
{
|
{
|
||||||
static char map[PLATFORM_MAX_PATH];
|
return Handler_MapSelectMenu(menu, action, param1, param2);
|
||||||
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 ITEMDRAW_DEFAULT;
|
return ITEMDRAW_DEFAULT;
|
||||||
@ -1116,82 +1115,7 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
|||||||
|
|
||||||
case MenuAction_DisplayItem:
|
case MenuAction_DisplayItem:
|
||||||
{
|
{
|
||||||
if(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_CHEATS, true))
|
return Handler_MapSelectMenu(menu, action, param1, param2);
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user