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()
|
void UpdateMapMenus()
|
||||||
{
|
{
|
||||||
if(g_MapMenu != INVALID_HANDLE)
|
g_MapMenu = BuildMapMenu("", 0);
|
||||||
delete g_MapMenu;
|
|
||||||
|
|
||||||
g_MapMenu = BuildMapMenu("");
|
|
||||||
|
|
||||||
if(g_AdminMapMenu != INVALID_HANDLE)
|
|
||||||
delete g_AdminMapMenu;
|
|
||||||
|
|
||||||
g_AdminMapMenu = BuildAdminMapMenu("");
|
g_AdminMapMenu = BuildAdminMapMenu("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,17 +236,16 @@ void UpdateMapTrie()
|
|||||||
|
|
||||||
public void OnNominationRemoved(const char[] map, int owner)
|
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? */
|
/* Was the map disabled due to being nominated */
|
||||||
if(!GetTrieValue(g_mapTrie, map, status))
|
if((status & MAPSTATUS_EXCLUDE_NOMINATED) != MAPSTATUS_EXCLUDE_NOMINATED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Was the map disabled due to being nominated */
|
SetTrieValue(g_mapTrie, map, MAPSTATUS_ENABLED);
|
||||||
if((status & MAPSTATUS_EXCLUDE_NOMINATED) != MAPSTATUS_EXCLUDE_NOMINATED)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SetTrieValue(g_mapTrie, map, MAPSTATUS_ENABLED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Command_Addmap(int client, int args)
|
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_DISABLED) == MAPSTATUS_DISABLED)
|
||||||
{
|
{
|
||||||
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
|
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)
|
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)
|
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);
|
CReplyToCommand(client, "%t", "Map Already In Vote", mapname);
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
@ -388,7 +380,7 @@ public Action Command_Removemap(int client, int args)
|
|||||||
|
|
||||||
if(!RemoveNominationByMap(mapname))
|
if(!RemoveNominationByMap(mapname))
|
||||||
{
|
{
|
||||||
CReplyToCommand(client, "This map isn't nominated.", mapname);
|
CReplyToCommand(client, "This map isnt nominated.", mapname);
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
@ -523,130 +515,135 @@ public Action Command_Say(int client, int args)
|
|||||||
|
|
||||||
public Action Command_Nominate(int client, int args)
|
public Action Command_Nominate(int client, int args)
|
||||||
{
|
{
|
||||||
if(!client || !IsNominateAllowed(client))
|
if(!client || !IsNominateAllowed(client))
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
|
|
||||||
if(g_NominationDelay > GetTime())
|
if(g_NominationDelay > GetTime())
|
||||||
{
|
{
|
||||||
PrintToChat(client, "[NE] Nominations will be unlocked in %d seconds", g_NominationDelay - GetTime());
|
PrintToChat(client, "[NE] Nominations will be unlocked in %d seconds", g_NominationDelay - GetTime());
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args == 0)
|
if(args == 0)
|
||||||
{
|
{
|
||||||
AttemptNominate(client);
|
AttemptNominate(client);
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_Player_NominationDelay[client] > GetTime())
|
if(g_Player_NominationDelay[client] > GetTime())
|
||||||
{
|
{
|
||||||
PrintToChat(client, "[NE] Please wait %d seconds before you can nominate again", 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;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char mapname[PLATFORM_MAX_PATH];
|
static char mapname[PLATFORM_MAX_PATH];
|
||||||
GetCmdArg(1, mapname, sizeof(mapname));
|
GetCmdArg(1, mapname, sizeof(mapname));
|
||||||
|
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
if(!GetTrieValue(g_mapTrie, mapname, status))
|
if(!GetTrieValue(g_mapTrie, mapname, status))
|
||||||
{
|
{
|
||||||
CPrintToChat(client, "%t", "Map was not found", mapname);
|
CPrintToChat(client, "%t", "Map was not found", mapname);
|
||||||
AttemptNominate(client, mapname);
|
AttemptNominate(client, mapname);
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RestrictionsActive = AreRestrictionsActive();
|
bool RestrictionsActive = AreRestrictionsActive();
|
||||||
|
|
||||||
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)
|
||||||
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)
|
if(RestrictionsActive && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
||||||
{
|
{
|
||||||
int Cooldown = GetMapCooldown(mapname);
|
int Cooldown = GetMapCooldown(mapname);
|
||||||
CPrintToChat(client, "[NE] %t (%d)", "Map in Exclude List", Cooldown);
|
CPrintToChat(client, "[NE] %t (%d)", "Map in Exclude List", Cooldown);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
|
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
|
||||||
CPrintToChat(client, "[NE] %t", "Map Already Nominated");
|
CPrintToChat(client, "[NE] %t", "Map Already Nominated");
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Cooldown = GetMapCooldownTime(mapname);
|
int Cooldown = GetMapCooldownTime(mapname);
|
||||||
if(RestrictionsActive && Cooldown > GetTime())
|
if(RestrictionsActive && Cooldown > GetTime())
|
||||||
{
|
{
|
||||||
int Seconds = Cooldown - GetTime();
|
int Seconds = Cooldown - GetTime();
|
||||||
CPrintToChat(client, "[NE] %t", "Map Cooldown Time Error", Seconds / 3600, (Seconds % 3600) / 60);
|
CPrintToChat(client, "[NE] %t", "Map Cooldown Time Error", Seconds / 3600, (Seconds % 3600) / 60);
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VIPRestriction = GetMapVIPRestriction(mapname, client);
|
bool VIPRestriction = GetMapVIPRestriction(mapname, client);
|
||||||
if(RestrictionsActive && VIPRestriction)
|
if(RestrictionsActive && VIPRestriction)
|
||||||
{
|
{
|
||||||
CPrintToChat(client, "[NE] %t", "Map Nominate VIP Error");
|
CPrintToChat(client, "[NE] %t", "Map Nominate VIP Error");
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TimeRestriction = GetMapTimeRestriction(mapname);
|
int TimeRestriction = GetMapTimeRestriction(mapname);
|
||||||
if(RestrictionsActive && TimeRestriction)
|
if(RestrictionsActive && TimeRestriction)
|
||||||
{
|
{
|
||||||
CPrintToChat(client, "[NE] %t", "Map Nominate Time Error", TimeRestriction / 60, TimeRestriction % 60);
|
CPrintToChat(client, "[NE] %t", "Map Nominate Time Error", TimeRestriction / 60, TimeRestriction % 60);
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PlayerRestriction = GetMapPlayerRestriction(mapname);
|
int PlayerRestriction = GetMapPlayerRestriction(mapname);
|
||||||
if(RestrictionsActive && PlayerRestriction)
|
if(RestrictionsActive && PlayerRestriction)
|
||||||
{
|
{
|
||||||
if(PlayerRestriction < 0)
|
if(PlayerRestriction < 0)
|
||||||
CPrintToChat(client, "[NE] %t", "Map Nominate MinPlayers Error", PlayerRestriction * -1);
|
CPrintToChat(client, "[NE] %t", "Map Nominate MinPlayers Error", PlayerRestriction * -1);
|
||||||
else
|
else
|
||||||
CPrintToChat(client, "[NE] %t", "Map Nominate MaxPlayers Error", PlayerRestriction);
|
CPrintToChat(client, "[NE] %t", "Map Nominate MaxPlayers Error", PlayerRestriction);
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GroupRestriction = GetMapGroupRestriction(mapname, client);
|
int GroupRestriction = GetMapGroupRestriction(mapname, client);
|
||||||
if(RestrictionsActive && GroupRestriction >= 0)
|
if(RestrictionsActive && GroupRestriction >= 0)
|
||||||
{
|
{
|
||||||
CPrintToChat(client, "[NE] %t", "Map Nominate Group Error", GroupRestriction);
|
CPrintToChat(client, "[NE] %t", "Map Nominate Group Error", GroupRestriction);
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
NominateResult result = NominateMap(mapname, false, client);
|
NominateResult result = NominateMap(mapname, false, client);
|
||||||
|
|
||||||
if(result > Nominate_Replaced)
|
if (result == Nominate_InvalidMap)
|
||||||
{
|
{
|
||||||
if(result == Nominate_AlreadyInVote)
|
CPrintToChat(client, "[NE] %t", "You already nominated the map ", mapname);
|
||||||
CPrintToChat(client, "[NE] %t", "Map Already In Vote", mapname);
|
return Plugin_Handled;
|
||||||
else if(result == Nominate_VoteFull)
|
}
|
||||||
CPrintToChat(client, "[NE] %t", "Max Nominations");
|
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];
|
static char name[MAX_NAME_LENGTH];
|
||||||
GetClientName(client, name, sizeof(name));
|
GetClientName(client, name, sizeof(name));
|
||||||
|
|
||||||
if(result == Nominate_Added)
|
if(result == Nominate_Added)
|
||||||
PrintToChatAll("[NE] %t", "Map Nominated", name, mapname);
|
PrintToChatAll("[NE] %t", "Map Nominated", name, mapname);
|
||||||
else if(result == Nominate_Replaced)
|
else if(result == Nominate_Replaced)
|
||||||
PrintToChatAll("[NE] %t", "Map Nomination Changed", name, mapname);
|
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)
|
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 = "")
|
void AttemptNominate(int client, const char[] filter = "")
|
||||||
{
|
{
|
||||||
if(!client)
|
if(!client)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Menu menu = g_MapMenu;
|
Menu menu = g_MapMenu;
|
||||||
if(filter[0])
|
menu = BuildMapMenu(filter, client);
|
||||||
menu = BuildMapMenu(filter);
|
|
||||||
|
|
||||||
SetMenuTitle(menu, "%T", "Nominate Title", client);
|
SetMenuTitle(menu, "%T", "Nominate Title", client);
|
||||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttemptAdminNominate(int client, const char[] filter = "")
|
void AttemptAdminNominate(int client, const char[] filter = "")
|
||||||
@ -786,25 +782,64 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
|
|||||||
return true;
|
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++)
|
int arraySize = ByteCountToCells(PLATFORM_MAX_PATH);
|
||||||
{
|
ArrayList MapList = CreateArray(arraySize);
|
||||||
GetArrayString(g_MapList, i, map, sizeof(map));
|
ArrayList OwnerList = CreateArray();
|
||||||
|
StringMap sm = new StringMap();
|
||||||
|
|
||||||
if(!filter[0] || StrContains(map, filter, false) != -1)
|
GetNominatedMapList(MapList, OwnerList);
|
||||||
{
|
bool nominated_maps = true;
|
||||||
AddMenuItem(menu, map, map);
|
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)
|
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)
|
public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int param2)
|
||||||
{
|
{
|
||||||
switch(action)
|
switch(action)
|
||||||
{
|
{
|
||||||
case MenuAction_End:
|
case MenuAction_End:
|
||||||
{
|
{
|
||||||
if(menu != g_MapMenu)
|
if (menu != g_MapMenu)
|
||||||
delete menu;
|
{
|
||||||
}
|
delete menu;
|
||||||
case MenuAction_Select:
|
}
|
||||||
{
|
}
|
||||||
if(g_Player_NominationDelay[param1] > GetTime())
|
case MenuAction_Select:
|
||||||
{
|
{
|
||||||
PrintToChat(param1, "[NE] Please wait %d seconds before you can nominate again", g_Player_NominationDelay[param1] - GetTime());
|
if(g_Player_NominationDelay[param1] > GetTime())
|
||||||
DisplayMenuAtItem(menu, param1, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
|
{
|
||||||
return 0;
|
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];
|
static char map[PLATFORM_MAX_PATH];
|
||||||
char name[MAX_NAME_LENGTH];
|
char name[MAX_NAME_LENGTH];
|
||||||
GetMenuItem(menu, param2, map, sizeof(map));
|
GetMenuItem(menu, param2, map, sizeof(map));
|
||||||
|
|
||||||
GetClientName(param1, name, MAX_NAME_LENGTH);
|
GetClientName(param1, name, MAX_NAME_LENGTH);
|
||||||
|
|
||||||
if(AreRestrictionsActive() && (
|
if(AreRestrictionsActive() && (
|
||||||
GetMapCooldownTime(map) > GetTime() ||
|
GetMapCooldownTime(map) > GetTime() ||
|
||||||
GetMapTimeRestriction(map) ||
|
GetMapTimeRestriction(map) ||
|
||||||
GetMapPlayerRestriction(map) ||
|
GetMapPlayerRestriction(map) ||
|
||||||
GetMapGroupRestriction(map, param1) >= 0 ||
|
GetMapGroupRestriction(map, param1) >= 0 ||
|
||||||
GetMapVIPRestriction(map, param1)))
|
GetMapVIPRestriction(map, param1)))
|
||||||
{
|
{
|
||||||
PrintToChat(param1, "[NE] You can't nominate this map right now.");
|
PrintToChat(param1, "[NE] You cant nominate this map right now.");
|
||||||
return 0;
|
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_InvalidMap)
|
||||||
if(result == Nominate_AlreadyInVote)
|
{
|
||||||
{
|
PrintToChat(param1, "[NE] You already nominated the map %s", map);
|
||||||
PrintToChat(param1, "[NE] %t", "Map Already Nominated");
|
return 0;
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
else if(result == Nominate_VoteFull)
|
|
||||||
{
|
|
||||||
PrintToChat(param1, "[NE] %t", "Max Nominations");
|
|
||||||
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)
|
//SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
|
||||||
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);
|
if(result == Nominate_Added)
|
||||||
g_Player_NominationDelay[param1] = GetTime() + GetConVarInt(g_Cvar_NominateDelay);
|
PrintToChatAll("[NE] %t", "Map Nominated", name, map);
|
||||||
}
|
else if(result == Nominate_Replaced)
|
||||||
|
PrintToChatAll("[NE] %t", "Map Nomination Changed", name, map);
|
||||||
|
|
||||||
case MenuAction_DrawItem:
|
LogMessage("%s nominated %s", name, map);
|
||||||
{
|
g_Player_NominationDelay[param1] = GetTime() + GetConVarInt(g_Cvar_NominateDelay);
|
||||||
static char map[PLATFORM_MAX_PATH];
|
}
|
||||||
GetMenuItem(menu, param2, map, sizeof(map));
|
|
||||||
|
|
||||||
int status;
|
case MenuAction_DrawItem:
|
||||||
if(GetTrieValue(g_mapTrie, map, status))
|
{
|
||||||
{
|
static char map[PLATFORM_MAX_PATH];
|
||||||
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
GetMenuItem(menu, param2, map, sizeof(map));
|
||||||
{
|
|
||||||
if((status & MAPSTATUS_EXCLUDE_CURRENT) == MAPSTATUS_EXCLUDE_CURRENT)
|
|
||||||
{
|
|
||||||
return ITEMDRAW_DISABLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(AreRestrictionsActive() && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
int status;
|
||||||
{
|
if(GetTrieValue(g_mapTrie, map, status))
|
||||||
return ITEMDRAW_DISABLED;
|
{
|
||||||
}
|
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)
|
if(AreRestrictionsActive() && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
||||||
{
|
{
|
||||||
return ITEMDRAW_DISABLED;
|
return ITEMDRAW_DISABLED;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(AreRestrictionsActive() && (
|
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
|
||||||
GetMapCooldownTime(map) > GetTime() ||
|
{
|
||||||
GetMapTimeRestriction(map) ||
|
return ITEMDRAW_DISABLED;
|
||||||
GetMapPlayerRestriction(map) ||
|
}
|
||||||
GetMapGroupRestriction(map, param1) >= 0 ||
|
}
|
||||||
GetMapVIPRestriction(map, param1)))
|
}
|
||||||
{
|
|
||||||
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:
|
return ITEMDRAW_DEFAULT;
|
||||||
{
|
}
|
||||||
static char map[PLATFORM_MAX_PATH];
|
|
||||||
GetMenuItem(menu, param2, map, sizeof(map));
|
|
||||||
|
|
||||||
int mark = GetConVarInt(g_Cvar_MarkCustomMaps);
|
case MenuAction_DisplayItem:
|
||||||
bool official;
|
{
|
||||||
|
static char map[PLATFORM_MAX_PATH];
|
||||||
|
GetMenuItem(menu, param2, map, sizeof(map));
|
||||||
|
|
||||||
static char buffer[100];
|
int mark = GetConVarInt(g_Cvar_MarkCustomMaps);
|
||||||
static char display[150];
|
bool official;
|
||||||
|
|
||||||
if(mark)
|
static char buffer[100];
|
||||||
official = IsMapOfficial(map);
|
static char display[150];
|
||||||
|
|
||||||
if(mark && !official)
|
if(mark)
|
||||||
{
|
official = IsMapOfficial(map);
|
||||||
switch(mark)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
Format(buffer, sizeof(buffer), "%T", "Custom Marked", param1, map);
|
|
||||||
}
|
|
||||||
|
|
||||||
case 2:
|
if(mark && !official)
|
||||||
{
|
{
|
||||||
Format(buffer, sizeof(buffer), "%T", "Custom", param1, map);
|
switch(mark)
|
||||||
}
|
{
|
||||||
}
|
case 1:
|
||||||
}
|
{
|
||||||
else
|
Format(buffer, sizeof(buffer), "%T", "Custom Marked", param1, map);
|
||||||
strcopy(buffer, sizeof(buffer), map);
|
}
|
||||||
|
|
||||||
bool RestrictionsActive = AreRestrictionsActive();
|
case 2:
|
||||||
|
{
|
||||||
|
Format(buffer, sizeof(buffer), "%T", "Custom", param1, map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strcopy(buffer, sizeof(buffer), map);
|
||||||
|
|
||||||
bool VIPRestriction = GetMapVIPRestriction(map);
|
bool RestrictionsActive = AreRestrictionsActive();
|
||||||
if(RestrictionsActive && VIPRestriction)
|
|
||||||
{
|
|
||||||
Format(buffer, sizeof(buffer), "%s (%T)", buffer, "VIP Restriction", param1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int status;
|
bool VIPRestriction = GetMapVIPRestriction(map);
|
||||||
if(GetTrieValue(g_mapTrie, map, status))
|
if(RestrictionsActive && VIPRestriction)
|
||||||
{
|
{
|
||||||
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
Format(buffer, sizeof(buffer), "%s (%T)", buffer, "VIP Restriction", param1);
|
||||||
{
|
}
|
||||||
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 status;
|
||||||
{
|
if(GetTrieValue(g_mapTrie, map, status))
|
||||||
int Cooldown = GetMapCooldown(map);
|
{
|
||||||
Format(display, sizeof(display), "%s (%T %d)", buffer, "Recently Played", param1, Cooldown);
|
if((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
||||||
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((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
|
if(RestrictionsActive && (status & MAPSTATUS_EXCLUDE_PREVIOUS) == MAPSTATUS_EXCLUDE_PREVIOUS)
|
||||||
{
|
{
|
||||||
Format(display, sizeof(display), "%s (%T)", buffer, "Nominated", param1);
|
int Cooldown = GetMapCooldown(map);
|
||||||
return RedrawMenuItem(display);
|
Format(display, sizeof(display), "%s (%T %d)", buffer, "Recently Played", param1, Cooldown);
|
||||||
}
|
return RedrawMenuItem(display);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int Cooldown = GetMapCooldownTime(map);
|
if((status & MAPSTATUS_EXCLUDE_NOMINATED) == MAPSTATUS_EXCLUDE_NOMINATED)
|
||||||
if(RestrictionsActive && Cooldown > GetTime())
|
{
|
||||||
{
|
Format(display, sizeof(display), "%s (%T)", buffer, "Nominated", param1);
|
||||||
int Seconds = Cooldown - GetTime();
|
return RedrawMenuItem(display);
|
||||||
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);
|
int Cooldown = GetMapCooldownTime(map);
|
||||||
if(RestrictionsActive && TimeRestriction)
|
if(RestrictionsActive && Cooldown > GetTime())
|
||||||
{
|
{
|
||||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", TimeRestriction / 60, TimeRestriction % 60);
|
int Seconds = Cooldown - GetTime();
|
||||||
return RedrawMenuItem(display);
|
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);
|
int TimeRestriction = GetMapTimeRestriction(map);
|
||||||
if(RestrictionsActive && PlayerRestriction)
|
if(RestrictionsActive && TimeRestriction)
|
||||||
{
|
{
|
||||||
if(PlayerRestriction < 0)
|
Format(display, sizeof(display), "%s (%T)", buffer, "Map Time Restriction", param1, "+", TimeRestriction / 60, TimeRestriction % 60);
|
||||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Player Restriction", param1, "+", PlayerRestriction * -1);
|
return RedrawMenuItem(display);
|
||||||
else
|
}
|
||||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Player Restriction", param1, "-", PlayerRestriction);
|
|
||||||
|
|
||||||
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);
|
return RedrawMenuItem(display);
|
||||||
if(RestrictionsActive && GroupRestriction >= 0)
|
}
|
||||||
{
|
|
||||||
Format(display, sizeof(display), "%s (%T)", buffer, "Map Group Restriction", param1, GroupRestriction);
|
|
||||||
return RedrawMenuItem(display);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(RestrictionsActive && VIPRestriction)
|
//2023 edit for multiple nominations
|
||||||
{
|
/*
|
||||||
return RedrawMenuItem(buffer);
|
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)
|
if(RestrictionsActive && VIPRestriction)
|
||||||
return RedrawMenuItem(buffer);
|
{
|
||||||
|
return RedrawMenuItem(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
if(mark && !official)
|
||||||
}
|
return RedrawMenuItem(buffer);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
stock bool IsNominateAllowed(int client)
|
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)
|
public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1, int param2)
|
||||||
{
|
{
|
||||||
switch(action)
|
switch(action)
|
||||||
{
|
{
|
||||||
case MenuAction_End:
|
case MenuAction_End:
|
||||||
{
|
{
|
||||||
if(menu != g_AdminMapMenu)
|
if(menu != g_AdminMapMenu)
|
||||||
delete menu;
|
delete menu;
|
||||||
}
|
}
|
||||||
case MenuAction_Select:
|
case MenuAction_Select:
|
||||||
{
|
{
|
||||||
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(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_CHEATS, true))
|
||||||
{
|
{
|
||||||
if(AreRestrictionsActive() && (
|
if(AreRestrictionsActive() && (
|
||||||
GetMapCooldownTime(map) > GetTime() ||
|
GetMapCooldownTime(map) > GetTime() ||
|
||||||
GetMapTimeRestriction(map) ||
|
GetMapTimeRestriction(map) ||
|
||||||
GetMapPlayerRestriction(map) ||
|
GetMapPlayerRestriction(map) ||
|
||||||
GetMapGroupRestriction(map, param1) >= 0 ||
|
GetMapGroupRestriction(map, param1) >= 0 ||
|
||||||
GetMapVIPRestriction(map, param1)))
|
GetMapVIPRestriction(map, param1)))
|
||||||
{
|
{
|
||||||
PrintToChat(param1, "[NE] You can't nominate this map right now.");
|
PrintToChat(param1, "[NE] You cant nominate this map right now.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NominateResult result = NominateMap(map, true, 0);
|
NominateResult result = NominateMap(map, true, 0);
|
||||||
|
|
||||||
if(result > Nominate_Replaced)
|
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 */
|
||||||
PrintToChat(param1, "[NE] %t", "Map Already In Vote", map);
|
PrintToChat(param1, "[NE] %t", "Map Already In Vote", map);
|
||||||
return 0;
|
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);
|
PrintToChat(param1, "[NE] %t", "Map Inserted", map);
|
||||||
LogAction(param1, -1, "\"%L\" inserted map \"%s\".", param1, 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:
|
case MenuAction_DrawItem:
|
||||||
{
|
{
|
||||||
if(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_CHEATS, true))
|
if(!CheckCommandAccess(param1, "sm_nominate_ignore", ADMFLAG_CHEATS, true))
|
||||||
{
|
{
|
||||||
return Handler_MapSelectMenu(menu, action, param1, param2);
|
return Handler_MapSelectMenu(menu, action, param1, param2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ITEMDRAW_DEFAULT;
|
return ITEMDRAW_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MenuAction_DisplayItem:
|
case MenuAction_DisplayItem:
|
||||||
{
|
{
|
||||||
return Handler_MapSelectMenu(menu, action, param1, param2);
|
return Handler_MapSelectMenu(menu, action, param1, param2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Handler_AdminRemoveMapMenu(Menu menu, MenuAction action, int param1, int param2)
|
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))
|
if(!RemoveNominationByMap(map))
|
||||||
{
|
{
|
||||||
CReplyToCommand(param1, "This map isn't nominated.", map);
|
CReplyToCommand(param1, "This map isnt nominated.", map);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1302,7 +1348,7 @@ stock int GetVIPTimeRestriction()
|
|||||||
MinTime = (MinTime <= CurTime) ? MinTime + 2400 : MinTime;
|
MinTime = (MinTime <= CurTime) ? MinTime + 2400 : MinTime;
|
||||||
MinTime = (MinTime <= MaxTime) ? 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);
|
CurTime = ((CurTime / 100) * 60) + (CurTime % 100);
|
||||||
MinTime = ((MinTime / 100) * 60) + (MinTime % 100);
|
MinTime = ((MinTime / 100) * 60) + (MinTime % 100);
|
||||||
MaxTime = ((MaxTime / 100) * 60) + (MaxTime % 100);
|
MaxTime = ((MaxTime / 100) * 60) + (MaxTime % 100);
|
||||||
|
Loading…
Reference in New Issue
Block a user