3 * =============================================================================
4 * SourceMod Basefunvotes Plugin
5 * Provides voteburn 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>.
34 DisplayVoteBurnMenu(client, target, String:name[])
36 if (!IsPlayerAlive(target))
38 ReplyToCommand(client, "[SM] %t", "Cannot be performed on dead", name);
42 g_voteClient[VOTE_CLIENTID] = target;
43 GetClientName(target, g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]));
45 LogAction(client, target, "\"%L\" initiated a burn vote against \"%L\"", client, target);
46 ShowActivity2(client, "[SM] ", "%t", "Initiated Vote Burn", g_voteInfo[VOTE_NAME]);
48 g_voteType = voteType:burn;
50 g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
51 SetMenuTitle(g_hVoteMenu, "Voteburn player");
52 AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes");
53 AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
54 SetMenuExitButton(g_hVoteMenu, false);
55 VoteMenuToAll(g_hVoteMenu, 20);
58 DisplayBurnTargetMenu(client)
60 new Handle:menu = CreateMenu(MenuHandler_Burn);
62 decl String:title[100];
63 Format(title, sizeof(title), "%T:", "Burn vote", client);
64 SetMenuTitle(menu, title);
65 SetMenuExitBackButton(menu, true);
67 AddTargetsToMenu(menu, client, true, true);
69 DisplayMenu(menu, client, MENU_TIME_FOREVER);
72 public AdminMenu_VoteBurn(Handle:topmenu,
74 TopMenuObject:object_id,
79 if (action == TopMenuAction_DisplayOption)
81 Format(buffer, maxlength, "%T", "Burn vote", param);
83 else if (action == TopMenuAction_SelectOption)
85 DisplayBurnTargetMenu(param);
87 else if (action == TopMenuAction_DrawOption)
89 /* disable this option if a vote is already running */
90 buffer[0] = !IsNewVoteAllowed() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
94 public MenuHandler_Burn(Handle:menu, MenuAction:action, param1, param2)
96 if (action == MenuAction_End)
100 else if (action == MenuAction_Cancel)
102 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
104 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
107 else if (action == MenuAction_Select)
109 decl String:info[32], String:name[32];
112 GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name));
113 userid = StringToInt(info);
115 if ((target = GetClientOfUserId(userid)) == 0)
117 PrintToChat(param1, "[SM] %t", "Player no longer available");
119 else if (!CanUserTarget(param1, target))
121 PrintToChat(param1, "[SM] %t", "Unable to target");
123 else if (!IsPlayerAlive(target))
125 PrintToChat(param1, "[SM] %t", "Player has since died");
129 DisplayVoteBurnMenu(param1, target, name);
134 public Action:Command_VoteBurn(client, args)
138 ReplyToCommand(client, "[SM] Usage: sm_voteburn <player>");
139 return Plugin_Handled;
142 if (IsVoteInProgress())
144 ReplyToCommand(client, "[SM] %t", "Vote in Progress");
145 return Plugin_Handled;
148 if (!TestVoteDelay(client))
150 return Plugin_Handled;
153 decl String:text[256], String:arg[64];
154 GetCmdArgString(text, sizeof(text));
156 BreakString(text, arg, sizeof(arg));
158 decl String:target_name[MAX_TARGET_LENGTH];
159 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
161 if ((target_count = ProcessTargetString(
166 COMMAND_FILTER_NO_MULTI,
171 ReplyToTargetError(client, target_count);
172 return Plugin_Handled;
175 DisplayVoteBurnMenu(client, target_list[0], arg);
177 return Plugin_Handled;