Update to sm_ban, sm_kick, & sm_map in chat with no args to display menu (#838)

This change makes it so /kick, /ban, and /map open the already created methods for displaying their menus when there are no args.

The reason for the feature is to take advantage of menus that already exist and to make the commands easier to use.

The client == 0 check prevents them from opening if it was ran via rcon, sm_rcon, or server command. Client auth is also checked because its a registered admin command.

Usage params will display if client == 0 and args < min

For example, a moderator wants to change a map, instead of running through the admin menu, they can instead type just /map to display available maps and choose one.

If a mod wants to quickly ban or kick someone without having to either run through the admin menu or type it out, they could then type the corresponding commands with no args to open the menus.
This commit is contained in:
JoinedSenses 2018-09-03 19:41:22 -04:00 committed by Asher Baker
parent 398522712e
commit a5b22498ce
3 changed files with 36 additions and 6 deletions

View File

@ -57,14 +57,20 @@ void PrepareBan(int client, int target, int time, const char[] reason)
if (reason[0] == '\0')
{
ShowActivity(client, "%t", "Permabanned player", name);
} else {
}
else
{
ShowActivity(client, "%t", "Permabanned player reason", name, reason);
}
} else {
}
else
{
if (reason[0] == '\0')
{
ShowActivity(client, "%t", "Banned player", name, time);
} else {
}
else
{
ShowActivity(client, "%t", "Banned player reason", name, time, reason);
}
}
@ -266,8 +272,16 @@ public int MenuHandler_BanTimeList(Menu menu, MenuAction action, int param1, int
public Action Command_Ban(int client, int args)
{
if (args < 2)
{
if ((GetCmdReplySource() == SM_REPLY_TO_CHAT) && (client != 0) && (args == 0))
{
DisplayBanTargetMenu(client);
}
else
{
ReplyToCommand(client, "[SM] Usage: sm_ban <#userid|name> <minutes|0> [reason]");
}
return Plugin_Handled;
}

View File

@ -124,8 +124,16 @@ public int MenuHandler_Kick(Menu menu, MenuAction action, int param1, int param2
public Action Command_Kick(int client, int args)
{
if (args < 1)
{
if ((GetCmdReplySource() == SM_REPLY_TO_CHAT) && (client != 0))
{
DisplayKickMenu(client);
}
else
{
ReplyToCommand(client, "[SM] Usage: sm_kick <#userid|name> [reason]");
}
return Plugin_Handled;
}

View File

@ -84,8 +84,16 @@ public void AdminMenu_Map(TopMenu topmenu,
public Action Command_Map(int client, int args)
{
if (args < 1)
{
if ((GetCmdReplySource() == SM_REPLY_TO_CHAT) && (client != 0))
{
g_MapList.SetTitle("%T", "Choose Map", client);
g_MapList.Display(client, MENU_TIME_FOREVER);
}
else
{
ReplyToCommand(client, "[SM] Usage: sm_map <map>");
}
return Plugin_Handled;
}