1.1 --- a/plugins/basecommands/kick.sp Fri Mar 28 06:21:34 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,161 +0,0 @@
1.4 -
1.5 -PerformKick(client, target, const String:reason[])
1.6 -{
1.7 - LogAction(client, target, "\"%L\" kicked \"%L\" (reason \"%s\")", client, target, reason);
1.8 -
1.9 - if (reason[0] == '\0')
1.10 - {
1.11 - KickClient(target, "%t", "Kicked by admin");
1.12 - }
1.13 - else
1.14 - {
1.15 - KickClient(target, "%s", reason);
1.16 - }
1.17 -}
1.18 -
1.19 -DisplayKickMenu(client)
1.20 -{
1.21 - new Handle:menu = CreateMenu(MenuHandler_Kick);
1.22 -
1.23 - decl String:title[100];
1.24 - Format(title, sizeof(title), "%T:", "Kick player", client);
1.25 - SetMenuTitle(menu, title);
1.26 - SetMenuExitBackButton(menu, true);
1.27 -
1.28 - AddTargetsToMenu(menu, client, false, false);
1.29 -
1.30 - DisplayMenu(menu, client, MENU_TIME_FOREVER);
1.31 -}
1.32 -
1.33 -public AdminMenu_Kick(Handle:topmenu,
1.34 - TopMenuAction:action,
1.35 - TopMenuObject:object_id,
1.36 - param,
1.37 - String:buffer[],
1.38 - maxlength)
1.39 -{
1.40 - if (action == TopMenuAction_DisplayOption)
1.41 - {
1.42 - Format(buffer, maxlength, "%T", "Kick player", param);
1.43 - }
1.44 - else if (action == TopMenuAction_SelectOption)
1.45 - {
1.46 - DisplayKickMenu(param);
1.47 - }
1.48 -}
1.49 -
1.50 -public MenuHandler_Kick(Handle:menu, MenuAction:action, param1, param2)
1.51 -{
1.52 - if (action == MenuAction_End)
1.53 - {
1.54 - CloseHandle(menu);
1.55 - }
1.56 - else if (action == MenuAction_Cancel)
1.57 - {
1.58 - if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
1.59 - {
1.60 - DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
1.61 - }
1.62 - }
1.63 - else if (action == MenuAction_Select)
1.64 - {
1.65 - decl String:info[32];
1.66 - new userid, target;
1.67 -
1.68 - GetMenuItem(menu, param2, info, sizeof(info));
1.69 - userid = StringToInt(info);
1.70 -
1.71 - if ((target = GetClientOfUserId(userid)) == 0)
1.72 - {
1.73 - PrintToChat(param1, "[SM] %t", "Player no longer available");
1.74 - }
1.75 - else if (!CanUserTarget(param1, target))
1.76 - {
1.77 - PrintToChat(param1, "[SM] %t", "Unable to target");
1.78 - }
1.79 - else
1.80 - {
1.81 - decl String:name[MAX_NAME_LENGTH];
1.82 - GetClientName(target, name, sizeof(name));
1.83 - ShowActivity2(param1, "[SM] ", "%t", "Kicked target", "_s", name);
1.84 - PerformKick(param1, target, "");
1.85 - }
1.86 -
1.87 - /* Re-draw the menu if they're still valid */
1.88 - if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
1.89 - {
1.90 - DisplayKickMenu(param1);
1.91 - }
1.92 - }
1.93 -}
1.94 -
1.95 -public Action:Command_Kick(client, args)
1.96 -{
1.97 - if (args < 1)
1.98 - {
1.99 - ReplyToCommand(client, "[SM] Usage: sm_kick <#userid|name> [reason]");
1.100 - return Plugin_Handled;
1.101 - }
1.102 -
1.103 - decl String:Arguments[256];
1.104 - GetCmdArgString(Arguments, sizeof(Arguments));
1.105 -
1.106 - decl String:arg[65];
1.107 - new len = BreakString(Arguments, arg, sizeof(arg));
1.108 -
1.109 - if (len == -1)
1.110 - {
1.111 - /* Safely null terminate */
1.112 - len = 0;
1.113 - Arguments[0] = '\0';
1.114 - }
1.115 -
1.116 - decl String:target_name[MAX_TARGET_LENGTH];
1.117 - decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
1.118 -
1.119 - if ((target_count = ProcessTargetString(
1.120 - arg,
1.121 - client,
1.122 - target_list,
1.123 - MAXPLAYERS,
1.124 - COMMAND_FILTER_CONNECTED,
1.125 - target_name,
1.126 - sizeof(target_name),
1.127 - tn_is_ml)) > 0)
1.128 - {
1.129 - if (tn_is_ml)
1.130 - {
1.131 - ShowActivity2(client, "[SM] ", "%t", "Kicked target", target_name);
1.132 - }
1.133 - else
1.134 - {
1.135 - ShowActivity2(client, "[SM] ", "%t", "Kicked target", "_s", target_name);
1.136 - }
1.137 -
1.138 - new kick_self = 0;
1.139 -
1.140 - for (new i = 0; i < target_count; i++)
1.141 - {
1.142 - /* Kick everyone else first */
1.143 - if (target_list[i] == client)
1.144 - {
1.145 - kick_self = client;
1.146 - }
1.147 - else
1.148 - {
1.149 - PerformKick(client, target_list[i], Arguments[len]);
1.150 - }
1.151 - }
1.152 -
1.153 - if (kick_self)
1.154 - {
1.155 - PerformKick(client, client, Arguments[len]);
1.156 - }
1.157 - }
1.158 - else
1.159 - {
1.160 - ReplyToTargetError(client, target_count);
1.161 - }
1.162 -
1.163 - return Plugin_Handled;
1.164 -}