ds@1952: /**
ds@1952: * vim: set ts=4 :
ds@1952: * =============================================================================
ds@1952: * SourceMod Basic Fun Commands Plugin
ds@1952: * Implements basic punishment commands.
ds@1952: *
ds@1952: * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
ds@1952: * =============================================================================
ds@1952: *
ds@1952: * This program is free software; you can redistribute it and/or modify it under
ds@1952: * the terms of the GNU General Public License, version 3.0, as published by the
ds@1952: * Free Software Foundation.
ds@1952: *
ds@1952: * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1952: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1952: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
ds@1952: * details.
ds@1952: *
ds@1952: * You should have received a copy of the GNU General Public License along with
ds@1952: * this program. If not, see .
ds@1952: *
ds@1952: * As a special exception, AlliedModders LLC gives you permission to link the
ds@1952: * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1952: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1952: * by the Valve Corporation. You must obey the GNU General Public License in
ds@1952: * all respects for all other code used. Additionally, AlliedModders LLC grants
ds@1952: * this exception to all derivative works. AlliedModders LLC defines further
ds@1952: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1952: * or .
ds@1952: *
ds@1952: * Version: $Id$
ds@1952: */
ds@1952:
ds@1952: #pragma semicolon 1
ds@1952:
ds@1952: #include
ds@1952: #include
ds@1952: #undef REQUIRE_PLUGIN
ds@1952: #include
ds@1952:
ds@1952: public Plugin:myinfo =
ds@1952: {
ds@1952: name = "Fun Commands",
ds@1952: author = "AlliedModders LLC",
ds@1952: description = "Fun Commands",
ds@1952: version = SOURCEMOD_VERSION,
ds@1952: url = "http://www.sourcemod.net/"
ds@1952: };
ds@1952:
ds@1952: // -------------------------------------------------------------------------------
ds@1952: // Set any of these to 0 and recompile to completely disable those commands
ds@1952: // -------------------------------------------------------------------------------
ds@1952: #define BEACON 1
ds@1952: #define TIMEBOMB 1
ds@1952: #define FIRE 1
ds@1952: #define ICE 1
ds@1952: #define GRAVITY 1
ds@1952: #define BLIND 1
ds@1952: #define NOCLIP 1
ds@1952: #define DRUG 1
ds@1952: #define TELEPORT 1
ds@1952: #define HEALTH 1
ds@1952: #define COLORS 1
ds@1952: #define CASH 1
ds@1952: // -------------------------------------------------------------------------------
ds@1952:
ds@1952: new Handle:hTopMenu = INVALID_HANDLE;
ds@1952:
ds@1952: // Sounds
ds@1952: #define SOUND_BLIP "buttons/blip1.wav"
ds@1952: #define SOUND_BEEP "buttons/button17.wav"
ds@1952: #define SOUND_FINAL "weapons/cguard/charging.wav"
ds@1952: #define SOUND_BOOM "weapons/explode3.wav"
ds@1952: #define SOUND_FREEZE "physics/glass/glass_impact_bullet4.wav"
ds@1952:
ds@1952: // Following are model indexes for temp entities
ds@1952: new g_BeamSprite;
ds@1952: new g_BeamSprite2;
ds@1952: new g_HaloSprite;
ds@1952: new g_GlowSprite;
ds@1952: new g_ExplosionSprite;
ds@1952:
ds@1952: // Basic color arrays for temp entities
ds@1952: new redColor[4] = {255, 75, 75, 255};
ds@1952: new orangeColor[4] = {255, 128, 0, 255};
ds@1952: new greenColor[4] = {75, 255, 75, 255};
ds@1952: new blueColor[4] = {75, 75, 255, 255};
ds@1952: new whiteColor[4] = {255, 255, 255, 255};
ds@1952: new greyColor[4] = {128, 128, 128, 255};
ds@1952:
ds@1952: // UserMessageId for Fade.
ds@1952: new UserMsg:g_FadeUserMsgId;
ds@1952:
ds@1952: // Include various commands and supporting functions
ds@1952: #if BEACON
ds@1952: #include "funcommands/beacon.sp"
ds@1952: #endif
ds@1952: #if TIMEBOMB
ds@1952: #include "funcommands/timebomb.sp"
ds@1952: #endif
ds@1952: #if FIRE
ds@1952: #include "funcommands/fire.sp"
ds@1952: #endif
ds@1952: #if ICE
ds@1952: #include "funcommands/ice.sp"
ds@1952: #endif
ds@1952: #if GRAVITY
ds@1952: #include "funcommands/gravity.sp"
ds@1952: #endif
ds@1952: #if BLIND
ds@1952: #include "funcommands/blind.sp"
ds@1952: #endif
ds@1952: #if NOCLIP
ds@1952: #include "funcommands/noclip.sp"
ds@1952: #endif
ds@1952: #if DRUG
ds@1952: #include "funcommands/drug.sp"
ds@1952: #endif
ds@1952:
ds@1952: public OnPluginStart()
ds@1952: {
ds@1952: if (FindPluginByFile("basefuncommands.smx") != INVALID_HANDLE)
ds@1952: {
ds@1952: ThrowError("This plugin replaces basefuncommands. You cannot run both at once.");
ds@1952: }
ds@1952:
ds@1952: LoadTranslations("common.phrases");
dvander@2020: LoadTranslations("funcommands.phrases");
ds@1952:
ds@1952: g_FadeUserMsgId = GetUserMessageId("Fade");
ds@1952:
ds@1952: RegAdminCmd("sm_play", Command_Play, ADMFLAG_GENERIC, "sm_play <#userid|name> ");
ds@1952:
ds@1952: HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
ds@1952:
ds@1952: #if BEACON
ds@1952: SetupBeacon(); // sm_beacon
ds@1952: #endif
ds@1952:
ds@1952: #if TIMEBOMB
ds@1952: SetupTimeBomb(); // sm_timebomb
ds@1952: #endif
ds@1952:
ds@1952: #if FIRE
ds@1952: SetupFire(); // sm_burn and sm_firebomb
ds@1952: #endif
ds@1952:
ds@1952: #if ICE
ds@1952: SetupIce(); // sm_freeze and sm_freezebomb
ds@1952: #endif
ds@1952:
ds@1952: #if GRAVITY
ds@1952: SetupGravity(); // sm_gravity
ds@1952: #endif
ds@1952:
ds@1952: #if BLIND
ds@1952: SetupBlind(); // sm_blind
ds@1952: #endif
ds@1952:
ds@1952: #if NOCLIP
ds@1952: SetupNoClip(); // sm_noclip
ds@1952: #endif
ds@1952:
ds@1952: #if DRUG
ds@1952: SetupDrugs(); // sm_drug
ds@1952: #endif
ds@1952:
ds@1952: AutoExecConfig(true, "funcommands");
ds@1952:
ds@1952: /* Account for late loading */
ds@1952: new Handle:topmenu;
ds@1952: if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
ds@1952: {
ds@1952: OnAdminMenuReady(topmenu);
ds@1952: }
ds@1952: }
ds@1952:
ds@1952: public OnMapStart()
ds@1952: {
ds@1952: PrecacheSound(SOUND_BLIP, true);
ds@1952: PrecacheSound(SOUND_BEEP, true);
ds@1952: PrecacheSound(SOUND_FINAL, true);
ds@1952: PrecacheSound(SOUND_BOOM, true);
ds@1952: PrecacheSound(SOUND_FREEZE, true);
ds@1952:
ds@1952: g_BeamSprite = PrecacheModel("materials/sprites/laser.vmt");
ds@1952: g_BeamSprite2 = PrecacheModel("sprites/bluelight1.vmt");
ds@1952: g_HaloSprite = PrecacheModel("materials/sprites/halo01.vmt");
ds@1952: g_GlowSprite = PrecacheModel("sprites/blueglow2.vmt");
ds@1952: g_ExplosionSprite = PrecacheModel("sprites/sprite_fire01.vmt");
ds@1952: }
ds@1952:
ds@1952: public OnMapEnd()
ds@1952: {
ds@1952: #if BEACON
ds@1952: KillAllBeacons();
ds@1952: #endif
ds@1952: #if TIMEBOMB
ds@1952: KillAllTimeBombs();
ds@1952: #endif
ds@1952: #if FIRE
ds@1952: KillAllFireBombs();
ds@1952: #endif
ds@1952: #if ICE
ds@1952: KillAllFreezes();
ds@1952: #endif
ds@1952: #if DRUG
ds@1952: KillAllDrugs();
ds@1952: #endif
ds@1952: }
ds@1952:
ds@1952: public Action:Event_RoundEnd(Handle:event,const String:name[],bool:dontBroadcast)
ds@1952: {
ds@1952: #if BEACON
ds@1952: KillAllBeacons();
ds@1952: #endif
ds@1952: #if TIMEBOMB
ds@1952: KillAllTimeBombs();
ds@1952: #endif
ds@1952: #if FIRE
ds@1952: KillAllFireBombs();
ds@1952: #endif
ds@1952: #if ICE
ds@1952: KillAllFreezes();
ds@1952: #endif
ds@1952: #if DRUG
ds@1952: KillAllDrugs();
ds@1952: #endif
ds@1952:
ds@1952: return Plugin_Handled;
ds@1952: }
ds@1952:
ds@1952: public OnAdminMenuReady(Handle:topmenu)
ds@1952: {
ds@1952: /* Block us from being called twice */
ds@1952: if (topmenu == hTopMenu)
ds@1952: {
ds@1952: return;
ds@1952: }
ds@1952:
ds@1952: /* Save the Handle */
ds@1952: hTopMenu = topmenu;
ds@1952:
ds@1952: /* Find the "Player Commands" category */
ds@1952: new TopMenuObject:player_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_PLAYERCOMMANDS);
ds@1952:
ds@1952: if (player_commands != INVALID_TOPMENUOBJECT)
ds@1952: {
ds@1952: #if BEACON
ds@1952: AddToTopMenu(hTopMenu,
ds@1952: "sm_beacon",
ds@1952: TopMenuObject_Item,
ds@1952: AdminMenu_Beacon,
ds@1952: player_commands,
ds@1952: "sm_beacon",
ds@1952: ADMFLAG_SLAY);
ds@1952: #endif
ds@1952:
ds@1952: #if TIMEBOMB
ds@1952: AddToTopMenu(hTopMenu,
ds@1952: "sm_timebomb",
ds@1952: TopMenuObject_Item,
ds@1952: AdminMenu_TimeBomb,
ds@1952: player_commands,
ds@1952: "sm_timebomb",
ds@1952: ADMFLAG_SLAY);
ds@1952: #endif
ds@1952:
ds@1952: #if FIRE
ds@1952: AddToTopMenu(hTopMenu,
ds@1952: "sm_burn",
ds@1952: TopMenuObject_Item,
ds@1952: AdminMenu_Burn,
ds@1952: player_commands,
ds@1952: "sm_burn",
ds@1952: ADMFLAG_SLAY);
ds@1952:
ds@1952: AddToTopMenu(hTopMenu,
ds@1952: "sm_firebomb",
ds@1952: TopMenuObject_Item,
ds@1952: AdminMenu_FireBomb,
ds@1952: player_commands,
ds@1952: "sm_firebomb",
ds@1952: ADMFLAG_SLAY);
ds@1952: #endif
ds@1952:
ds@1952: #if ICE
ds@1952: AddToTopMenu(hTopMenu,
ds@1952: "sm_freeze",
ds@1952: TopMenuObject_Item,
ds@1952: AdminMenu_Freeze,
ds@1952: player_commands,
ds@1952: "sm_freeze",
ds@1952: ADMFLAG_SLAY);
ds@1952:
ds@1952: AddToTopMenu(hTopMenu,
ds@1952: "sm_freezebomb",
ds@1952: TopMenuObject_Item,
ds@1952: AdminMenu_FreezeBomb,
ds@1952: player_commands,
ds@1952: "sm_freezebomb",
ds@1952: ADMFLAG_SLAY);
ds@1952: #endif
ds@1952:
ds@1952: #if GRAVITY
ds@1952: AddToTopMenu(hTopMenu,
ds@1952: "sm_gravity",
ds@1952: TopMenuObject_Item,
ds@1952: AdminMenu_Gravity,
ds@1952: player_commands,
ds@1952: "sm_gravity",
ds@1952: ADMFLAG_SLAY);
ds@1952: #endif
ds@1952:
ds@1952: #if BLIND
ds@1952: AddToTopMenu(hTopMenu,
ds@1952: "sm_blind",
ds@1952: TopMenuObject_Item,
ds@1952: AdminMenu_Blind,
ds@1952: player_commands,
ds@1952: "sm_blind",
ds@1952: ADMFLAG_SLAY);
ds@1952: #endif
ds@1952:
ds@1952: #if NOCLIP
ds@1952: AddToTopMenu(hTopMenu,
ds@1952: "sm_noclip",
ds@1952: TopMenuObject_Item,
ds@1952: AdminMenu_NoClip,
ds@1952: player_commands,
ds@1952: "sm_noclip",
ds@1952: ADMFLAG_SLAY);
ds@1952: #endif
ds@1952:
ds@1952: #if DRUG
ds@1952: AddToTopMenu(hTopMenu,
ds@1952: "sm_drug",
ds@1952: TopMenuObject_Item,
ds@1952: AdminMenu_Drug,
ds@1952: player_commands,
ds@1952: "sm_drug",
ds@1952: ADMFLAG_SLAY);
ds@1952: #endif
ds@1952: }
ds@1952: }
ds@1952:
ds@1952: public Action:Command_Play(client, args)
ds@1952: {
ds@1952: if (args < 2)
ds@1952: {
ds@1952: ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> ");
ds@1952: }
ds@1952:
ds@1952: new String:Arguments[PLATFORM_MAX_PATH + 65];
ds@1952: GetCmdArgString(Arguments, sizeof(Arguments));
ds@1952:
ds@1952: decl String:Arg[65];
ds@1952: new len = BreakString(Arguments, Arg, sizeof(Arg));
ds@1952:
ds@1952: /* Make sure it does not go out of bound by doing "sm_play user "*/
ds@1952: if (len == -1)
ds@1952: {
ds@1952: ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> ");
ds@1952: return Plugin_Handled;
ds@1952: }
ds@1952:
ds@1952: /* Incase they put quotes and white spaces after the quotes */
ds@1952: if (Arguments[len] == '"')
ds@1952: {
ds@1952: len++;
ds@1952: new FileLen = TrimString(Arguments[len]) + len;
ds@1952:
ds@1952: if (Arguments[FileLen - 1] == '"')
ds@1952: {
ds@1952: Arguments[FileLen - 1] = '\0';
ds@1952: }
ds@1952: }
ds@1952:
ds@1952: decl String:target_name[MAX_TARGET_LENGTH];
ds@1952: decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
ds@1952:
ds@1952: if ((target_count = ProcessTargetString(
ds@1952: Arg,
ds@1952: client,
ds@1952: target_list,
ds@1952: MAXPLAYERS,
ds@1952: COMMAND_FILTER_NO_BOTS,
ds@1952: target_name,
ds@1952: sizeof(target_name),
ds@1952: tn_is_ml)) <= 0)
ds@1952: {
ds@1952: ReplyToTargetError(client, target_count);
ds@1952: return Plugin_Handled;
ds@1952: }
ds@1952:
ds@1952: for (new i = 0; i < target_count; i++)
ds@1952: {
ds@1952: ClientCommand(target_list[i], "playgamesound \"%s\"", Arguments[len]);
ds@1952: LogAction(client, target_list[i], "\"%L\" played sound on \"%L\" (file \"%s\")", client, target_list[i], Arguments[len]);
ds@1952: }
ds@1952:
ds@1952: if (tn_is_ml)
ds@1952: {
ds@1952: ShowActivity2(client, "[SM] ", "%t", "Played sound to target", target_name);
ds@1952: }
ds@1952: else
ds@1952: {
ds@1952: ShowActivity2(client, "[SM] ", "%t", "Played sound to target", "_s", target_name);
ds@1952: }
ds@1952:
ds@1952: return Plugin_Handled;
ds@1952: }