rehawl of mapchooser so clients can have multiple nominations where the maps with most nominations get into the vote
This commit is contained in:
parent
1c851906db
commit
987c643838
1659
mapchooser_extended/scripting/mapchooser_extended.sp
Normal file → Executable file
1659
mapchooser_extended/scripting/mapchooser_extended.sp
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
774
mapchooser_extended/scripting/nominations_extended.sp
Normal file → Executable file
774
mapchooser_extended/scripting/nominations_extended.sp
Normal file → Executable file
@ -187,14 +187,7 @@ public void OnConfigsExecuted()
|
||||
|
||||
void UpdateMapMenus()
|
||||
{
|
||||
if(g_MapMenu != INVALID_HANDLE)
|
||||
delete g_MapMenu;
|
||||
|
||||
g_MapMenu = BuildMapMenu("");
|
||||
|
||||
if(g_AdminMapMenu != INVALID_HANDLE)
|
||||
delete g_AdminMapMenu;
|
||||
|
||||
g_MapMenu = BuildMapMenu("", 0);
|
||||
g_AdminMapMenu = BuildAdminMapMenu("");
|
||||
}
|
||||
|
||||
@ -243,17 +236,16 @@ void UpdateMapTrie()
|
||||
|
||||
public void OnNominationRemoved(const char[] map, int owner)
|
||||
{
|
||||
int status;
|
||||
int status;
|
||||
/* Is the map in our list? */
|
||||
if(!GetTrieValue(g_mapTrie, map, status))
|
||||
return;
|
||||
|
||||
/* 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;
|
||||
|
||||
/* Was the map disabled due to being nominated */
|
||||
if((status & MAPSTATUS_EXCLUDE_NOMINATED) != MAPSTATUS_EXCLUDE_NOMINATED)
|
||||
return;
|
||||
|
||||
SetTrieValue(g_mapTrie, map, MAPSTATUS_ENABLED);
|
||||
SetTrieValue(g_mapTrie, map, MAPSTATUS_ENABLED);
|
||||
}
|
||||
|
||||
public Action Command_Addmap(int client, int args)
|
||||
@ -290,7 +282,7 @@ public Action Command_Addmap(int client, int args)
|
||||
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
||||
{
|
||||
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
|
||||
CPrintToChat(client, "[NE] %t", "Can't Nominate Current Map");
|
||||
CPrintToChat(client, "[NE] %t", "Cant Nominate Current Map");
|
||||
|
||||
if(RestrictionsActive && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
||||
{
|
||||
@ -345,7 +337,7 @@ public Action Command_Addmap(int client, int args)
|
||||
|
||||
if(result > Nominate_Replaced)
|
||||
{
|
||||
/* We assume already in vote is the casue because the maplist does a Map Validity check and we forced, so it can't be full */
|
||||
/* We assume already in vote is the casue because the maplist does a Map Validity check and we forced, so it cant be full */
|
||||
CReplyToCommand(client, "%t", "Map Already In Vote", mapname);
|
||||
|
||||
return Plugin_Handled;
|
||||
@ -388,7 +380,7 @@ public Action Command_Removemap(int client, int args)
|
||||
|
||||
if(!RemoveNominationByMap(mapname))
|
||||
{
|
||||
CReplyToCommand(client, "This map isn't nominated.", mapname);
|
||||
CReplyToCommand(client, "This map isnt nominated.", mapname);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@ -523,130 +515,135 @@ public Action Command_Say(int client, int args)
|
||||
|
||||
public Action Command_Nominate(int client, int args)
|
||||
{
|
||||
if(!client || !IsNominateAllowed(client))
|
||||
return Plugin_Handled;
|
||||
if(!client || !IsNominateAllowed(client))
|
||||
return Plugin_Handled;
|
||||
|
||||
if(g_NominationDelay > GetTime())
|
||||
{
|
||||
PrintToChat(client, "[NE] Nominations will be unlocked in %d seconds", g_NominationDelay - GetTime());
|
||||
return Plugin_Handled;
|
||||
}
|
||||
if(g_NominationDelay > GetTime())
|
||||
{
|
||||
PrintToChat(client, "[NE] Nominations will be unlocked in %d seconds", g_NominationDelay - GetTime());
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if(args == 0)
|
||||
{
|
||||
AttemptNominate(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
if(args == 0)
|
||||
{
|
||||
AttemptNominate(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if(g_Player_NominationDelay[client] > GetTime())
|
||||
{
|
||||
PrintToChat(client, "[NE] Please wait %d seconds before you can nominate again", g_Player_NominationDelay[client] - GetTime());
|
||||
return Plugin_Handled;
|
||||
}
|
||||
if(g_Player_NominationDelay[client] > GetTime())
|
||||
{
|
||||
PrintToChat(client, "[NE] Please wait %d seconds before you can nominate again", g_Player_NominationDelay[client] - GetTime());
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
static char mapname[PLATFORM_MAX_PATH];
|
||||
GetCmdArg(1, mapname, sizeof(mapname));
|
||||
static char mapname[PLATFORM_MAX_PATH];
|
||||
GetCmdArg(1, mapname, sizeof(mapname));
|
||||
|
||||
|
||||
int status;
|
||||
if(!GetTrieValue(g_mapTrie, mapname, status))
|
||||
{
|
||||
CPrintToChat(client, "%t", "Map was not found", mapname);
|
||||
AttemptNominate(client, mapname);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
int status;
|
||||
if(!GetTrieValue(g_mapTrie, mapname, status))
|
||||
{
|
||||
CPrintToChat(client, "%t", "Map was not found", mapname);
|
||||
AttemptNominate(client, mapname);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
bool RestrictionsActive = AreRestrictionsActive();
|
||||
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_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(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");
|
||||
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
|
||||
CPrintToChat(client, "[NE] %t", "Map Already Nominated");
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int Cooldown = GetMapCooldownTime(mapname);
|
||||
if(RestrictionsActive && Cooldown > GetTime())
|
||||
{
|
||||
int Seconds = Cooldown - GetTime();
|
||||
CPrintToChat(client, "[NE] %t", "Map Cooldown Time Error", Seconds / 3600, (Seconds % 3600) / 60);
|
||||
int Cooldown = GetMapCooldownTime(mapname);
|
||||
if(RestrictionsActive && Cooldown > GetTime())
|
||||
{
|
||||
int Seconds = Cooldown - GetTime();
|
||||
CPrintToChat(client, "[NE] %t", "Map Cooldown Time Error", Seconds / 3600, (Seconds % 3600) / 60);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
bool VIPRestriction = GetMapVIPRestriction(mapname, client);
|
||||
if(RestrictionsActive && VIPRestriction)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate VIP Error");
|
||||
bool VIPRestriction = GetMapVIPRestriction(mapname, client);
|
||||
if(RestrictionsActive && VIPRestriction)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate VIP Error");
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int TimeRestriction = GetMapTimeRestriction(mapname);
|
||||
if(RestrictionsActive && TimeRestriction)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate Time Error", TimeRestriction / 60, TimeRestriction % 60);
|
||||
int TimeRestriction = GetMapTimeRestriction(mapname);
|
||||
if(RestrictionsActive && TimeRestriction)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate Time Error", TimeRestriction / 60, TimeRestriction % 60);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int PlayerRestriction = GetMapPlayerRestriction(mapname);
|
||||
if(RestrictionsActive && PlayerRestriction)
|
||||
{
|
||||
if(PlayerRestriction < 0)
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate MinPlayers Error", PlayerRestriction * -1);
|
||||
else
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate MaxPlayers Error", PlayerRestriction);
|
||||
int PlayerRestriction = GetMapPlayerRestriction(mapname);
|
||||
if(RestrictionsActive && PlayerRestriction)
|
||||
{
|
||||
if(PlayerRestriction < 0)
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate MinPlayers Error", PlayerRestriction * -1);
|
||||
else
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate MaxPlayers Error", PlayerRestriction);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
int GroupRestriction = GetMapGroupRestriction(mapname, client);
|
||||
if(RestrictionsActive && GroupRestriction >= 0)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate Group Error", GroupRestriction);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
int GroupRestriction = GetMapGroupRestriction(mapname, client);
|
||||
if(RestrictionsActive && GroupRestriction >= 0)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "Map Nominate Group Error", GroupRestriction);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
NominateResult result = NominateMap(mapname, false, client);
|
||||
NominateResult result = NominateMap(mapname, false, client);
|
||||
|
||||
if(result > Nominate_Replaced)
|
||||
{
|
||||
if(result == Nominate_AlreadyInVote)
|
||||
CPrintToChat(client, "[NE] %t", "Map Already In Vote", mapname);
|
||||
else if(result == Nominate_VoteFull)
|
||||
CPrintToChat(client, "[NE] %t", "Max Nominations");
|
||||
if (result == Nominate_InvalidMap)
|
||||
{
|
||||
CPrintToChat(client, "[NE] %t", "You already nominated the map ", mapname);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
if(result > Nominate_Replaced)
|
||||
{
|
||||
if(result == Nominate_AlreadyInVote)
|
||||
CPrintToChat(client, "[NE] %t", "Map Already In Vote", mapname);
|
||||
else if(result == Nominate_VoteFull)
|
||||
CPrintToChat(client, "[NE] %t", "Max Nominations");
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
/* Map was nominated! - Disable the menu item and update the trie */
|
||||
/* Map was nominated! - Disable the menu item and update the trie */
|
||||
|
||||
SetTrieValue(g_mapTrie, mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
|
||||
//SetTrieValue(g_mapTrie, mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
|
||||
|
||||
static char name[MAX_NAME_LENGTH];
|
||||
GetClientName(client, name, sizeof(name));
|
||||
static char name[MAX_NAME_LENGTH];
|
||||
GetClientName(client, name, sizeof(name));
|
||||
|
||||
if(result == Nominate_Added)
|
||||
PrintToChatAll("[NE] %t", "Map Nominated", name, mapname);
|
||||
else if(result == Nominate_Replaced)
|
||||
PrintToChatAll("[NE] %t", "Map Nomination Changed", name, mapname);
|
||||
if(result == Nominate_Added)
|
||||
PrintToChatAll("[NE] %t", "Map Nominated", name, mapname);
|
||||
else if(result == Nominate_Replaced)
|
||||
PrintToChatAll("[NE] %t", "Map Nomination Changed", name, mapname);
|
||||
|
||||
LogMessage("%s nominated %s", name, mapname);
|
||||
LogMessage("%s nominated %s", name, mapname);
|
||||
|
||||
g_Player_NominationDelay[client] = GetTime() + GetConVarInt(g_Cvar_NominateDelay);
|
||||
g_Player_NominationDelay[client] = GetTime() + GetConVarInt(g_Cvar_NominateDelay);
|
||||
|
||||
return Plugin_Continue;
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action Command_NominateList(int client, int args)
|
||||
@ -701,15 +698,14 @@ public int Handler_NominateListMenu(Menu menu, MenuAction action, int param1, in
|
||||
|
||||
void AttemptNominate(int client, const char[] filter = "")
|
||||
{
|
||||
if(!client)
|
||||
return;
|
||||
if(!client)
|
||||
return;
|
||||
|
||||
Menu menu = g_MapMenu;
|
||||
if(filter[0])
|
||||
menu = BuildMapMenu(filter);
|
||||
Menu menu = g_MapMenu;
|
||||
menu = BuildMapMenu(filter, client);
|
||||
|
||||
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 AttemptAdminNominate(int client, const char[] filter = "")
|
||||
@ -786,25 +782,64 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
|
||||
return true;
|
||||
}
|
||||
|
||||
Menu BuildMapMenu(const char[] filter)
|
||||
Menu BuildMapMenu(const char[] filter, int client)
|
||||
{
|
||||
Menu menu = CreateMenu(Handler_MapSelectMenu, MENU_ACTIONS_DEFAULT|MenuAction_DrawItem|MenuAction_DisplayItem);
|
||||
Menu menu = CreateMenu(Handler_MapSelectMenu, MENU_ACTIONS_DEFAULT|MenuAction_DrawItem|MenuAction_DisplayItem);
|
||||
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
static char map[PLATFORM_MAX_PATH * 2];
|
||||
|
||||
for(int i = 0; i < GetArraySize(g_MapList); i++)
|
||||
{
|
||||
GetArrayString(g_MapList, i, map, sizeof(map));
|
||||
int arraySize = ByteCountToCells(PLATFORM_MAX_PATH);
|
||||
ArrayList MapList = CreateArray(arraySize);
|
||||
ArrayList OwnerList = CreateArray();
|
||||
StringMap sm = new StringMap();
|
||||
|
||||
if(!filter[0] || StrContains(map, filter, false) != -1)
|
||||
{
|
||||
AddMenuItem(menu, map, map);
|
||||
}
|
||||
}
|
||||
GetNominatedMapList(MapList, OwnerList);
|
||||
bool nominated_maps = true;
|
||||
if (!GetArraySize(MapList))
|
||||
{
|
||||
nominated_maps = false;
|
||||
}
|
||||
|
||||
SetMenuExitButton(menu, true);
|
||||
if (client != 0 && nominated_maps)
|
||||
{
|
||||
for(int j = 0; j < GetArraySize(MapList); j++)
|
||||
{
|
||||
int owner = GetArrayCell(OwnerList, j);
|
||||
if (client == owner)
|
||||
{
|
||||
GetArrayString(MapList, j, map, sizeof(map));
|
||||
sm.SetValue(map, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return menu;
|
||||
for(int i = 0; i < GetArraySize(g_MapList); i++)
|
||||
{
|
||||
GetArrayString(g_MapList, i, map, sizeof(map));
|
||||
|
||||
if(!filter[0] || StrContains(map, filter, false) != -1)
|
||||
{
|
||||
if (client != 0 && nominated_maps)
|
||||
{
|
||||
int map_present = 0;
|
||||
sm.GetValue(map, map_present);
|
||||
if (map_present == 1)
|
||||
{
|
||||
//PrintToChatAll("client %N here. map: %s", client, map);
|
||||
StrCat(map, sizeof(map), " (Nominated)");
|
||||
}
|
||||
}
|
||||
AddMenuItem(menu, map, map);
|
||||
}
|
||||
}
|
||||
|
||||
delete MapList;
|
||||
delete OwnerList;
|
||||
delete sm;
|
||||
|
||||
SetMenuExitButton(menu, true);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
Menu BuildAdminMapMenu(const char[] filter)
|
||||
@ -840,218 +875,229 @@ Menu BuildAdminMapMenu(const char[] filter)
|
||||
|
||||
public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int param2)
|
||||
{
|
||||
switch(action)
|
||||
{
|
||||
case MenuAction_End:
|
||||
{
|
||||
if(menu != g_MapMenu)
|
||||
delete menu;
|
||||
}
|
||||
case MenuAction_Select:
|
||||
{
|
||||
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;
|
||||
}
|
||||
switch(action)
|
||||
{
|
||||
case MenuAction_End:
|
||||
{
|
||||
if (menu != g_MapMenu)
|
||||
{
|
||||
delete menu;
|
||||
}
|
||||
}
|
||||
case MenuAction_Select:
|
||||
{
|
||||
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));
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
|
||||
GetClientName(param1, name, MAX_NAME_LENGTH);
|
||||
GetClientName(param1, name, MAX_NAME_LENGTH);
|
||||
|
||||
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;
|
||||
}
|
||||
if(AreRestrictionsActive() && (
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetMapGroupRestriction(map, param1) >= 0 ||
|
||||
GetMapVIPRestriction(map, param1)))
|
||||
{
|
||||
PrintToChat(param1, "[NE] You cant nominate this map right now.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
NominateResult result = NominateMap(map, false, param1);
|
||||
NominateResult result = NominateMap(map, false, param1);
|
||||
|
||||
/* Don't 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;
|
||||
}
|
||||
if (result == Nominate_InvalidMap)
|
||||
{
|
||||
PrintToChat(param1, "[NE] You already nominated the map %s", map);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
|
||||
/* 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;
|
||||
}
|
||||
|
||||
if(result == Nominate_Added)
|
||||
PrintToChatAll("[NE] %t", "Map Nominated", name, map);
|
||||
else if(result == Nominate_Replaced)
|
||||
PrintToChatAll("[NE] %t", "Map Nomination Changed", name, map);
|
||||
//SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
|
||||
|
||||
LogMessage("%s nominated %s", name, map);
|
||||
g_Player_NominationDelay[param1] = GetTime() + GetConVarInt(g_Cvar_NominateDelay);
|
||||
}
|
||||
if(result == Nominate_Added)
|
||||
PrintToChatAll("[NE] %t", "Map Nominated", name, map);
|
||||
else if(result == Nominate_Replaced)
|
||||
PrintToChatAll("[NE] %t", "Map Nomination Changed", name, map);
|
||||
|
||||
case MenuAction_DrawItem:
|
||||
{
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
LogMessage("%s nominated %s", name, map);
|
||||
g_Player_NominationDelay[param1] = GetTime() + GetConVarInt(g_Cvar_NominateDelay);
|
||||
}
|
||||
|
||||
int status;
|
||||
if(GetTrieValue(g_mapTrie, map, status))
|
||||
{
|
||||
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
||||
{
|
||||
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
case MenuAction_DrawItem:
|
||||
{
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
|
||||
if(AreRestrictionsActive() && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
int status;
|
||||
if(GetTrieValue(g_mapTrie, map, status))
|
||||
{
|
||||
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
||||
{
|
||||
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
|
||||
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(AreRestrictionsActive() && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
|
||||
if(AreRestrictionsActive() && (
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetMapGroupRestriction(map, param1) >= 0 ||
|
||||
GetMapVIPRestriction(map, param1)))
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ITEMDRAW_DEFAULT;
|
||||
}
|
||||
if(AreRestrictionsActive() && (
|
||||
GetMapCooldownTime(map) > GetTime() ||
|
||||
GetMapTimeRestriction(map) ||
|
||||
GetMapPlayerRestriction(map) ||
|
||||
GetMapGroupRestriction(map, param1) >= 0 ||
|
||||
GetMapVIPRestriction(map, param1)))
|
||||
{
|
||||
return ITEMDRAW_DISABLED;
|
||||
}
|
||||
|
||||
case MenuAction_DisplayItem:
|
||||
{
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
return ITEMDRAW_DEFAULT;
|
||||
}
|
||||
|
||||
int mark = GetConVarInt(g_Cvar_MarkCustomMaps);
|
||||
bool official;
|
||||
case MenuAction_DisplayItem:
|
||||
{
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
|
||||
static char buffer[100];
|
||||
static char display[150];
|
||||
int mark = GetConVarInt(g_Cvar_MarkCustomMaps);
|
||||
bool official;
|
||||
|
||||
if(mark)
|
||||
official = IsMapOfficial(map);
|
||||
static char buffer[100];
|
||||
static char display[150];
|
||||
|
||||
if(mark && !official)
|
||||
{
|
||||
switch(mark)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
Format(buffer, sizeof(buffer), "%T", "Custom Marked", param1, map);
|
||||
}
|
||||
if(mark)
|
||||
official = IsMapOfficial(map);
|
||||
|
||||
case 2:
|
||||
{
|
||||
Format(buffer, sizeof(buffer), "%T", "Custom", param1, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
strcopy(buffer, sizeof(buffer), map);
|
||||
if(mark && !official)
|
||||
{
|
||||
switch(mark)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
Format(buffer, sizeof(buffer), "%T", "Custom Marked", param1, map);
|
||||
}
|
||||
|
||||
bool RestrictionsActive = AreRestrictionsActive();
|
||||
case 2:
|
||||
{
|
||||
Format(buffer, sizeof(buffer), "%T", "Custom", param1, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
strcopy(buffer, sizeof(buffer), map);
|
||||
|
||||
bool VIPRestriction = GetMapVIPRestriction(map);
|
||||
if(RestrictionsActive && VIPRestriction)
|
||||
{
|
||||
Format(buffer, sizeof(buffer), "%s (%T)", buffer, "VIP Restriction", param1);
|
||||
}
|
||||
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);
|
||||
}
|
||||
bool VIPRestriction = GetMapVIPRestriction(map);
|
||||
if(RestrictionsActive && VIPRestriction)
|
||||
{
|
||||
Format(buffer, sizeof(buffer), "%s (%T)", buffer, "VIP Restriction", param1);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
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((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
|
||||
{
|
||||
Format(display, sizeof(display), "%s (%T)", buffer, "Nominated", 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
|
||||
{
|
||||
Format(display, sizeof(display), "%s (%T)", buffer, "Nominated", param1);
|
||||
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 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 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);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
int GroupRestriction = GetMapGroupRestriction(map, param1);
|
||||
if(RestrictionsActive && GroupRestriction >= 0)
|
||||
{
|
||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Group Restriction", param1, GroupRestriction);
|
||||
return RedrawMenuItem(display);
|
||||
}
|
||||
return RedrawMenuItem(display);
|
||||
}
|
||||
|
||||
if(RestrictionsActive && VIPRestriction)
|
||||
{
|
||||
return RedrawMenuItem(buffer);
|
||||
}
|
||||
//2023 edit for multiple nominations
|
||||
/*
|
||||
int GroupRestriction = GetMapGroupRestriction(map, param1);
|
||||
if(RestrictionsActive && GroupRestriction >= 0)
|
||||
{
|
||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Group Restriction", param1, GroupRestriction);
|
||||
return RedrawMenuItem(display);
|
||||
}
|
||||
*/
|
||||
|
||||
if(mark && !official)
|
||||
return RedrawMenuItem(buffer);
|
||||
if(RestrictionsActive && VIPRestriction)
|
||||
{
|
||||
return RedrawMenuItem(buffer);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if(mark && !official)
|
||||
return RedrawMenuItem(buffer);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
stock bool IsNominateAllowed(int client)
|
||||
@ -1103,66 +1149,66 @@ stock bool IsNominateAllowed(int client)
|
||||
|
||||
public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1, int param2)
|
||||
{
|
||||
switch(action)
|
||||
{
|
||||
case MenuAction_End:
|
||||
{
|
||||
if(menu != g_AdminMapMenu)
|
||||
delete menu;
|
||||
}
|
||||
case MenuAction_Select:
|
||||
{
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
switch(action)
|
||||
{
|
||||
case MenuAction_End:
|
||||
{
|
||||
if(menu != g_AdminMapMenu)
|
||||
delete menu;
|
||||
}
|
||||
case MenuAction_Select:
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
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 cant nominate this map right now.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
NominateResult result = NominateMap(map, true, 0);
|
||||
NominateResult result = NominateMap(map, true, 0);
|
||||
|
||||
if(result > Nominate_Replaced)
|
||||
{
|
||||
/* We assume already in vote is the casue because the maplist does a Map Validity check and we forced, so it can't be full */
|
||||
PrintToChat(param1, "[NE] %t", "Map Already In Vote", map);
|
||||
return 0;
|
||||
}
|
||||
if(result > Nominate_Replaced)
|
||||
{
|
||||
/* We assume already in vote is the casue because the maplist does a Map Validity check and we forced, so it cant be full */
|
||||
PrintToChat(param1, "[NE] %t", "Map Already In Vote", map);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
|
||||
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);
|
||||
PrintToChat(param1, "[NE] %t", "Map Inserted", map);
|
||||
LogAction(param1, -1, "\"%L\" inserted map \"%s\".", param1, map);
|
||||
|
||||
PrintToChatAll("[NE] %N has inserted %s into nominations", param1, map);
|
||||
}
|
||||
PrintToChatAll("[NE] %N has inserted %s into nominations", param1, map);
|
||||
}
|
||||
|
||||
case MenuAction_DrawItem:
|
||||
{
|
||||
if(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_CHEATS, true))
|
||||
{
|
||||
return Handler_MapSelectMenu(menu, action, param1, param2);
|
||||
}
|
||||
case MenuAction_DrawItem:
|
||||
{
|
||||
if(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_CHEATS, true))
|
||||
{
|
||||
return Handler_MapSelectMenu(menu, action, param1, param2);
|
||||
}
|
||||
|
||||
return ITEMDRAW_DEFAULT;
|
||||
}
|
||||
return ITEMDRAW_DEFAULT;
|
||||
}
|
||||
|
||||
case MenuAction_DisplayItem:
|
||||
{
|
||||
return Handler_MapSelectMenu(menu, action, param1, param2);
|
||||
}
|
||||
}
|
||||
case MenuAction_DisplayItem:
|
||||
{
|
||||
return Handler_MapSelectMenu(menu, action, param1, param2);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Handler_AdminRemoveMapMenu(Menu menu, MenuAction action, int param1, int param2)
|
||||
@ -1180,7 +1226,7 @@ public int Handler_AdminRemoveMapMenu(Menu menu, MenuAction action, int param1,
|
||||
|
||||
if(!RemoveNominationByMap(map))
|
||||
{
|
||||
CReplyToCommand(param1, "This map isn't nominated.", map);
|
||||
CReplyToCommand(param1, "This map isnt nominated.", map);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1302,7 +1348,7 @@ stock int GetVIPTimeRestriction()
|
||||
MinTime = (MinTime <= CurTime) ? MinTime + 2400 : MinTime;
|
||||
MinTime = (MinTime <= MaxTime) ? MinTime + 2400 : MinTime;
|
||||
|
||||
// Convert our 'time' to minutes.
|
||||
// Convert our time to minutes.
|
||||
CurTime = ((CurTime / 100) * 60) + (CurTime % 100);
|
||||
MinTime = ((MinTime / 100) * 60) + (MinTime % 100);
|
||||
MaxTime = ((MaxTime / 100) * 60) + (MaxTime % 100);
|
||||
|
Loading…
Reference in New Issue
Block a user