Fixed SDKTools dota build.
3 * =============================================================================
4 * SourceMod Basefuncommands Plugin
5 * Provides drug 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 new Handle:g_DrugTimers[MAXPLAYERS+1];
35 new Float:g_DrugAngles[20] = {0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 20.0, 15.0, 10.0, 5.0, 0.0, -5.0, -10.0, -15.0, -20.0, -25.0, -20.0, -15.0, -10.0, -5.0};
39 g_DrugTimers[client] = CreateTimer(1.0, Timer_Drug, client, TIMER_REPEAT);
44 KillDrugTimer(client);
47 GetClientEyeAngles(client, angs);
51 TeleportEntity(client, NULL_VECTOR, angs, NULL_VECTOR);
58 new flags = (0x0001 | 0x0010);
59 new color[4] = { 0, 0, 0, 0 };
61 new Handle:message = StartMessageEx(g_FadeUserMsgId, clients, 1);
63 if (GetUserMessageType() == UM_Protobuf)
65 PbSetInt(message, "duration", duration);
66 PbSetInt(message, "hold_time", holdtime);
67 PbSetInt(message, "flags", flags);
68 PbSetColor(message, "clr", color);
72 BfWriteShort(message, duration);
73 BfWriteShort(message, holdtime);
74 BfWriteShort(message, flags);
75 BfWriteByte(message, color[0]);
76 BfWriteByte(message, color[1]);
77 BfWriteByte(message, color[2]);
78 BfWriteByte(message, color[3]);
86 KillTimer(g_DrugTimers[client]);
87 g_DrugTimers[client] = INVALID_HANDLE;
92 for (new i = 1; i <= MaxClients; i++)
94 if (g_DrugTimers[i] != INVALID_HANDLE)
108 PerformDrug(client, target, toggle)
114 if (g_DrugTimers[target] == INVALID_HANDLE)
117 LogAction(client, target, "\"%L\" drugged \"%L\"", client, target);
122 LogAction(client, target, "\"%L\" undrugged \"%L\"", client, target);
128 if (g_DrugTimers[target] == INVALID_HANDLE)
131 LogAction(client, target, "\"%L\" drugged \"%L\"", client, target);
137 if (g_DrugTimers[target] != INVALID_HANDLE)
140 LogAction(client, target, "\"%L\" undrugged \"%L\"", client, target);
146 public Action:Timer_Drug(Handle:timer, any:client)
148 if (!IsClientInGame(client))
150 KillDrugTimer(client);
152 return Plugin_Handled;
155 if (!IsPlayerAlive(client))
159 return Plugin_Handled;
163 GetClientEyeAngles(client, angs);
165 angs[2] = g_DrugAngles[GetRandomInt(0,100) % 20];
167 TeleportEntity(client, NULL_VECTOR, angs, NULL_VECTOR);
175 new color[4] = { 0, 0, 0, 128 };
176 color[0] = GetRandomInt(0,255);
177 color[1] = GetRandomInt(0,255);
178 color[2] = GetRandomInt(0,255);
180 new Handle:message = StartMessageEx(g_FadeUserMsgId, clients, 1);
182 if (GetUserMessageType() == UM_Protobuf)
184 PbSetInt(message, "duration", duration);
185 PbSetInt(message, "hold_time", holdtime);
186 PbSetInt(message, "flags", flags);
187 PbSetColor(message, "clr", color);
191 BfWriteShort(message, duration);
192 BfWriteShort(message, holdtime);
193 BfWriteShort(message, flags);
194 BfWriteByte(message, color[0]);
195 BfWriteByte(message, color[1]);
196 BfWriteByte(message, color[2]);
197 BfWriteByte(message, color[3]);
202 return Plugin_Handled;
205 public AdminMenu_Drug(Handle:topmenu,
206 TopMenuAction:action,
207 TopMenuObject:object_id,
212 if (action == TopMenuAction_DisplayOption)
214 Format(buffer, maxlength, "%T", "Drug player", param);
216 else if (action == TopMenuAction_SelectOption)
218 DisplayDrugMenu(param);
222 DisplayDrugMenu(client)
224 new Handle:menu = CreateMenu(MenuHandler_Drug);
226 decl String:title[100];
227 Format(title, sizeof(title), "%T:", "Drug player", client);
228 SetMenuTitle(menu, title);
229 SetMenuExitBackButton(menu, true);
231 AddTargetsToMenu(menu, client, true, true);
233 DisplayMenu(menu, client, MENU_TIME_FOREVER);
236 public MenuHandler_Drug(Handle:menu, MenuAction:action, param1, param2)
238 if (action == MenuAction_End)
242 else if (action == MenuAction_Cancel)
244 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
246 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
249 else if (action == MenuAction_Select)
251 decl String:info[32];
254 GetMenuItem(menu, param2, info, sizeof(info));
255 userid = StringToInt(info);
257 if ((target = GetClientOfUserId(userid)) == 0)
259 PrintToChat(param1, "[SM] %t", "Player no longer available");
261 else if (!CanUserTarget(param1, target))
263 PrintToChat(param1, "[SM] %t", "Unable to target");
268 GetClientName(target, name, sizeof(name));
270 PerformDrug(param1, target, 2);
271 ShowActivity2(param1, "[SM] ", "%t", "Toggled drug on target", "_s", name);
274 /* Re-draw the menu if they're still valid */
275 if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
277 DisplayDrugMenu(param1);
282 public Action:Command_Drug(client, args)
286 ReplyToCommand(client, "[SM] Usage: sm_drug <#userid|name> [0/1]");
287 return Plugin_Handled;
291 GetCmdArg(1, arg, sizeof(arg));
297 GetCmdArg(2, arg2, sizeof(arg2));
298 if (StringToInt(arg2))
308 decl String:target_name[MAX_TARGET_LENGTH];
309 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
311 if ((target_count = ProcessTargetString(
316 COMMAND_FILTER_ALIVE,
321 ReplyToTargetError(client, target_count);
322 return Plugin_Handled;
325 for (new i = 0; i < target_count; i++)
327 PerformDrug(client, target_list[i], toggle);
332 ShowActivity2(client, "[SM] ", "%t", "Toggled drug on target", target_name);
336 ShowActivity2(client, "[SM] ", "%t", "Toggled drug on target", "_s", target_name);
339 return Plugin_Handled;