#pragma semicolon 1
#include <sourcemod>
#include <sdktools_functions>
#include <sdktools_entinput>
public Plugin:myinfo =
{
name = "C4 Glow",
author = "wS (World-Source.Ru)",
version = "1.0"
};
#define EFFECT_MODEL "sprites/glow01.spr"
new g_C4, g_Glow = INVALID_ENT_REFERENCE;
public OnPluginStart()
{
HookEvent("bomb_pickup", bomb_pickup, EventHookMode_Post);
HookEvent("bomb_dropped", bomb_dropped, EventHookMode_Post);
HookEvent("round_start", round_start, EventHookMode_PostNoCopy);
}
public OnMapStart()
{
PrecacheModel(EFFECT_MODEL, true);
}
public round_start(Handle:event, const String:name[], bool:silent)
{
g_C4 = 0;
g_Glow = INVALID_ENT_REFERENCE;
}
public bomb_dropped(Handle:event, const String:name[], bool:silent)
{
if (g_C4 < 1)
{
if ((g_C4 = FindEntityByClassname(-1, "weapon_c4")) < 1)
return;
DispatchKeyValue(g_C4, "targetname", "c4_glow");
}
decl Float:fOrigin[3];
GetEntPropVector(g_C4, Prop_Data, "m_vecAbsOrigin", fOrigin);
if (g_Glow == INVALID_ENT_REFERENCE)
{
new e = CreateEntityByName("env_sprite");
if (e < 1) return;
g_Glow = EntIndexToEntRef(e);
DispatchKeyValue(e, "model", EFFECT_MODEL);
DispatchKeyValueVector(e, "origin", fOrigin);
DispatchKeyValue(e, "rendermode", "5");
DispatchKeyValue(e, "scale", "1");
DispatchKeyValue(e, "renderamt", "255");
DispatchKeyValue(e, "rendercolor", "255 0 0");
DispatchSpawn(e);
SetVariantString("c4_glow");
AcceptEntityInput(e, "SetParent");
}
go("ShowSprite");
}
public bomb_pickup(Handle:event, const String:name[], bool:silent)
{
go("HideSprite");
}
go(const String:input[])
{
new e = EntRefToEntIndex(g_Glow);
if (e > 0) AcceptEntityInput(e, input);
}