forked from UNLOZE/sm-plugins
mapchooser_extended: Fix bug with full nomination when addmap and removemap. Add nominate_removemap menu.
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
#include <multicolors>
|
||||
#include <basecomm>
|
||||
|
||||
#define MCE_VERSION "1.3.0"
|
||||
#define MCE_VERSION "1.3.1"
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
@@ -362,6 +362,12 @@ public Action Command_Addmap(int client, int args)
|
||||
|
||||
public Action Command_Removemap(int client, int args)
|
||||
{
|
||||
if(args == 0 && client > 0)
|
||||
{
|
||||
AttemptAdminRemoveMap(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if(args != 1)
|
||||
{
|
||||
CReplyToCommand(client, "[NE] Usage: sm_nominate_removemap <mapname>");
|
||||
@@ -375,6 +381,7 @@ public Action Command_Removemap(int client, int args)
|
||||
if(/*!GetTrieValue(g_mapTrie, mapname, status)*/!IsMapValid(mapname))
|
||||
{
|
||||
CReplyToCommand(client, "%t", "Map was not found", mapname);
|
||||
AttemptAdminRemoveMap(client, mapname);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
@@ -643,46 +650,38 @@ public Action Command_Nominate(int client, int args)
|
||||
|
||||
public Action Command_NominateList(int client, int args)
|
||||
{
|
||||
int arraySize = ByteCountToCells(PLATFORM_MAX_PATH);
|
||||
ArrayList MapList = CreateArray(arraySize);
|
||||
|
||||
GetNominatedMapList(MapList);
|
||||
if(!GetArraySize(MapList))
|
||||
{
|
||||
ReplyToCommand(client, "[NE] No maps have been nominated.");
|
||||
delete MapList;
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
|
||||
if (client == 0)
|
||||
{
|
||||
int arraySize = ByteCountToCells(PLATFORM_MAX_PATH);
|
||||
ArrayList MapList = CreateArray(arraySize);
|
||||
GetNominatedMapList(MapList);
|
||||
|
||||
char aBuf[2048];
|
||||
StrCat(aBuf, sizeof(aBuf), "[NE] Nominated Maps:");
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
for(int i = 0; i < GetArraySize(MapList); i++)
|
||||
{
|
||||
StrCat(aBuf, sizeof(aBuf), "\n");
|
||||
GetArrayString(MapList, i, map, sizeof(map));
|
||||
StrCat(aBuf, sizeof(aBuf), map);
|
||||
}
|
||||
|
||||
ReplyToCommand(client, aBuf);
|
||||
delete MapList;
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
Handle NominateListMenu = CreateMenu(Handler_NominateListMenu, MENU_ACTIONS_DEFAULT|MenuAction_DisplayItem);
|
||||
Menu NominateListMenu = CreateMenu(Handler_NominateListMenu, MENU_ACTIONS_DEFAULT|MenuAction_DisplayItem);
|
||||
|
||||
for(int i = 0; i < GetArraySize(MapList); i++)
|
||||
if(!PopulateNominateListMenu(NominateListMenu, client))
|
||||
{
|
||||
GetArrayString(MapList, i, map, sizeof(map));
|
||||
AddMenuItem(NominateListMenu, map, map);
|
||||
ReplyToCommand(client, "[NE] No maps have been nominated.");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
SetMenuTitle(NominateListMenu, "Nominated Maps", client);
|
||||
DisplayMenu(NominateListMenu, client, MENU_TIME_FOREVER);
|
||||
|
||||
delete MapList;
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
@@ -694,22 +693,6 @@ public int Handler_NominateListMenu(Menu menu, MenuAction action, int param1, in
|
||||
{
|
||||
delete menu;
|
||||
}
|
||||
|
||||
case MenuAction_DisplayItem:
|
||||
{
|
||||
static char display[150];
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
|
||||
bool VIPRestriction = GetMapVIPRestriction(map);
|
||||
if((VIPRestriction) && AreRestrictionsActive())
|
||||
{
|
||||
Format(display, sizeof(display), "%s (%T)", map, "VIP Nomination", param1);
|
||||
return RedrawMenuItem(display);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -717,26 +700,87 @@ public int Handler_NominateListMenu(Menu menu, MenuAction action, int param1, in
|
||||
|
||||
void AttemptNominate(int client, const char[] filter = "")
|
||||
{
|
||||
if(!client)
|
||||
return;
|
||||
|
||||
Menu menu = g_MapMenu;
|
||||
if(filter[0])
|
||||
menu = BuildMapMenu(filter);
|
||||
|
||||
SetMenuTitle(menu, "%T", "Nominate Title", client);
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void AttemptAdminNominate(int client, const char[] filter = "")
|
||||
{
|
||||
if(!client)
|
||||
return;
|
||||
|
||||
Menu menu = g_AdminMapMenu;
|
||||
if(filter[0])
|
||||
menu = BuildAdminMapMenu(filter);
|
||||
|
||||
SetMenuTitle(menu, "%T", "Nominate Title", client);
|
||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
return;
|
||||
void AttemptAdminRemoveMap(int client, const char[] filter = "")
|
||||
{
|
||||
if(!client)
|
||||
return;
|
||||
|
||||
Menu AdminRemoveMapMenu = CreateMenu(Handler_AdminRemoveMapMenu, MENU_ACTIONS_DEFAULT|MenuAction_DisplayItem);
|
||||
|
||||
if(!PopulateNominateListMenu(AdminRemoveMapMenu, client, filter))
|
||||
{
|
||||
ReplyToCommand(client, "[NE] No maps have been nominated.");
|
||||
return;
|
||||
}
|
||||
|
||||
SetMenuTitle(AdminRemoveMapMenu, "Remove nomination", client);
|
||||
DisplayMenu(AdminRemoveMapMenu, client, MENU_TIME_FOREVER);
|
||||
|
||||
}
|
||||
|
||||
bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
|
||||
{
|
||||
int arraySize = ByteCountToCells(PLATFORM_MAX_PATH);
|
||||
ArrayList MapList = CreateArray(arraySize);
|
||||
ArrayList OwnerList = CreateArray();
|
||||
|
||||
GetNominatedMapList(MapList, OwnerList);
|
||||
if(!GetArraySize(MapList))
|
||||
{
|
||||
delete MapList;
|
||||
delete OwnerList;
|
||||
return false;
|
||||
}
|
||||
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
static char display[PLATFORM_MAX_PATH];
|
||||
for(int i = 0; i < GetArraySize(MapList); i++)
|
||||
{
|
||||
GetArrayString(MapList, i, map, sizeof(map));
|
||||
|
||||
if(!filter[0] || StrContains(map, filter, false) != -1)
|
||||
{
|
||||
int owner = GetArrayCell(OwnerList, i);
|
||||
if(!owner)
|
||||
Format(display, sizeof(display), "%s (Admin)", map);
|
||||
else
|
||||
Format(display, sizeof(display), "%s (%N)", map, owner);
|
||||
|
||||
bool VIPRestriction = GetMapVIPRestriction(map);
|
||||
if((VIPRestriction) && AreRestrictionsActive())
|
||||
Format(display, sizeof(display), "%s (%T)", map, "VIP Nomination", client);
|
||||
|
||||
AddMenuItem(menu, map, display);
|
||||
}
|
||||
}
|
||||
|
||||
delete MapList;
|
||||
delete OwnerList;
|
||||
return true;
|
||||
}
|
||||
|
||||
Menu BuildMapMenu(const char[] filter)
|
||||
@@ -1118,6 +1162,35 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Handler_AdminRemoveMapMenu(Menu menu, MenuAction action, int param1, int param2)
|
||||
{
|
||||
switch(action)
|
||||
{
|
||||
case MenuAction_End:
|
||||
{
|
||||
delete menu;
|
||||
}
|
||||
case MenuAction_Select:
|
||||
{
|
||||
static char map[PLATFORM_MAX_PATH];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
|
||||
if(!RemoveNominationByMap(map))
|
||||
{
|
||||
CReplyToCommand(param1, "This map isn't nominated.", map);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CReplyToCommand(param1, "Map '%s' removed from the nominations list.", map);
|
||||
LogAction(param1, -1, "\"%L\" removed map \"%s\" from nominations.", param1, map);
|
||||
|
||||
PrintToChatAll("[NE] %N has removed %s from nominations", param1, map);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Native_GetNominationPool(Handle plugin, int numArgs)
|
||||
{
|
||||
SetNativeCellRef(1, g_MapList);
|
||||
|
||||
Reference in New Issue
Block a user