3 * =============================================================================
4 * SourceMod Basic Fun Commands Plugin
5 * Implements basic punishment commands.
7 * SourceMod (C)2004-2007 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 = "Basic Fun Commands",
44 author = "AlliedModders LLC",
45 description = "Basic 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 // -------------------------------------------------------------------------------
68 * Fire requires timebomb
70 #if TIMEBOMB == 0 && FIRE == 1
71 #error "TimeBomb requires Fire"
74 new Handle:hTopMenu = INVALID_HANDLE;
77 #define SOUND_BLIP "buttons/blip1.wav"
78 #define SOUND_BEEP "buttons/button17.wav"
79 #define SOUND_FINAL "weapons/cguard/charging.wav"
80 #define SOUND_BOOM "weapons/explode3.wav"
81 #define SOUND_FREEZE "physics/glass/glass_impact_bullet4.wav"
83 // Following are model indexes for temp entities
88 new g_ExplosionSprite;
90 // Basic color arrays for temp entities
91 new redColor[4] = {255, 75, 75, 255};
92 new orangeColor[4] = {255, 128, 0, 255};
93 new greenColor[4] = {75, 255, 75, 255};
94 new blueColor[4] = {75, 75, 255, 255};
95 new whiteColor[4] = {255, 255, 255, 255};
96 new greyColor[4] = {128, 128, 128, 255};
98 // UserMessageId for Fade.
99 new UserMsg:g_FadeUserMsgId;
101 // Include various commands and supporting functions
103 #include "basefuncommands/beacon.sp"
106 #include "basefuncommands/timebomb.sp"
109 #include "basefuncommands/fire.sp"
112 #include "basefuncommands/ice.sp"
115 #include "basefuncommands/gravity.sp"
118 #include "basefuncommands/blind.sp"
121 #include "basefuncommands/noclip.sp"
124 #include "basefuncommands/drug.sp"
127 public OnPluginStart()
129 LoadTranslations("common.phrases");
130 LoadTranslations("basefuncommands.phrases");
132 g_FadeUserMsgId = GetUserMessageId("Fade");
134 RegAdminCmd("sm_play", Command_Play, ADMFLAG_GENERIC, "sm_play <#userid|name> <filename>");
136 HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
139 SetupBeacon(); // sm_beacon
143 SetupTimeBomb(); // sm_timebomb
147 SetupFire(); // sm_burn and sm_firebomb
151 SetupIce(); // sm_freeze and sm_freezebomb
155 SetupGravity(); // sm_gravity
159 SetupBlind(); // sm_blind
163 SetupNoClip(); // sm_noclip
167 SetupDrugs(); // sm_drug
170 AutoExecConfig(true, "funcommands");
172 /* Account for late loading */
174 if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
176 OnAdminMenuReady(topmenu);
182 PrecacheSound(SOUND_BLIP, true);
183 PrecacheSound(SOUND_BEEP, true);
184 PrecacheSound(SOUND_FINAL, true);
185 PrecacheSound(SOUND_BOOM, true);
186 PrecacheSound(SOUND_FREEZE, true);
188 g_BeamSprite = PrecacheModel("materials/sprites/laser.vmt");
189 g_BeamSprite2 = PrecacheModel("sprites/bluelight1.vmt");
190 g_HaloSprite = PrecacheModel("materials/sprites/halo01.vmt");
191 g_GlowSprite = PrecacheModel("sprites/blueglow2.vmt");
192 g_ExplosionSprite = PrecacheModel("sprites/sprite_fire01.vmt");
214 public Action:Event_RoundEnd(Handle:event,const String:name[],bool:dontBroadcast)
232 return Plugin_Handled;
235 public OnAdminMenuReady(Handle:topmenu)
237 /* Block us from being called twice */
238 if (topmenu == hTopMenu)
243 /* Save the Handle */
246 /* Find the "Player Commands" category */
247 new TopMenuObject:player_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_PLAYERCOMMANDS);
249 if (player_commands != INVALID_TOPMENUOBJECT)
252 AddToTopMenu(hTopMenu,
262 AddToTopMenu(hTopMenu,
272 AddToTopMenu(hTopMenu,
280 AddToTopMenu(hTopMenu,
290 AddToTopMenu(hTopMenu,
298 AddToTopMenu(hTopMenu,
301 AdminMenu_FreezeBomb,
308 AddToTopMenu(hTopMenu,
318 AddToTopMenu(hTopMenu,
328 AddToTopMenu(hTopMenu,
338 AddToTopMenu(hTopMenu,
349 public Action:Command_Play(client, args)
353 ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
356 new String:Arguments[PLATFORM_MAX_PATH + 65];
357 GetCmdArgString(Arguments, sizeof(Arguments));
360 new len = BreakString(Arguments, Arg, sizeof(Arg));
362 /* Make sure it does not go out of bound by doing "sm_play user "*/
365 ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
366 return Plugin_Handled;
369 /* Incase they put quotes and white spaces after the quotes */
370 if (Arguments[len] == '"')
373 new FileLen = TrimString(Arguments[len]) + len;
375 if (Arguments[FileLen - 1] == '"')
377 Arguments[FileLen - 1] = '\0';
381 decl String:target_name[MAX_TARGET_LENGTH];
382 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
384 if ((target_count = ProcessTargetString(
389 COMMAND_FILTER_NO_BOTS,
394 ReplyToTargetError(client, target_count);
395 return Plugin_Handled;
398 for (new i = 0; i < target_count; i++)
400 ClientCommand(target_list[i], "playgamesound \"%s\"", Arguments[len]);
401 LogAction(client, target_list[i], "\"%L\" played sound on \"%L\" (file \"%s\")", client, target_list[i], Arguments[len]);
406 ShowActivity2(client, "[SM] ", "%t", "Played sound to target", target_name);
410 ShowActivity2(client, "[SM] ", "%t", "Played sound to target", "_s", target_name);
413 return Plugin_Handled;