forked from UNLOZE/sm-plugins
WIP
This commit is contained in:
@@ -280,6 +280,8 @@ public Action Command_Addmap(int client, int args)
|
||||
|
||||
if(!CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_CHEATS, true))
|
||||
{
|
||||
bool RestrictionsActive = AreRestrictionsActive();
|
||||
|
||||
int status;
|
||||
if(GetTrieValue(g_mapTrie, mapname, status))
|
||||
{
|
||||
@@ -288,7 +290,7 @@ public Action Command_Addmap(int client, int args)
|
||||
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
|
||||
CPrintToChat(client, "[NE] %t", "Can't Nominate Current Map");
|
||||
|
||||
if((status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
||||
if(RestrictionsActive && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
||||
{
|
||||
int Cooldown = GetMapCooldown(mapname);
|
||||
CPrintToChat(client, "[NE] %t (%d)", "Map in Exclude List", Cooldown);
|
||||
@@ -302,7 +304,7 @@ public Action Command_Addmap(int client, int args)
|
||||
}
|
||||
|
||||
int TimeRestriction = GetMapTimeRestriction(mapname);
|
||||
if(TimeRestriction)
|
||||
if(RestrictionsActive && TimeRestriction)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate Time Error", RoundToFloor(float(TimeRestriction / 60)), TimeRestriction % 60);
|
||||
|
||||
@@ -310,7 +312,7 @@ public Action Command_Addmap(int client, int args)
|
||||
}
|
||||
|
||||
int PlayerRestriction = GetMapPlayerRestriction(mapname);
|
||||
if(PlayerRestriction)
|
||||
if(RestrictionsActive && PlayerRestriction)
|
||||
{
|
||||
if(PlayerRestriction < 0)
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate MinPlayers Error", PlayerRestriction * -1);
|
||||
@@ -321,7 +323,7 @@ public Action Command_Addmap(int client, int args)
|
||||
}
|
||||
|
||||
int GroupRestriction = GetMapGroupRestriction(mapname);
|
||||
if(GroupRestriction >= 0)
|
||||
if(RestrictionsActive && GroupRestriction >= 0)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate Group Error", GroupRestriction);
|
||||
return Plugin_Handled;
|
||||
@@ -485,6 +487,7 @@ 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))
|
||||
{
|
||||
@@ -493,12 +496,14 @@ public Action Command_Nominate(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
bool RestrictionsActive = AreRestrictionsActive();
|
||||
|
||||
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
||||
{
|
||||
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
|
||||
CPrintToChat(client, "[NE] %t", "Can't Nominate Current Map");
|
||||
|
||||
if(((status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS) && AreRestrictionsActive())
|
||||
if(RestrictionsActive && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
||||
{
|
||||
int Cooldown = GetMapCooldown(mapname);
|
||||
CPrintToChat(client, "[NE] %t (%d)", "Map in Exclude List", Cooldown);
|
||||
@@ -511,7 +516,7 @@ public Action Command_Nominate(int client, int args)
|
||||
}
|
||||
|
||||
bool VIPRestriction = GetMapVIPRestriction(mapname, client);
|
||||
if((VIPRestriction) && AreRestrictionsActive())
|
||||
if(RestrictionsActive && VIPRestriction)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate VIP Error");
|
||||
|
||||
@@ -519,7 +524,7 @@ public Action Command_Nominate(int client, int args)
|
||||
}
|
||||
|
||||
int TimeRestriction = GetMapTimeRestriction(mapname);
|
||||
if((TimeRestriction) && AreRestrictionsActive())
|
||||
if(RestrictionsActive && TimeRestriction)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate Time Error", RoundToFloor(float(TimeRestriction / 60)), TimeRestriction % 60);
|
||||
|
||||
@@ -527,7 +532,7 @@ public Action Command_Nominate(int client, int args)
|
||||
}
|
||||
|
||||
int PlayerRestriction = GetMapPlayerRestriction(mapname);
|
||||
if((PlayerRestriction) && AreRestrictionsActive())
|
||||
if(RestrictionsActive && PlayerRestriction)
|
||||
{
|
||||
if(PlayerRestriction < 0)
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate MinPlayers Error", PlayerRestriction * -1);
|
||||
@@ -538,7 +543,7 @@ public Action Command_Nominate(int client, int args)
|
||||
}
|
||||
|
||||
int GroupRestriction = GetMapGroupRestriction(mapname, client);
|
||||
if((GroupRestriction >= 0) && AreRestrictionsActive())
|
||||
if(RestrictionsActive && GroupRestriction >= 0)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate Group Error", GroupRestriction);
|
||||
return Plugin_Handled;
|
||||
@@ -749,7 +754,12 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
|
||||
GetClientName(param1, name, MAX_NAME_LENGTH);
|
||||
|
||||
if((GetMapTimeRestriction(map) || GetMapPlayerRestriction(map) || GetMapGroupRestriction(map, param1) >= 0 || GetMapVIPRestriction(map, param1)) && AreRestrictionsActive())
|
||||
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;
|
||||
@@ -800,7 +810,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
|
||||
if(((status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS) && AreRestrictionsActive())
|
||||
if(AreRestrictionsActive() && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
@@ -811,8 +821,15 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
}
|
||||
}
|
||||
|
||||
if((GetMapTimeRestriction(map) || GetMapPlayerRestriction(map) || GetMapGroupRestriction(map, param1) >= 0 || GetMapVIPRestriction(map, param1)) && AreRestrictionsActive())
|
||||
if(AreRestrictionsActive() && (
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetMapGroupRestriction(map, param1) >= 0 ||
|
||||
GetMapVIPRestriction(map, param1)))
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
|
||||
return ITEMDRAW_DEFAULT;
|
||||
}
|
||||
@@ -857,8 +874,10 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
else
|
||||
strcopy(buffer, sizeof(buffer), map);
|
||||
|
||||
bool RestrictionsActive = AreRestrictionsActive();
|
||||
|
||||
bool VIPRestriction = GetMapVIPRestriction(map);
|
||||
if((VIPRestriction) && AreRestrictionsActive())
|
||||
if(RestrictionsActive && VIPRestriction)
|
||||
{
|
||||
Format(buffer, sizeof(buffer), "%s (%T)", buffer, "VIP Restriction", param1);
|
||||
}
|
||||
@@ -871,7 +890,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
return RedrawMenuItem(display);
|
||||
}
|
||||
|
||||
if(((status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS) && AreRestrictionsActive())
|
||||
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);
|
||||
@@ -886,14 +905,14 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
}
|
||||
|
||||
int TimeRestriction = GetMapTimeRestriction(map);
|
||||
if((TimeRestriction) && AreRestrictionsActive())
|
||||
if(RestrictionsActive && TimeRestriction)
|
||||
{
|
||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", RoundToFloor(float(TimeRestriction / 60)), TimeRestriction % 60);
|
||||
return RedrawMenuItem(display);
|
||||
}
|
||||
|
||||
int PlayerRestriction = GetMapPlayerRestriction(map);
|
||||
if((PlayerRestriction) && AreRestrictionsActive())
|
||||
if(RestrictionsActive && PlayerRestriction)
|
||||
{
|
||||
if(PlayerRestriction < 0)
|
||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Player Restriction", param1, "+", PlayerRestriction * -1);
|
||||
@@ -904,13 +923,13 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
|
||||
}
|
||||
|
||||
int GroupRestriction = GetMapGroupRestriction(map, param1);
|
||||
if((GroupRestriction >= 0) && AreRestrictionsActive())
|
||||
if(RestrictionsActive && GroupRestriction >= 0)
|
||||
{
|
||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Group Restriction", param1, GroupRestriction);
|
||||
return RedrawMenuItem(display);
|
||||
}
|
||||
|
||||
if((VIPRestriction) && AreRestrictionsActive())
|
||||
if(RestrictionsActive && VIPRestriction)
|
||||
{
|
||||
return RedrawMenuItem(buffer);
|
||||
}
|
||||
@@ -1036,6 +1055,8 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
||||
|
||||
strcopy(buffer, sizeof(buffer), map);
|
||||
|
||||
bool RestrictionsActive = AreRestrictionsActive();
|
||||
|
||||
int status;
|
||||
if(GetTrieValue(g_mapTrie, map, status))
|
||||
{
|
||||
@@ -1047,7 +1068,7 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
||||
return RedrawMenuItem(display);
|
||||
}
|
||||
|
||||
if((status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
||||
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);
|
||||
@@ -1063,7 +1084,7 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
||||
}
|
||||
|
||||
int TimeRestriction = GetMapTimeRestriction(map);
|
||||
if(TimeRestriction)
|
||||
if(RestrictionsActive && TimeRestriction)
|
||||
{
|
||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", RoundToFloor(float(TimeRestriction / 60)), TimeRestriction % 60);
|
||||
|
||||
@@ -1071,7 +1092,7 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
||||
}
|
||||
|
||||
int PlayerRestriction = GetMapPlayerRestriction(map);
|
||||
if(PlayerRestriction)
|
||||
if(RestrictionsActive && PlayerRestriction)
|
||||
{
|
||||
if(PlayerRestriction < 0)
|
||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Player Restriction", param1, "+", PlayerRestriction * -1);
|
||||
@@ -1082,7 +1103,7 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
||||
}
|
||||
|
||||
int GroupRestriction = GetMapGroupRestriction(map);
|
||||
if(GroupRestriction >= 0)
|
||||
if(RestrictionsActive && GroupRestriction >= 0)
|
||||
{
|
||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Group Restriction", param1, GroupRestriction);
|
||||
return RedrawMenuItem(display);
|
||||
@@ -1214,3 +1235,15 @@ stock int GetVIPTimeRestriction()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
stock void CustomFormatTime(int seconds, char[] buffer, int maxlen)
|
||||
{
|
||||
if(seconds <= 60)
|
||||
Format(buffer, maxlen, "%ds", seconds);
|
||||
else if(seconds <= 3600)
|
||||
Format(buffer, maxlen, "%dm", RoundToNearest(seconds / 60));
|
||||
else if(seconds <= 10*3600)
|
||||
Format(buffer, maxlen, "%dh%dm", RoundToFloor(seconds / 3600), RoundToNearest((seconds % 3600) / 60));
|
||||
else
|
||||
Format(buffer, maxlen, "%dh", RoundToNearest(seconds / 3600));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user