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 new Handle:hTopMenu = INVALID_HANDLE;
53 #define SOUND_BLIP "buttons/blip1.wav"
54 #define SOUND_BEEP "buttons/button17.wav"
55 #define SOUND_FINAL "weapons/cguard/charging.wav"
56 #define SOUND_BOOM "weapons/explode3.wav"
57 #define SOUND_FREEZE "physics/glass/glass_impact_bullet4.wav"
59 // Following are model indexes for temp entities
64 new g_ExplosionSprite;
66 // Basic color arrays for temp entities
67 new redColor[4] = {255, 75, 75, 255};
68 new orangeColor[4] = {255, 128, 0, 255};
69 new greenColor[4] = {75, 255, 75, 255};
70 new blueColor[4] = {75, 75, 255, 255};
71 new whiteColor[4] = {255, 255, 255, 255};
72 new greyColor[4] = {128, 128, 128, 255};
74 // Used for some trace rays.
76 new g_FilteredEntity = -1;
77 public bool:TR_Filter_Client(ent, contentMask)
79 return (ent == g_FilteredEntity) ? false : true;
83 // Include various commands and supporting functions
84 #include "basefuncommands/beacon.sp"
85 #include "basefuncommands/timebomb.sp"
86 #include "basefuncommands/fire.sp"
87 #include "basefuncommands/ice.sp"
89 public OnPluginStart()
91 LoadTranslations("common.phrases");
92 LoadTranslations("basefuncommands.phrases");
94 RegAdminCmd("sm_play", Command_Play, ADMFLAG_GENERIC, "sm_play <#userid|name> <filename>");
96 HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
98 SetupBeacon(); // sm_beacon
99 SetupTimeBomb(); // sm_timebomb
100 SetupFire(); // sm_burn and sm_firebomb
101 SetupIce(); // sm_freeze and sm_freezebomb
103 AutoExecConfig(true, "funcommands");
105 /* Account for late loading */
107 if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
109 OnAdminMenuReady(topmenu);
115 PrecacheSound(SOUND_BLIP, true);
116 PrecacheSound(SOUND_BEEP, true);
117 PrecacheSound(SOUND_FINAL, true);
118 PrecacheSound(SOUND_BOOM, true);
119 PrecacheSound(SOUND_FREEZE, true);
121 g_BeamSprite = PrecacheModel("materials/sprites/laser.vmt");
122 g_BeamSprite2 = PrecacheModel("sprites/bluelight1.vmt");
123 g_HaloSprite = PrecacheModel("materials/sprites/halo01.vmt");
124 g_GlowSprite = PrecacheModel("sprites/blueglow2.vmt");
125 g_ExplosionSprite = PrecacheModel("sprites/sprite_fire01.vmt");
136 public Action:Event_RoundEnd(Handle:event,const String:name[],bool:dontBroadcast)
143 return Plugin_Handled;
146 public OnAdminMenuReady(Handle:topmenu)
148 /* Block us from being called twice */
149 if (topmenu == hTopMenu)
154 /* Save the Handle */
157 /* Find the "Player Commands" category */
158 new TopMenuObject:player_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_PLAYERCOMMANDS);
160 if (player_commands != INVALID_TOPMENUOBJECT)
162 AddToTopMenu(hTopMenu,
170 AddToTopMenu(hTopMenu,
178 AddToTopMenu(hTopMenu,
186 AddToTopMenu(hTopMenu,
194 AddToTopMenu(hTopMenu,
202 AddToTopMenu(hTopMenu,
205 AdminMenu_FreezeBomb,
212 public Action:Command_Play(client, args)
216 ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
219 new String:Arguments[PLATFORM_MAX_PATH + 65];
220 GetCmdArgString(Arguments, sizeof(Arguments));
223 new len = BreakString(Arguments, Arg, sizeof(Arg));
225 /* Make sure it does not go out of bound by doing "sm_play user "*/
228 ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
229 return Plugin_Handled;
232 /* Incase they put quotes and white spaces after the quotes */
233 if (Arguments[len] == '"')
236 new FileLen = TrimString(Arguments[len]) + len;
238 if (Arguments[FileLen - 1] == '"')
240 Arguments[FileLen - 1] = '\0';
244 decl String:target_name[MAX_TARGET_LENGTH];
245 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
247 if ((target_count = ProcessTargetString(
252 COMMAND_FILTER_NO_BOTS,
257 ReplyToTargetError(client, target_count);
258 return Plugin_Handled;
261 for (new i = 0; i < target_count; i++)
263 ClientCommand(target_list[i], "playgamesound \"%s\"", Arguments[len]);
264 LogAction(client, target_list[i], "\"%L\" played sound on \"%L\" (file \"%s\")", client, target_list[i], Arguments[len]);
269 ShowActivity2(client, "[SM] ", "%t", "Played sound to target", target_name);
273 ShowActivity2(client, "[SM] ", "%t", "Played sound to target", "_s", target_name);
276 return Plugin_Handled;