Rewrote timer system in funcommands. Cleaned up the code. Moved sounds to a seperate plugin. Misc code optimizations. (bug 3498 r=dvander)

This commit is contained in:
Liam 2009-01-07 19:21:54 -05:00
parent f96ca17f17
commit db760dc29b
10 changed files with 458 additions and 657 deletions

View File

@ -47,23 +47,7 @@ public Plugin:myinfo =
url = "http://www.sourcemod.net/"
};
// -------------------------------------------------------------------------------
// Set any of these to 0 and recompile to completely disable those commands
// -------------------------------------------------------------------------------
#define BEACON 1
#define TIMEBOMB 1
#define FIRE 1
#define ICE 1
#define GRAVITY 1
#define BLIND 1
#define NOCLIP 1
#define DRUG 1
#define TELEPORT 1
#define HEALTH 1
#define COLORS 1
#define CASH 1
// -------------------------------------------------------------------------------
// Admin Menu
new Handle:hTopMenu = INVALID_HANDLE;
// Sounds
@ -81,41 +65,31 @@ new g_GlowSprite;
new g_ExplosionSprite;
// Basic color arrays for temp entities
new redColor[4] = {255, 75, 75, 255};
new orangeColor[4] = {255, 128, 0, 255};
new greenColor[4] = {75, 255, 75, 255};
new blueColor[4] = {75, 75, 255, 255};
new whiteColor[4] = {255, 255, 255, 255};
new greyColor[4] = {128, 128, 128, 255};
new redColor[4] = {255, 75, 75, 255};
new orangeColor[4] = {255, 128, 0, 255};
new greenColor[4] = {75, 255, 75, 255};
new blueColor[4] = {75, 75, 255, 255};
new whiteColor[4] = {255, 255, 255, 255};
new greyColor[4] = {128, 128, 128, 255};
// UserMessageId for Fade.
new UserMsg:g_FadeUserMsgId;
// Serial Generator for Timer Safety
new g_Serial_Gen = 0;
// Flags used in various timers
#define DEFAULT_TIMER_FLAGS TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE
// Include various commands and supporting functions
#if BEACON
#include "funcommands/beacon.sp"
#endif
#if TIMEBOMB
#include "funcommands/timebomb.sp"
#endif
#if FIRE
#include "funcommands/fire.sp"
#endif
#if ICE
#include "funcommands/ice.sp"
#endif
#if GRAVITY
#include "funcommands/gravity.sp"
#endif
#if BLIND
#include "funcommands/blind.sp"
#endif
#if NOCLIP
#include "funcommands/noclip.sp"
#endif
#if DRUG
#include "funcommands/drug.sp"
#endif
public OnPluginStart()
{
@ -126,46 +100,11 @@ public OnPluginStart()
LoadTranslations("common.phrases");
LoadTranslations("funcommands.phrases");
g_FadeUserMsgId = GetUserMessageId("Fade");
RegAdminCmd("sm_play", Command_Play, ADMFLAG_GENERIC, "sm_play <#userid|name> <filename>");
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
#if BEACON
SetupBeacon(); // sm_beacon
#endif
#if TIMEBOMB
SetupTimeBomb(); // sm_timebomb
#endif
#if FIRE
SetupFire(); // sm_burn and sm_firebomb
#endif
#if ICE
SetupIce(); // sm_freeze and sm_freezebomb
#endif
#if GRAVITY
SetupGravity(); // sm_gravity
#endif
#if BLIND
SetupBlind(); // sm_blind
#endif
#if NOCLIP
SetupNoClip(); // sm_noclip
#endif
#if DRUG
SetupDrugs(); // sm_drug
#endif
AutoExecConfig(true, "funcommands");
RegisterCvars( );
RegisterCmds( );
HookEvents( );
/* Account for late loading */
new Handle:topmenu;
@ -175,6 +114,50 @@ public OnPluginStart()
}
}
RegisterCvars( )
{
// beacon
g_Cvar_BeaconRadius = CreateConVar("sm_beacon_radius", "375", "Sets the radius for beacon's light rings.", 0, true, 50.0, true, 1500.0);
// timebomb
g_Cvar_TimeBombTicks = CreateConVar("sm_timebomb_ticks", "10.0", "Sets how long the timebomb fuse is.", 0, true, 5.0, true, 120.0);
g_Cvar_TimeBombRadius = CreateConVar("sm_timebomb_radius", "600", "Sets the bomb blast radius.", 0, true, 50.0, true, 3000.0);
g_Cvar_TimeBombMode = CreateConVar("sm_timebomb_mode", "0", "Who is killed by the timebomb? 0 = Target only, 1 = Target's team, 2 = Everyone", 0, true, 0.0, true, 2.0);
// fire
g_Cvar_BurnDuration = CreateConVar("sm_burn_duration", "20.0", "Sets the default duration of sm_burn and firebomb victims.", 0, true, 0.5, true, 20.0);
g_Cvar_FireBombTicks = CreateConVar("sm_firebomb_ticks", "10.0", "Sets how long the FireBomb fuse is.", 0, true, 5.0, true, 120.0);
g_Cvar_FireBombRadius = CreateConVar("sm_firebomb_radius", "600", "Sets the bomb blast radius.", 0, true, 50.0, true, 3000.0);
g_Cvar_FireBombMode = CreateConVar("sm_firebomb_mode", "0", "Who is targetted by the FireBomb? 0 = Target only, 1 = Target's team, 2 = Everyone", 0, true, 0.0, true, 2.0);
// ice
g_Cvar_FreezeDuration = CreateConVar("sm_freeze_duration", "10.0", "Sets the default duration for sm_freeze and freezebomb victims", 0, true, 1.0, true, 120.0);
g_Cvar_FreezeBombTicks = CreateConVar("sm_freezebomb_ticks", "10.0", "Sets how long the freezebomb fuse is.", 0, true, 5.0, true, 120.0);
g_Cvar_FreezeBombRadius = CreateConVar("sm_freezebomb_radius", "600", "Sets the freezebomb blast radius.", 0, true, 50.0, true, 3000.0);
g_Cvar_FreezeBombMode = CreateConVar("sm_freezebomb_mode", "0", "Who is targetted by the freezebomb? 0 = Target only, 1 = Target's team, 2 = Everyone", 0, true, 0.0, true, 2.0);
AutoExecConfig(true, "funcommands");
}
RegisterCmds( )
{
RegAdminCmd("sm_beacon", Command_Beacon, ADMFLAG_SLAY, "sm_beacon <#userid|name> [0/1]");
RegAdminCmd("sm_timebomb", Command_TimeBomb, ADMFLAG_SLAY, "sm_timebomb <#userid|name> [0/1]");
RegAdminCmd("sm_burn", Command_Burn, ADMFLAG_SLAY, "sm_burn <#userid|name> [time]");
RegAdminCmd("sm_firebomb", Command_FireBomb, ADMFLAG_SLAY, "sm_firebomb <#userid|name> [0/1]");
RegAdminCmd("sm_freeze", Command_Freeze, ADMFLAG_SLAY, "sm_freeze <#userid|name> [time]");
RegAdminCmd("sm_freezebomb", Command_FreezeBomb, ADMFLAG_SLAY, "sm_freezebomb <#userid|name> [0/1]");
RegAdminCmd("sm_gravity", Command_Gravity, ADMFLAG_SLAY, "sm_gravity <#userid|name> [amount] - Leave amount off to reset. Amount is 0.0 through 5.0");
RegAdminCmd("sm_blind", Command_Blind, ADMFLAG_SLAY, "sm_blind <#userid|name> [amount] - Leave amount off to reset.");
RegAdminCmd("sm_noclip", Command_NoClip, ADMFLAG_SLAY|ADMFLAG_CHEATS, "sm_noclip <#userid|name>");
RegAdminCmd("sm_drug", Command_Drug, ADMFLAG_SLAY, "sm_drug <#userid|name> [0/1]");
}
HookEvents( )
{
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
}
public OnMapStart()
{
PrecacheSound(SOUND_BLIP, true);
@ -192,42 +175,20 @@ public OnMapStart()
public OnMapEnd()
{
#if BEACON
KillAllBeacons();
#endif
#if TIMEBOMB
KillAllBeacons( );
KillAllTimeBombs();
#endif
#if FIRE
KillAllFireBombs();
#endif
#if ICE
KillAllFreezes();
#endif
#if DRUG
KillAllDrugs();
#endif
}
public Action:Event_RoundEnd(Handle:event,const String:name[],bool:dontBroadcast)
{
#if BEACON
KillAllBeacons();
#endif
#if TIMEBOMB
KillAllBeacons( );
KillAllTimeBombs();
#endif
#if FIRE
KillAllFireBombs();
#endif
#if ICE
KillAllFreezes();
#endif
#if DRUG
KillAllDrugs();
#endif
return Plugin_Handled;
}
public OnAdminMenuReady(Handle:topmenu)
@ -246,7 +207,6 @@ public OnAdminMenuReady(Handle:topmenu)
if (player_commands != INVALID_TOPMENUOBJECT)
{
#if BEACON
AddToTopMenu(hTopMenu,
"sm_beacon",
TopMenuObject_Item,
@ -254,9 +214,7 @@ public OnAdminMenuReady(Handle:topmenu)
player_commands,
"sm_beacon",
ADMFLAG_SLAY);
#endif
#if TIMEBOMB
AddToTopMenu(hTopMenu,
"sm_timebomb",
TopMenuObject_Item,
@ -264,9 +222,7 @@ public OnAdminMenuReady(Handle:topmenu)
player_commands,
"sm_timebomb",
ADMFLAG_SLAY);
#endif
#if FIRE
AddToTopMenu(hTopMenu,
"sm_burn",
TopMenuObject_Item,
@ -274,7 +230,7 @@ public OnAdminMenuReady(Handle:topmenu)
player_commands,
"sm_burn",
ADMFLAG_SLAY);
AddToTopMenu(hTopMenu,
"sm_firebomb",
TopMenuObject_Item,
@ -282,9 +238,7 @@ public OnAdminMenuReady(Handle:topmenu)
player_commands,
"sm_firebomb",
ADMFLAG_SLAY);
#endif
#if ICE
AddToTopMenu(hTopMenu,
"sm_freeze",
TopMenuObject_Item,
@ -300,9 +254,7 @@ public OnAdminMenuReady(Handle:topmenu)
player_commands,
"sm_freezebomb",
ADMFLAG_SLAY);
#endif
#if GRAVITY
AddToTopMenu(hTopMenu,
"sm_gravity",
TopMenuObject_Item,
@ -310,9 +262,7 @@ public OnAdminMenuReady(Handle:topmenu)
player_commands,
"sm_gravity",
ADMFLAG_SLAY);
#endif
#if BLIND
AddToTopMenu(hTopMenu,
"sm_blind",
TopMenuObject_Item,
@ -320,9 +270,7 @@ public OnAdminMenuReady(Handle:topmenu)
player_commands,
"sm_blind",
ADMFLAG_SLAY);
#endif
#if NOCLIP
AddToTopMenu(hTopMenu,
"sm_noclip",
TopMenuObject_Item,
@ -330,9 +278,7 @@ public OnAdminMenuReady(Handle:topmenu)
player_commands,
"sm_noclip",
ADMFLAG_SLAY);
#endif
#if DRUG
AddToTopMenu(hTopMenu,
"sm_drug",
TopMenuObject_Item,
@ -340,73 +286,6 @@ public OnAdminMenuReady(Handle:topmenu)
player_commands,
"sm_drug",
ADMFLAG_SLAY);
#endif
}
}
public Action:Command_Play(client, args)
{
if (args < 2)
{
ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
}
new String:Arguments[PLATFORM_MAX_PATH + 65];
GetCmdArgString(Arguments, sizeof(Arguments));
decl String:Arg[65];
new len = BreakString(Arguments, Arg, sizeof(Arg));
/* Make sure it does not go out of bound by doing "sm_play user "*/
if (len == -1)
{
ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
return Plugin_Handled;
}
/* Incase they put quotes and white spaces after the quotes */
if (Arguments[len] == '"')
{
len++;
new FileLen = TrimString(Arguments[len]) + len;
if (Arguments[FileLen - 1] == '"')
{
Arguments[FileLen - 1] = '\0';
}
}
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
if ((target_count = ProcessTargetString(
Arg,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_NO_BOTS,
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
for (new i = 0; i < target_count; i++)
{
ClientCommand(target_list[i], "playgamesound \"%s\"", Arguments[len]);
LogAction(client, target_list[i], "\"%L\" played sound on \"%L\" (file \"%s\")", client, target_list[i], Arguments[len]);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Played sound to target", target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Played sound to target", "_s", target_name);
}
return Plugin_Handled;
}

View File

@ -31,85 +31,61 @@
* Version: $Id$
*/
new Handle:g_BeaconTimers[MAXPLAYERS+1];
new g_BeaconSerial[MAXPLAYERS+1] = { 0, ... };
new Handle:g_BeaconRadius = INVALID_HANDLE;
SetupBeacon()
{
RegAdminCmd("sm_beacon", Command_Beacon, ADMFLAG_SLAY, "sm_beacon <#userid|name> [0/1]");
g_BeaconRadius = CreateConVar("sm_beacon_radius", "375", "Sets the radius for beacon's light rings.", 0, true, 50.0, true, 1500.0);
}
new Handle:g_Cvar_BeaconRadius = INVALID_HANDLE;
CreateBeacon(client)
{
g_BeaconTimers[client] = CreateTimer(2.0, Timer_Beacon, client, TIMER_REPEAT);
g_BeaconSerial[client] = ++g_Serial_Gen;
CreateTimer(1.0, Timer_Beacon, client | (g_Serial_Gen << 7), DEFAULT_TIMER_FLAGS);
}
KillBeacon(client)
{
KillTimer(g_BeaconTimers[client]);
g_BeaconTimers[client] = INVALID_HANDLE;
g_BeaconSerial[client] = 0;
if (IsClientInGame(client))
{
SetEntityRenderColor(client, 255, 255, 255, 255);
}
}
KillAllBeacons()
{
new maxclients = GetMaxClients();
for (new i = 1; i <= maxclients; i++)
{
if (g_BeaconTimers[i] != INVALID_HANDLE)
{
KillBeacon(i);
}
KillBeacon(i);
}
}
PerformBeacon(client, target, toggle)
PerformBeacon(client, target)
{
switch (toggle)
if (g_BeaconSerial[target] == 0)
{
case (2):
{
if (g_BeaconTimers[target] == INVALID_HANDLE)
{
CreateBeacon(target);
LogAction(client, target, "\"%L\" set a beacon on \"%L\"", client, target);
}
else
{
KillBeacon(target);
LogAction(client, target, "\"%L\" removed a beacon on \"%L\"", client, target);
}
}
case (1):
{
if (g_BeaconTimers[target] == INVALID_HANDLE)
{
CreateBeacon(target);
LogAction(client, target, "\"%L\" set a beacon on \"%L\"", client, target);
}
}
case (0):
{
if (g_BeaconTimers[target] != INVALID_HANDLE)
{
KillBeacon(target);
LogAction(client, target, "\"%L\" removed a beacon on \"%L\"", client, target);
}
}
CreateBeacon(target);
LogAction(client, target, "\"%L\" set a beacon on \"%L\"", client, target);
}
else
{
KillBeacon(target);
LogAction(client, target, "\"%L\" removed a beacon on \"%L\"", client, target);
}
}
public Action:Timer_Beacon(Handle:timer, any:client)
public Action:Timer_Beacon(Handle:timer, any:value)
{
if (!IsClientInGame(client) || !IsPlayerAlive(client))
{
KillBeacon(client);
new client = value & 0x7f;
new serial = value >> 7;
return Plugin_Handled;
if (!IsClientInGame(client)
|| !IsPlayerAlive(client)
|| g_BeaconSerial[client] != serial)
{
KillBeacon(client);
return Plugin_Stop;
}
new team = GetClientTeam(client);
@ -118,20 +94,20 @@ public Action:Timer_Beacon(Handle:timer, any:client)
GetClientAbsOrigin(client, vec);
vec[2] += 10;
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SendToAll();
if (team == 2)
{
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, redColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, redColor, 10, 0);
}
else if (team == 3)
{
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, blueColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, blueColor, 10, 0);
}
else
{
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, greenColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, greenColor, 10, 0);
}
TE_SendToAll();
@ -139,7 +115,7 @@ public Action:Timer_Beacon(Handle:timer, any:client)
GetClientEyePosition(client, vec);
EmitAmbientSound(SOUND_BLIP, vec, client, SNDLEVEL_RAIDSIREN);
return Plugin_Handled;
return Plugin_Continue;
}
public AdminMenu_Beacon(Handle:topmenu,
@ -207,7 +183,7 @@ public MenuHandler_Beacon(Handle:menu, MenuAction:action, param1, param2)
new String:name[32];
GetClientName(target, name, sizeof(name));
PerformBeacon(param1, target, 2);
PerformBeacon(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Toggled beacon on target", "_s", name);
}
@ -223,27 +199,12 @@ public Action:Command_Beacon(client, args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_beacon <#userid|name> [0/1]");
ReplyToCommand(client, "[SM] Usage: sm_beacon <#userid|name>");
return Plugin_Handled;
}
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
new toggle = 2;
if (args > 1)
{
decl String:arg2[2];
GetCmdArg(2, arg2, sizeof(arg2));
if (arg2[0])
{
toggle = 1;
}
else
{
toggle = 0;
}
}
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
@ -264,7 +225,7 @@ public Action:Command_Beacon(client, args)
for (new i = 0; i < target_count; i++)
{
PerformBeacon(client, target_list[i], toggle);
PerformBeacon(client, target_list[i]);
}
if (tn_is_ml)

View File

@ -33,11 +33,6 @@
new g_BlindTarget[MAXPLAYERS+1];
SetupBlind()
{
RegAdminCmd("sm_blind", Command_Blind, ADMFLAG_SLAY, "sm_blind <#userid|name> [amount] - Leave amount off to reset.");
}
PerformBlind(client, target, amount)
{
new targets[2];

View File

@ -34,11 +34,6 @@
new Handle:g_DrugTimers[MAXPLAYERS+1];
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};
SetupDrugs()
{
RegAdminCmd("sm_drug", Command_Drug, ADMFLAG_SLAY, "sm_drug <#userid|name> [0/1]");
}
CreateDrug(client)
{
g_DrugTimers[client] = CreateTimer(1.0, Timer_Drug, client, TIMER_REPEAT);

View File

@ -31,116 +31,86 @@
* Version: $Id$
*/
new Handle:g_FireBombTimers[MAXPLAYERS+1];
new g_FireBombTracker[MAXPLAYERS+1];
new g_FireBombSerial[MAXPLAYERS+1] = { 0, ... };
new g_FireBombTime[MAXPLAYERS+1] = { 0, ... };
new Handle:g_BurnDuration = INVALID_HANDLE;
new Handle:g_FireBombTicks = INVALID_HANDLE;
new Handle:g_FireBombRadius = INVALID_HANDLE;
new Handle:g_FireBombMode = INVALID_HANDLE;
SetupFire()
{
RegAdminCmd("sm_burn", Command_Burn, ADMFLAG_SLAY, "sm_burn <#userid|name> [time]");
RegAdminCmd("sm_firebomb", Command_FireBomb, ADMFLAG_SLAY, "sm_firebomb <#userid|name> [0/1]");
g_BurnDuration = CreateConVar("sm_burn_duration", "20", "Sets the default duration of sm_burn and firebomb victims.", 0, true, 0.5, true, 20.0);
g_FireBombTicks = CreateConVar("sm_firebomb_ticks", "10", "Sets how long the FireBomb fuse is.", 0, true, 5.0, true, 120.0);
g_FireBombRadius = CreateConVar("sm_firebomb_radius", "600", "Sets the bomb blast radius.", 0, true, 50.0, true, 3000.0);
g_FireBombMode = CreateConVar("sm_firebomb_mode", "0", "Who is targetted by the FireBomb? 0 = Target only, 1 = Target's team, 2 = Everyone", 0, true, 0.0, true, 2.0);
}
new Handle:g_Cvar_BurnDuration = INVALID_HANDLE;
new Handle:g_Cvar_FireBombTicks = INVALID_HANDLE;
new Handle:g_Cvar_FireBombRadius = INVALID_HANDLE;
new Handle:g_Cvar_FireBombMode = INVALID_HANDLE;
CreateFireBomb(client)
{
g_FireBombTimers[client] = CreateTimer(1.0, Timer_FireBomb, client, TIMER_REPEAT);
g_FireBombTracker[client] = GetConVarInt(g_FireBombTicks);
g_FireBombSerial[client] = ++g_Serial_Gen;
CreateTimer(1.0, Timer_FireBomb, client | (g_Serial_Gen << 7), DEFAULT_TIMER_FLAGS);
g_FireBombTime[client] = GetConVarInt(g_Cvar_FireBombTicks);
}
KillFireBomb(client)
{
KillTimer(g_FireBombTimers[client]);
g_FireBombTimers[client] = INVALID_HANDLE;
g_FireBombSerial[client] = 0;
if (IsClientInGame(client))
{
SetEntityRenderColor(client, 255, 255, 255, 255);
}
}
KillAllFireBombs()
{
new maxclients = GetMaxClients();
for (new i = 1; i <= maxclients; i++)
{
if (g_FireBombTimers[i] != INVALID_HANDLE)
{
KillFireBomb(i);
}
KillFireBomb(i);
}
}
PerformBurn(client, target, Float:seconds)
{
LogAction(client, target, "\"%L\" ignited \"%L\" (seconds \"%f\")", client, target, seconds);
IgniteEntity(target, seconds);
LogAction(client, target, "\"%L\" ignited \"%L\" (seconds \"%f\")", client, target, seconds);
}
PerformFireBomb(client, target, toggle)
PerformFireBomb(client, target)
{
switch (toggle)
if (g_FireBombSerial[client] == 0)
{
case (2):
{
if (g_FireBombTimers[target] == INVALID_HANDLE)
{
CreateFireBomb(target);
LogAction(client, target, "\"%L\" set a FireBomb on \"%L\"", client, target);
}
else
{
KillFireBomb(target);
SetEntityRenderColor(client, 255, 255, 255, 255);
LogAction(client, target, "\"%L\" removed a FireBomb on \"%L\"", client, target);
}
}
case (1):
{
if (g_FireBombTimers[target] == INVALID_HANDLE)
{
CreateFireBomb(target);
LogAction(client, target, "\"%L\" set a FireBomb on \"%L\"", client, target);
}
}
case (0):
{
if (g_FireBombTimers[target] != INVALID_HANDLE)
{
KillFireBomb(target);
SetEntityRenderColor(client, 255, 255, 255, 255);
LogAction(client, target, "\"%L\" removed a FireBomb on \"%L\"", client, target);
}
}
CreateFireBomb(target);
LogAction(client, target, "\"%L\" set a FireBomb on \"%L\"", client, target);
}
else
{
KillFireBomb(target);
SetEntityRenderColor(client, 255, 255, 255, 255);
LogAction(client, target, "\"%L\" removed a FireBomb on \"%L\"", client, target);
}
}
public Action:Timer_FireBomb(Handle:timer, any:client)
public Action:Timer_FireBomb(Handle:timer, any:value)
{
if (!IsClientInGame(client) || !IsPlayerAlive(client))
{
KillFireBomb(client);
new client = value & 0x7f;
new serial = value >> 7;
return Plugin_Handled;
}
g_FireBombTracker[client]--;
if (!IsClientInGame(client)
|| !IsPlayerAlive(client)
|| g_FireBombSerial[client] != serial)
{
KillFireBomb(client);
return Plugin_Stop;
}
g_FireBombTime[client]--;
new Float:vec[3];
GetClientEyePosition(client, vec);
if (g_FireBombTracker[client] > 0)
if (g_FireBombTime[client] > 0)
{
new color;
if (g_FireBombTracker[client] > 1)
if (g_FireBombTime[client] > 1)
{
color = RoundToFloor(g_FireBombTracker[client] * (255.0 / GetConVarFloat(g_FireBombTicks)));
color = RoundToFloor(g_FireBombTime[client] * (255.0 / GetConVarFloat(g_Cvar_FireBombTicks)));
EmitAmbientSound(SOUND_BEEP, vec, client, SNDLEVEL_RAIDSIREN);
}
else
@ -153,44 +123,45 @@ public Action:Timer_FireBomb(Handle:timer, any:client)
decl String:name[64];
GetClientName(client, name, sizeof(name));
PrintCenterTextAll("%t", "Till Explodes", name, g_FireBombTracker[client]);
PrintCenterTextAll("%t", "Till Explodes", name, g_FireBombTime[client]);
GetClientAbsOrigin(client, vec);
vec[2] += 10;
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_FireBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_FireBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SendToAll();
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_FireBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_FireBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
TE_SendToAll();
return Plugin_Continue;
}
else
{
TE_SetupExplosion(vec, g_ExplosionSprite, 0.1, 1, 0, GetConVarInt(g_FireBombRadius), 5000);
TE_SetupExplosion(vec, g_ExplosionSprite, 0.1, 1, 0, GetConVarInt(g_Cvar_FireBombRadius), 5000);
TE_SendToAll();
GetClientAbsOrigin(client, vec);
vec[2] += 10;
TE_SetupBeamRingPoint(vec, 50.0, GetConVarFloat(g_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.5, 30.0, 1.5, orangeColor, 5, 0);
TE_SetupBeamRingPoint(vec, 50.0, GetConVarFloat(g_Cvar_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.5, 30.0, 1.5, orangeColor, 5, 0);
TE_SendToAll();
vec[2] += 15;
TE_SetupBeamRingPoint(vec, 40.0, GetConVarFloat(g_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 30.0, 1.5, orangeColor, 5, 0);
TE_SetupBeamRingPoint(vec, 40.0, GetConVarFloat(g_Cvar_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 30.0, 1.5, orangeColor, 5, 0);
TE_SendToAll();
vec[2] += 15;
TE_SetupBeamRingPoint(vec, 30.0, GetConVarFloat(g_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.7, 30.0, 1.5, orangeColor, 5, 0);
TE_SetupBeamRingPoint(vec, 30.0, GetConVarFloat(g_Cvar_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.7, 30.0, 1.5, orangeColor, 5, 0);
TE_SendToAll();
vec[2] += 15;
TE_SetupBeamRingPoint(vec, 20.0, GetConVarFloat(g_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.8, 30.0, 1.5, orangeColor, 5, 0);
TE_SetupBeamRingPoint(vec, 20.0, GetConVarFloat(g_Cvar_FireBombRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.8, 30.0, 1.5, orangeColor, 5, 0);
TE_SendToAll();
EmitAmbientSound(SOUND_BOOM, vec, client, SNDLEVEL_RAIDSIREN);
IgniteEntity(client, GetConVarFloat(g_BurnDuration));
IgniteEntity(client, GetConVarFloat(g_Cvar_BurnDuration));
KillFireBomb(client);
SetEntityRenderColor(client, 255, 255, 255, 255);
if (GetConVarInt(g_FireBombMode) > 0)
if (GetConVarInt(g_Cvar_FireBombMode) > 0)
{
new teamOnly = ((GetConVarInt(g_FireBombMode) == 1) ? true : false);
new teamOnly = ((GetConVarInt(g_Cvar_FireBombMode) == 1) ? true : false);
new maxClients = GetMaxClients();
for (new i = 1; i < maxClients; i++)
@ -210,20 +181,19 @@ public Action:Timer_FireBomb(Handle:timer, any:client)
new Float:distance = GetVectorDistance(vec, pos);
if (distance > GetConVarFloat(g_FireBombRadius))
if (distance > GetConVarFloat(g_Cvar_FireBombRadius))
{
continue;
}
new Float:duration = GetConVarFloat(g_BurnDuration);
duration *= (GetConVarFloat(g_FireBombRadius) - distance) / GetConVarFloat(g_FireBombRadius);
new Float:duration = GetConVarFloat(g_Cvar_BurnDuration);
duration *= (GetConVarFloat(g_Cvar_FireBombRadius) - distance) / GetConVarFloat(g_Cvar_FireBombRadius);
IgniteEntity(i, duration);
}
}
return Plugin_Stop;
}
return Plugin_Handled;
}
public AdminMenu_Burn(Handle:topmenu,
@ -367,7 +337,7 @@ public MenuHandler_FireBomb(Handle:menu, MenuAction:action, param1, param2)
new String:name[32];
GetClientName(target, name, sizeof(name));
PerformFireBomb(param1, target, 2);
PerformFireBomb(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Toggled FireBomb on target", "_s", name);
}
@ -390,7 +360,7 @@ public Action:Command_Burn(client, args)
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
new Float:seconds = GetConVarFloat(g_BurnDuration);
new Float:seconds = GetConVarFloat(g_Cvar_BurnDuration);
if (args > 1)
{
@ -441,27 +411,12 @@ public Action:Command_FireBomb(client, args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_firebomb <#userid|name> [0/1]");
ReplyToCommand(client, "[SM] Usage: sm_firebomb <#userid|name>");
return Plugin_Handled;
}
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
new toggle = 2;
if (args > 1)
{
decl String:arg2[2];
GetCmdArg(2, arg2, sizeof(arg2));
if (arg2[0])
{
toggle = 1;
}
else
{
toggle = 0;
}
}
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
@ -482,7 +437,7 @@ public Action:Command_FireBomb(client, args)
for (new i = 0; i < target_count; i++)
{
PerformFireBomb(client, target_list[i], toggle);
PerformFireBomb(client, target_list[i]);
}
if (tn_is_ml)
@ -492,8 +447,7 @@ public Action:Command_FireBomb(client, args)
else
{
ShowActivity2(client, "[SM] ", "%t", "Toggled FireBomb on target", "_s", target_name);
}
}
return Plugin_Handled;
}

View File

@ -33,11 +33,6 @@
new g_GravityTarget[MAXPLAYERS+1];
SetupGravity()
{
RegAdminCmd("sm_gravity", Command_Gravity, ADMFLAG_SLAY, "sm_gravity <#userid|name> [amount] - Leave amount off to reset. Amount is 0.0 through 5.0");
}
PerformGravity(client, target, Float:amount)
{
new offset = FindDataMapOffs(client, "m_flGravity");

View File

@ -31,98 +31,90 @@
* Version: $Id$
*/
new Handle:g_FreezeTimers[MAXPLAYERS+1];
new Handle:g_FreezeBombTimers[MAXPLAYERS+1];
new g_FreezeTracker[MAXPLAYERS+1];
new g_FreezeBombTracker[MAXPLAYERS+1];
new g_FreezeSerial[MAXPLAYERS+1] = { 0, ... };
new g_FreezeBombSerial[MAXPLAYERS+1] = { 0, ... };
new g_FreezeTime[MAXPLAYERS+1] = { 0, ... };
new g_FreezeBombTime[MAXPLAYERS+1] = { 0, ... };
new Handle:g_FreezeDuration = INVALID_HANDLE;
new Handle:g_FreezeBombTicks = INVALID_HANDLE;
new Handle:g_FreezeBombRadius = INVALID_HANDLE;
new Handle:g_FreezeBombMode = INVALID_HANDLE;
SetupIce()
{
RegAdminCmd("sm_freeze", Command_Freeze, ADMFLAG_SLAY, "sm_freeze <#userid|name> [time]");
RegAdminCmd("sm_freezebomb", Command_FreezeBomb, ADMFLAG_SLAY, "sm_freezebomb <#userid|name> [0/1]");
g_FreezeDuration = CreateConVar("sm_freeze_duration", "10.0", "Sets the default duration for sm_freeze and freezebomb victims", 0, true, 1.0, true, 120.0);
g_FreezeBombTicks = CreateConVar("sm_freezebomb_ticks", "10", "Sets how long the freezebomb fuse is.", 0, true, 5.0, true, 120.0);
g_FreezeBombRadius = CreateConVar("sm_freezebomb_radius", "600", "Sets the freezebomb blast radius.", 0, true, 50.0, true, 3000.0);
g_FreezeBombMode = CreateConVar("sm_freezebomb_mode", "0", "Who is targetted by the freezebomb? 0 = Target only, 1 = Target's team, 2 = Everyone", 0, true, 0.0, true, 2.0);
}
new Handle:g_Cvar_FreezeDuration = INVALID_HANDLE;
new Handle:g_Cvar_FreezeBombTicks = INVALID_HANDLE;
new Handle:g_Cvar_FreezeBombRadius = INVALID_HANDLE;
new Handle:g_Cvar_FreezeBombMode = INVALID_HANDLE;
FreezeClient(client, time)
{
if (g_FreezeTimers[client] != INVALID_HANDLE)
if (g_FreezeSerial[client] != 0)
{
UnfreezeClient(client);
return;
}
SetEntityMoveType(client, MOVETYPE_NONE);
SetEntityRenderColor(client, 0, 128, 255, 192);
new Float:vec[3];
GetClientEyePosition(client, vec);
EmitAmbientSound(SOUND_FREEZE, vec, client, SNDLEVEL_RAIDSIREN);
g_FreezeTimers[client] = CreateTimer(1.0, Timer_Freeze, client, TIMER_REPEAT);
g_FreezeTracker[client] = time;
g_FreezeTime[client] = time;
g_FreezeSerial[client] = ++ g_Serial_Gen;
CreateTimer(1.0, Timer_Freeze, client | (g_Serial_Gen << 7), DEFAULT_TIMER_FLAGS);
}
UnfreezeClient(client)
{
KillFreezeTimer(client);
g_FreezeSerial[client] = 0;
g_FreezeTime[client] = 0;
new Float:vec[3];
GetClientAbsOrigin(client, vec);
vec[2] += 10;
GetClientEyePosition(client, vec);
EmitAmbientSound(SOUND_FREEZE, vec, client, SNDLEVEL_RAIDSIREN);
if (IsClientInGame(client))
{
new Float:vec[3];
GetClientAbsOrigin(client, vec);
vec[2] += 10;
GetClientEyePosition(client, vec);
EmitAmbientSound(SOUND_FREEZE, vec, client, SNDLEVEL_RAIDSIREN);
SetEntityMoveType(client, MOVETYPE_WALK);
SetEntityRenderColor(client, 255, 255, 255, 255);
}
KillFreezeTimer(client)
{
KillTimer(g_FreezeTimers[client]);
g_FreezeTimers[client] = INVALID_HANDLE;
SetEntityMoveType(client, MOVETYPE_WALK);
SetEntityRenderColor(client, 255, 255, 255, 255);
}
}
CreateFreezeBomb(client)
{
g_FreezeBombTimers[client] = CreateTimer(1.0, Timer_FreezeBomb, client, TIMER_REPEAT);
g_FreezeBombTracker[client] = GetConVarInt(g_FreezeBombTicks);
if (g_FreezeBombSerial[client] != 0)
{
KillFreezeBomb(client);
return;
}
g_FreezeBombTime[client] = GetConVarInt(g_Cvar_FreezeBombTicks);
g_FreezeBombSerial[client] = ++g_Serial_Gen;
CreateTimer(1.0, Timer_FreezeBomb, client | (g_Serial_Gen << 7), DEFAULT_TIMER_FLAGS);
}
KillFreezeBomb(client)
{
KillTimer(g_FreezeBombTimers[client]);
g_FreezeBombTimers[client] = INVALID_HANDLE;
SetEntityRenderColor(client, 255, 255, 255, 255);
g_FreezeBombSerial[client] = 0;
g_FreezeBombTime[client] = 0;
if (IsClientInGame(client))
{
SetEntityRenderColor(client, 255, 255, 255, 255);
}
}
KillAllFreezes()
KillAllFreezes( )
{
new maxclients = GetMaxClients();
for (new i = 1; i <= maxclients; i++)
new maxclients = GetMaxClients( );
for(new i = 1; i < maxclients; i++)
{
if (g_FreezeTimers[i] != INVALID_HANDLE)
if (g_FreezeSerial[i] != 0)
{
if(IsClientInGame(i))
{
UnfreezeClient(i);
}
else
{
KillFreezeTimer(i);
}
}
if (g_FreezeBombTimers[i] != INVALID_HANDLE)
UnfreezeClient(i);
}
if (g_FreezeBombSerial[i] != 0)
{
KillFreezeBomb(i);
}
@ -135,101 +127,79 @@ PerformFreeze(client, target, time)
LogAction(client, target, "\"%L\" froze \"%L\"", client, target);
}
PerformFreezeBomb(client, target, toggle)
PerformFreezeBomb(client, target)
{
switch (toggle)
if (g_FreezeBombSerial[target] != 0)
{
case (2):
{
if (g_FreezeBombTimers[target] == INVALID_HANDLE)
{
CreateFreezeBomb(target);
LogAction(client, target, "\"%L\" set a FreezeBomb on \"%L\"", client, target);
}
else
{
KillFreezeBomb(target);
LogAction(client, target, "\"%L\" removed a FreezeBomb on \"%L\"", client, target);
}
}
case (1):
{
if (g_FreezeBombTimers[target] == INVALID_HANDLE)
{
CreateFreezeBomb(target);
LogAction(client, target, "\"%L\" set a FreezeBomb on \"%L\"", client, target);
}
}
case (0):
{
if (g_FreezeBombTimers[target] != INVALID_HANDLE)
{
KillFreezeBomb(target);
LogAction(client, target, "\"%L\" removed a FreezeBomb on \"%L\"", client, target);
}
}
KillFreezeBomb(target);
LogAction(client, target, "\"%L\" removed a FreezeBomb on \"%L\"", client, target);
}
else
{
CreateFreezeBomb(target);
LogAction(client, target, "\"%L\" set a FreezeBomb on \"%L\"", client, target);
}
}
public Action:Timer_Freeze(Handle:timer, any:client)
public Action:Timer_Freeze(Handle:timer, any:value)
{
if (!IsClientInGame(client))
{
KillFreezeTimer(client);
new client = value & 0x7f;
new serial = value >> 7;
return Plugin_Handled;
}
if (!IsPlayerAlive(client))
if (!IsClientInGame(client)
|| !IsPlayerAlive(client)
|| g_FreezeSerial[client] != serial)
{
UnfreezeClient(client);
return Plugin_Handled;
}
g_FreezeTracker[client]--;
return Plugin_Stop;
}
if (g_FreezeTime[client] == 0)
{
UnfreezeClient(client);
PrintHintText(client, "You are now unfrozen.");
return Plugin_Stop;
}
PrintHintText(client, "You will be unfrozen in %d seconds.", g_FreezeTime[client]);
g_FreezeTime[client]--;
SetEntityMoveType(client, MOVETYPE_NONE);
SetEntityRenderColor(client, 0, 128, 255, 135);
new Float:vec[3];
GetClientAbsOrigin(client, vec);
vec[2] += 10;
TE_SetupGlowSprite(vec, g_GlowSprite, 0.95, 1.5, 50);
TE_SendToAll();
TE_SendToAll();
if (g_FreezeTracker[client] == 0)
{
UnfreezeClient(client);
}
return Plugin_Handled;
return Plugin_Continue;
}
public Action:Timer_FreezeBomb(Handle:timer, any:client)
public Action:Timer_FreezeBomb(Handle:timer, any:value)
{
if (!IsClientInGame(client) || !IsPlayerAlive(client))
new client = value & 0x7f;
new serial = value >> 7;
if (!IsClientInGame(client)
|| !IsPlayerAlive(client)
|| g_FreezeBombSerial[client] != serial)
{
KillFreezeBomb(client);
return Plugin_Handled;
return Plugin_Stop;
}
g_FreezeBombTracker[client]--;
new Float:vec[3];
GetClientEyePosition(client, vec);
if (g_FreezeBombTracker[client] > 0)
g_FreezeBombTime[client]--;
if (g_FreezeBombTime[client] > 0)
{
new color;
if (g_FreezeBombTracker[client] > 1)
if (g_FreezeBombTime[client] > 1)
{
color = RoundToFloor(g_FreezeBombTracker[client] * (255.0 / GetConVarFloat(g_FreezeBombTicks)));
color = RoundToFloor(g_FreezeBombTime[client] * (255.0 / GetConVarFloat(g_Cvar_FreezeBombTicks)));
EmitAmbientSound(SOUND_BEEP, vec, client, SNDLEVEL_RAIDSIREN);
}
else
@ -242,30 +212,31 @@ public Action:Timer_FreezeBomb(Handle:timer, any:client)
decl String:name[64];
GetClientName(client, name, sizeof(name));
PrintCenterTextAll("%t", "Till Explodes", name, g_FreezeBombTracker[client]);
PrintCenterTextAll("%t", "Till Explodes", name, g_FreezeBombTime[client]);
GetClientAbsOrigin(client, vec);
vec[2] += 10;
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_FreezeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_FreezeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SendToAll();
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_FreezeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_FreezeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
TE_SendToAll();
return Plugin_Continue;
}
else
{
TE_SetupExplosion(vec, g_ExplosionSprite, 5.0, 1, 0, GetConVarInt(g_FreezeBombRadius), 5000);
TE_SetupExplosion(vec, g_ExplosionSprite, 5.0, 1, 0, GetConVarInt(g_Cvar_FreezeBombRadius), 5000);
TE_SendToAll();
EmitAmbientSound(SOUND_BOOM, vec, client, SNDLEVEL_RAIDSIREN);
KillFreezeBomb(client);
FreezeClient(client, GetConVarInt(g_FreezeDuration));
FreezeClient(client, GetConVarInt(g_Cvar_FreezeDuration));
if (GetConVarInt(g_FreezeBombMode) > 0)
if (GetConVarInt(g_Cvar_FreezeBombMode) > 0)
{
new teamOnly = ((GetConVarInt(g_FreezeBombMode) == 1) ? true : false);
new maxClients = GetMaxClients();
new bool:teamOnly = ((GetConVarInt(g_Cvar_FreezeBombMode) == 1) ? true : false);
new maxClients = GetMaxClients( );
for (new i = 1; i < maxClients; i++)
{
@ -284,7 +255,7 @@ public Action:Timer_FreezeBomb(Handle:timer, any:client)
new Float:distance = GetVectorDistance(vec, pos);
if (distance > GetConVarFloat(g_FreezeBombRadius))
if (distance > GetConVarFloat(g_Cvar_FreezeBombRadius))
{
continue;
}
@ -292,12 +263,11 @@ public Action:Timer_FreezeBomb(Handle:timer, any:client)
TE_SetupBeamPoints(vec, pos, g_BeamSprite2, g_HaloSprite, 0, 1, 0.7, 20.0, 50.0, 1, 1.5, blueColor, 10);
TE_SendToAll();
FreezeClient(i, GetConVarInt(g_FreezeDuration));
FreezeClient(i, GetConVarInt(g_Cvar_FreezeDuration));
}
}
return Plugin_Stop;
}
return Plugin_Handled;
}
public AdminMenu_Freeze(Handle:topmenu,
@ -396,7 +366,7 @@ public MenuHandler_Freeze(Handle:menu, MenuAction:action, param1, param2)
new String:name[32];
GetClientName(target, name, sizeof(name));
PerformFreeze(param1, target, GetConVarInt(g_FreezeDuration));
PerformFreeze(param1, target, GetConVarInt(g_Cvar_FreezeDuration));
ShowActivity2(param1, "[SM] ", "%t", "Froze target", "_s", name);
}
@ -442,7 +412,7 @@ public MenuHandler_FreezeBomb(Handle:menu, MenuAction:action, param1, param2)
new String:name[32];
GetClientName(target, name, sizeof(name));
PerformFreezeBomb(param1, target, 2);
PerformFreezeBomb(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Toggled FreezeBomb on target", "_s", name);
}
@ -465,7 +435,7 @@ public Action:Command_Freeze(client, args)
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
new seconds = GetConVarInt(g_FreezeDuration);
new seconds = GetConVarInt(g_Cvar_FreezeDuration);
if (args > 1)
{
@ -516,27 +486,12 @@ public Action:Command_FreezeBomb(client, args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_freezebomb <#userid|name> [0/1]");
ReplyToCommand(client, "[SM] Usage: sm_freezebomb <#userid|name>");
return Plugin_Handled;
}
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
new toggle = 2;
if (args > 1)
{
decl String:arg2[2];
GetCmdArg(2, arg2, sizeof(arg2));
if (arg2[0])
{
toggle = 1;
}
else
{
toggle = 0;
}
}
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
@ -557,7 +512,7 @@ public Action:Command_FreezeBomb(client, args)
for (new i = 0; i < target_count; i++)
{
PerformFreezeBomb(client, target_list[i], toggle);
PerformFreezeBomb(client, target_list[i]);
}
if (tn_is_ml)

View File

@ -30,11 +30,6 @@
*
* Version: $Id$
*/
SetupNoClip()
{
RegAdminCmd("sm_noclip", Command_NoClip, ADMFLAG_SLAY|ADMFLAG_CHEATS, "sm_noclip <#userid|name>");
}
PerformNoClip(client, target)
{

View File

@ -31,107 +31,79 @@
* Version: $Id$
*/
new Handle:g_TimeBombTimers[MAXPLAYERS+1];
new g_TimeBombTracker[MAXPLAYERS+1];
new g_TimeBombSerial[MAXPLAYERS+1] = { 0, ... };
new g_TimeBombTime[MAXPLAYERS+1] = { 0, ... };
new Handle:g_TimeBombTicks = INVALID_HANDLE;
new Handle:g_TimeBombRadius = INVALID_HANDLE;
new Handle:g_TimeBombMode = INVALID_HANDLE;
SetupTimeBomb()
{
RegAdminCmd("sm_timebomb", Command_TimeBomb, ADMFLAG_SLAY, "sm_timebomb <#userid|name> [0/1]");
g_TimeBombTicks = CreateConVar("sm_timebomb_ticks", "10", "Sets how long the timebomb fuse is.", 0, true, 5.0, true, 120.0);
g_TimeBombRadius = CreateConVar("sm_timebomb_radius", "600", "Sets the bomb blast radius.", 0, true, 50.0, true, 3000.0);
g_TimeBombMode = CreateConVar("sm_timebomb_mode", "0", "Who is killed by the timebomb? 0 = Target only, 1 = Target's team, 2 = Everyone", 0, true, 0.0, true, 2.0);
}
new Handle:g_Cvar_TimeBombTicks = INVALID_HANDLE;
new Handle:g_Cvar_TimeBombRadius = INVALID_HANDLE;
new Handle:g_Cvar_TimeBombMode = INVALID_HANDLE;
CreateTimeBomb(client)
{
g_TimeBombTimers[client] = CreateTimer(1.0, Timer_TimeBomb, client, TIMER_REPEAT);
g_TimeBombTracker[client] = GetConVarInt(g_TimeBombTicks);
g_TimeBombSerial[client] = ++g_Serial_Gen;
CreateTimer(1.0, Timer_TimeBomb, client | (g_Serial_Gen << 7), DEFAULT_TIMER_FLAGS);
g_TimeBombTime[client] = GetConVarInt(g_Cvar_TimeBombTicks);
}
KillTimeBomb(client)
{
KillTimer(g_TimeBombTimers[client]);
g_TimeBombTimers[client] = INVALID_HANDLE;
g_TimeBombSerial[client] = 0;
if (IsClientInGame(client))
{
SetEntityRenderColor(client, 255, 255, 255, 255);
}
}
KillAllTimeBombs()
{
new maxclients = GetMaxClients();
for (new i = 1; i <= maxclients; i++)
{
if (g_TimeBombTimers[i] != INVALID_HANDLE)
{
KillTimeBomb(i);
}
KillTimeBomb(i);
}
}
PerformTimeBomb(client, target, toggle)
PerformTimeBomb(client, target)
{
switch (toggle)
if (g_TimeBombSerial[target] == 0)
{
case (2):
{
if (g_TimeBombTimers[target] == INVALID_HANDLE)
{
CreateTimeBomb(target);
LogAction(client, target, "\"%L\" set a TimeBomb on \"%L\"", client, target);
}
else
{
KillTimeBomb(target);
SetEntityRenderColor(client, 255, 255, 255, 255);
LogAction(client, target, "\"%L\" removed a TimeBomb on \"%L\"", client, target);
}
}
case (1):
{
if (g_TimeBombTimers[target] == INVALID_HANDLE)
{
CreateTimeBomb(target);
LogAction(client, target, "\"%L\" set a TimeBomb on \"%L\"", client, target);
}
}
case (0):
{
if (g_TimeBombTimers[target] != INVALID_HANDLE)
{
KillTimeBomb(target);
SetEntityRenderColor(client, 255, 255, 255, 255);
LogAction(client, target, "\"%L\" removed a TimeBomb on \"%L\"", client, target);
}
}
CreateTimeBomb(target);
LogAction(client, target, "\"%L\" set a TimeBomb on \"%L\"", client, target);
}
else
{
KillTimeBomb(target);
SetEntityRenderColor(client, 255, 255, 255, 255);
LogAction(client, target, "\"%L\" removed a TimeBomb on \"%L\"", client, target);
}
}
public Action:Timer_TimeBomb(Handle:timer, any:client)
public Action:Timer_TimeBomb(Handle:timer, any:value)
{
if (!IsClientInGame(client) || !IsPlayerAlive(client))
{
KillTimeBomb(client);
new client = value & 0x7f;
new serial = value >> 7;
return Plugin_Handled;
}
g_TimeBombTracker[client]--;
if (!IsClientInGame(client)
|| !IsPlayerAlive(client)
|| serial != g_TimeBombSerial[client])
{
KillTimeBomb(client);
return Plugin_Stop;
}
g_TimeBombTime[client]--;
new Float:vec[3];
GetClientEyePosition(client, vec);
if (g_TimeBombTracker[client] > 0)
if (g_TimeBombTime[client] > 0)
{
new color;
if (g_TimeBombTracker[client] > 1)
if (g_TimeBombTime[client] > 1)
{
color = RoundToFloor(g_TimeBombTracker[client] * (128.0 / GetConVarFloat(g_TimeBombTicks)));
color = RoundToFloor(g_TimeBombTime[client] * (128.0 / GetConVarFloat(g_Cvar_TimeBombTicks)));
EmitAmbientSound(SOUND_BEEP, vec, client, SNDLEVEL_RAIDSIREN);
}
else
@ -144,19 +116,20 @@ public Action:Timer_TimeBomb(Handle:timer, any:client)
decl String:name[64];
GetClientName(client, name, sizeof(name));
PrintCenterTextAll("%t", "Till Explodes", name, g_TimeBombTracker[client]);
PrintCenterTextAll("%t", "Till Explodes", name, g_TimeBombTime[client]);
GetClientAbsOrigin(client, vec);
vec[2] += 10;
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_TimeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_TimeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
TE_SendToAll();
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_TimeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_TimeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
TE_SendToAll();
return Plugin_Continue;
}
else
{
TE_SetupExplosion(vec, g_ExplosionSprite, 5.0, 1, 0, GetConVarInt(g_TimeBombRadius), 5000);
TE_SetupExplosion(vec, g_ExplosionSprite, 5.0, 1, 0, GetConVarInt(g_Cvar_TimeBombRadius), 5000);
TE_SendToAll();
EmitAmbientSound(SOUND_BOOM, vec, client, SNDLEVEL_RAIDSIREN);
@ -165,13 +138,11 @@ public Action:Timer_TimeBomb(Handle:timer, any:client)
KillTimeBomb(client);
SetEntityRenderColor(client, 255, 255, 255, 255);
if (GetConVarInt(g_TimeBombMode) > 0)
if (GetConVarInt(g_Cvar_TimeBombMode) > 0)
{
new teamOnly = ((GetConVarInt(g_TimeBombMode) == 1) ? true : false);
new teamOnly = ((GetConVarInt(g_Cvar_TimeBombMode) == 1) ? true : false);
new maxClients = GetMaxClients();
//g_FilteredEntity = client;
for (new i = 1; i < maxClients; i++)
{
if (!IsClientInGame(i) || !IsPlayerAlive(i) || i == client)
@ -189,19 +160,19 @@ public Action:Timer_TimeBomb(Handle:timer, any:client)
new Float:distance = GetVectorDistance(vec, pos);
if (distance > GetConVarFloat(g_TimeBombRadius))
if (distance > GetConVarFloat(g_Cvar_TimeBombRadius))
{
continue;
}
new damage = 220;
damage = RoundToFloor(damage * ((GetConVarFloat(g_TimeBombRadius) - distance) / GetConVarFloat(g_TimeBombRadius)));
damage = RoundToFloor(damage * ((GetConVarFloat(g_Cvar_TimeBombRadius) - distance) / GetConVarFloat(g_Cvar_TimeBombRadius)));
SlapPlayer(i, damage, false);
TE_SetupExplosion(pos, g_ExplosionSprite, 0.05, 1, 0, 1, 1);
TE_SendToAll();
/*
/* ToDo
new Float:dir[3];
SubtractVectors(vec, pos, dir);
TR_TraceRayFilter(vec, dir, MASK_SOLID, RayType_Infinite, TR_Filter_Client);
@ -209,7 +180,7 @@ public Action:Timer_TimeBomb(Handle:timer, any:client)
if (i == TR_GetEntityIndex())
{
new damage = 100;
new radius = GetConVarInt(g_TimeBombRadius) / 2;
new radius = GetConVarInt(g_Cvar_TimeBombRadius) / 2;
if (distance > radius)
{
@ -222,9 +193,8 @@ public Action:Timer_TimeBomb(Handle:timer, any:client)
*/
}
}
return Plugin_Stop;
}
return Plugin_Handled;
}
public AdminMenu_TimeBomb(Handle:topmenu,
@ -292,7 +262,7 @@ public MenuHandler_TimeBomb(Handle:menu, MenuAction:action, param1, param2)
new String:name[32];
GetClientName(target, name, sizeof(name));
PerformTimeBomb(param1, target, 2);
PerformTimeBomb(param1, target);
ShowActivity2(param1, "[SM] ", "%t", "Toggled TimeBomb on target", "_s", name);
}
@ -308,27 +278,12 @@ public Action:Command_TimeBomb(client, args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_timebomb <#userid|name> [0/1]");
ReplyToCommand(client, "[SM] Usage: sm_timebomb <#userid|name>");
return Plugin_Handled;
}
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
new toggle = 2;
if (args > 1)
{
decl String:arg2[2];
GetCmdArg(2, arg2, sizeof(arg2));
if (arg2[0])
{
toggle = 1;
}
else
{
toggle = 0;
}
}
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
@ -349,7 +304,7 @@ public Action:Command_TimeBomb(client, args)
for (new i = 0; i < target_count; i++)
{
PerformTimeBomb(client, target_list[i], toggle);
PerformTimeBomb(client, target_list[i]);
}
if (tn_is_ml)

117
plugins/sounds.sp Normal file
View File

@ -0,0 +1,117 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Sound Commands Plugin
* Implements basic sound commands.
*
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#pragma semicolon 1
#include <sourcemod>
public Plugin:myinfo =
{
name = "Sound Commands",
author = "AlliedModders LLC",
description = "Sound Commands",
version = SOURCEMOD_VERSION,
url = "http://www.sourcemod.net/"
};
public OnPluginStart( )
{
RegAdminCmd("sm_play", Command_Play, ADMFLAG_GENERIC, "sm_play <#userid|name> <filename>");
}
public Action:Command_Play(client, args)
{
if (args < 2)
{
ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
}
new String:Arguments[PLATFORM_MAX_PATH + 65];
GetCmdArgString(Arguments, sizeof(Arguments));
decl String:Arg[65];
new len = BreakString(Arguments, Arg, sizeof(Arg));
/* Make sure it does not go out of bound by doing "sm_play user "*/
if (len == -1)
{
ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
return Plugin_Handled;
}
/* Incase they put quotes and white spaces after the quotes */
if (Arguments[len] == '"')
{
len++;
new FileLen = TrimString(Arguments[len]) + len;
if (Arguments[FileLen - 1] == '"')
{
Arguments[FileLen - 1] = '\0';
}
}
decl String:target_name[MAX_TARGET_LENGTH];
decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
if ((target_count = ProcessTargetString(
Arg,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_NO_BOTS,
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
ReplyToTargetError(client, target_count);
return Plugin_Handled;
}
for (new i = 0; i < target_count; i++)
{
ClientCommand(target_list[i], "playgamesound \"%s\"", Arguments[len]);
LogAction(client, target_list[i], "\"%L\" played sound on \"%L\" (file \"%s\")", client, target_list[i], Arguments[len]);
}
if (tn_is_ml)
{
ShowActivity2(client, "[SM] ", "%t", "Played sound to target", target_name);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Played sound to target", "_s", target_name);
}
return Plugin_Handled;
}