Finally, paths sorted out I think.
3 * =============================================================================
4 * SourceMod Basic Fun Commands Plugin
5 * Implements basic punishment commands.
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>.
41 public Plugin:myinfo =
43 name = "Fun Commands",
44 author = "AlliedModders LLC",
45 description = "Fun Commands",
46 version = SOURCEMOD_VERSION,
47 url = "http://www.sourcemod.net/"
50 // -------------------------------------------------------------------------------
51 // Set any of these to 0 and recompile to completely disable those commands
52 // -------------------------------------------------------------------------------
65 // -------------------------------------------------------------------------------
67 new Handle:hTopMenu = INVALID_HANDLE;
70 #define SOUND_BLIP "buttons/blip1.wav"
71 #define SOUND_BEEP "buttons/button17.wav"
72 #define SOUND_FINAL "weapons/cguard/charging.wav"
73 #define SOUND_BOOM "weapons/explode3.wav"
74 #define SOUND_FREEZE "physics/glass/glass_impact_bullet4.wav"
76 // Following are model indexes for temp entities
81 new g_ExplosionSprite;
83 // Basic color arrays for temp entities
84 new redColor[4] = {255, 75, 75, 255};
85 new orangeColor[4] = {255, 128, 0, 255};
86 new greenColor[4] = {75, 255, 75, 255};
87 new blueColor[4] = {75, 75, 255, 255};
88 new whiteColor[4] = {255, 255, 255, 255};
89 new greyColor[4] = {128, 128, 128, 255};
91 // UserMessageId for Fade.
92 new UserMsg:g_FadeUserMsgId;
94 // Include various commands and supporting functions
96 #include "funcommands/beacon.sp"
99 #include "funcommands/timebomb.sp"
102 #include "funcommands/fire.sp"
105 #include "funcommands/ice.sp"
108 #include "funcommands/gravity.sp"
111 #include "funcommands/blind.sp"
114 #include "funcommands/noclip.sp"
117 #include "funcommands/drug.sp"
120 public OnPluginStart()
122 if (FindPluginByFile("basefuncommands.smx") != INVALID_HANDLE)
124 ThrowError("This plugin replaces basefuncommands. You cannot run both at once.");
127 LoadTranslations("common.phrases");
128 LoadTranslations("funcommands.phrases");
130 g_FadeUserMsgId = GetUserMessageId("Fade");
132 RegAdminCmd("sm_play", Command_Play, ADMFLAG_GENERIC, "sm_play <#userid|name> <filename>");
134 HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
137 SetupBeacon(); // sm_beacon
141 SetupTimeBomb(); // sm_timebomb
145 SetupFire(); // sm_burn and sm_firebomb
149 SetupIce(); // sm_freeze and sm_freezebomb
153 SetupGravity(); // sm_gravity
157 SetupBlind(); // sm_blind
161 SetupNoClip(); // sm_noclip
165 SetupDrugs(); // sm_drug
168 AutoExecConfig(true, "funcommands");
170 /* Account for late loading */
172 if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
174 OnAdminMenuReady(topmenu);
180 PrecacheSound(SOUND_BLIP, true);
181 PrecacheSound(SOUND_BEEP, true);
182 PrecacheSound(SOUND_FINAL, true);
183 PrecacheSound(SOUND_BOOM, true);
184 PrecacheSound(SOUND_FREEZE, true);
186 g_BeamSprite = PrecacheModel("materials/sprites/laser.vmt");
187 g_BeamSprite2 = PrecacheModel("sprites/bluelight1.vmt");
188 g_HaloSprite = PrecacheModel("materials/sprites/halo01.vmt");
189 g_GlowSprite = PrecacheModel("sprites/blueglow2.vmt");
190 g_ExplosionSprite = PrecacheModel("sprites/sprite_fire01.vmt");
212 public Action:Event_RoundEnd(Handle:event,const String:name[],bool:dontBroadcast)
230 return Plugin_Handled;
233 public OnAdminMenuReady(Handle:topmenu)
235 /* Block us from being called twice */
236 if (topmenu == hTopMenu)
241 /* Save the Handle */
244 /* Find the "Player Commands" category */
245 new TopMenuObject:player_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_PLAYERCOMMANDS);
247 if (player_commands != INVALID_TOPMENUOBJECT)
250 AddToTopMenu(hTopMenu,
260 AddToTopMenu(hTopMenu,
270 AddToTopMenu(hTopMenu,
278 AddToTopMenu(hTopMenu,
288 AddToTopMenu(hTopMenu,
296 AddToTopMenu(hTopMenu,
299 AdminMenu_FreezeBomb,
306 AddToTopMenu(hTopMenu,
316 AddToTopMenu(hTopMenu,
326 AddToTopMenu(hTopMenu,
336 AddToTopMenu(hTopMenu,
347 public Action:Command_Play(client, args)
351 ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
354 new String:Arguments[PLATFORM_MAX_PATH + 65];
355 GetCmdArgString(Arguments, sizeof(Arguments));
358 new len = BreakString(Arguments, Arg, sizeof(Arg));
360 /* Make sure it does not go out of bound by doing "sm_play user "*/
363 ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
364 return Plugin_Handled;
367 /* Incase they put quotes and white spaces after the quotes */
368 if (Arguments[len] == '"')
371 new FileLen = TrimString(Arguments[len]) + len;
373 if (Arguments[FileLen - 1] == '"')
375 Arguments[FileLen - 1] = '\0';
379 decl String:target_name[MAX_TARGET_LENGTH];
380 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
382 if ((target_count = ProcessTargetString(
387 COMMAND_FILTER_NO_BOTS,
392 ReplyToTargetError(client, target_count);
393 return Plugin_Handled;
396 for (new i = 0; i < target_count; i++)
398 ClientCommand(target_list[i], "playgamesound \"%s\"", Arguments[len]);
399 LogAction(client, target_list[i], "\"%L\" played sound on \"%L\" (file \"%s\")", client, target_list[i], Arguments[len]);
404 ShowActivity2(client, "[SM] ", "%t", "Played sound to target", target_name);
408 ShowActivity2(client, "[SM] ", "%t", "Played sound to target", "_s", target_name);
411 return Plugin_Handled;