3 * =============================================================================
4 * SourceMod Basevotes Plugin
5 * Provides kick functionality
7 * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
8 * =============================================================================
10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License, version 3.0, as published by the
12 * Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
22 * As a special exception, AlliedModders LLC gives you permission to link the
23 * code of this program (as well as its derivative works) to "Half-Life 2," the
24 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
25 * by the Valve Corporation. You must obey the GNU General Public License in
26 * all respects for all other code used. Additionally, AlliedModders LLC grants
27 * this exception to all derivative works. AlliedModders LLC defines further
28 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
29 * or <http://www.sourcemod.net/license.php>.
35 DisplayVoteKickMenu(client, target)
37 g_voteClient[VOTE_CLIENTID] = target;
38 g_voteClient[VOTE_USERID] = GetClientUserId(target);
40 GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
42 LogAction(client, target, "\"%L\" initiated a kick vote against \"%L\"", client, target);
43 ShowActivity(client, "%t", "Initiated Vote Kick", g_voteInfo[VOTE_NAME]);
45 g_voteType = voteType:kick;
47 g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
48 SetMenuTitle(g_hVoteMenu, "Votekick Player");
49 AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
50 AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
51 SetMenuExitButton(g_hVoteMenu, false);
52 VoteMenuToAll(g_hVoteMenu, 20);
56 DisplayKickTargetMenu(client)
58 new Handle:menu = CreateMenu(MenuHandler_Kick);
60 decl String:title[100];
61 Format(title, sizeof(title), "%T:", "Kick vote", client);
62 SetMenuTitle(menu, title);
63 SetMenuExitBackButton(menu, true);
65 AddTargetsToMenu(menu, client, false, false);
67 DisplayMenu(menu, client, MENU_TIME_FOREVER);
70 public AdminMenu_VoteKick(Handle:topmenu,
72 TopMenuObject:object_id,
77 if (action == TopMenuAction_DisplayOption)
79 Format(buffer, maxlength, "%T", "Kick vote", param);
81 else if (action == TopMenuAction_SelectOption)
83 DisplayKickTargetMenu(param);
85 else if (action == TopMenuAction_DrawOption)
87 /* disable this option if a vote is already running */
88 buffer[0] = !IsNewVoteAllowed() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
92 public MenuHandler_Kick(Handle:menu, MenuAction:action, param1, param2)
94 if (action == MenuAction_End)
98 else if (action == MenuAction_Cancel)
100 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
102 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
105 else if (action == MenuAction_Select)
107 decl String:info[32], String:name[32];
110 GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name));
111 userid = StringToInt(info);
113 if ((target = GetClientOfUserId(userid)) == 0)
115 PrintToChat(param1, "[SM] %t", "Player no longer available");
117 else if (!CanUserTarget(param1, target))
119 PrintToChat(param1, "[SM] %t", "Unable to target");
124 DisplayVoteKickMenu(param1, target);
129 public Action:Command_Votekick(client, args)
133 ReplyToCommand(client, "[SM] Usage: sm_votekick <player> [reason]");
134 return Plugin_Handled;
137 if (IsVoteInProgress())
139 ReplyToCommand(client, "[SM] %t", "Vote in Progress");
140 return Plugin_Handled;
143 if (!TestVoteDelay(client))
145 return Plugin_Handled;
148 decl String:text[256], String:arg[64];
149 GetCmdArgString(text, sizeof(text));
151 new len = BreakString(text, arg, sizeof(arg));
153 new target = FindTarget(client, arg);
156 return Plugin_Handled;
161 strcopy(g_voteArg, sizeof(g_voteArg), text[len]);
168 DisplayVoteKickMenu(client, target);
170 return Plugin_Handled;