#pragma semicolon 1
#include <sourcemod>
//#include <sdktools_sound>
#include <sdktools_entinput>
#include <sdktools_functions>
#define Parlament_BEAM_MODEL "sprites/laser.vmt"
#define EFFECT_MODELS "sprites/redglow1.vmt"
#define EFFECT_MODELG "sprites/ledglow.vmt"
#define MODEL_ES "sprites/strider_blackball.vmt"
#define EFFECT_SMOKE "particle/smokestack.vmt"
new Handle:c4_model;
new bool:gBombEvents,
bool:gBombPlanted,
bool:gBombDefused,
bool:gBombPlanting,
bool:gBombExploded,
bool:gBombAbort,
bool:gBombPickUp,
bool:gBombDropped,
bool:gBombDefusing,
bool:gBombAbortDef,
bool:gPlandsc,
bool:b_cssGO,
bool:gPrintBomb;
new g_iSmokeEntity,
Parlament_Plant_Index,
gPrintType,
g_TimeFind, g_TimeBomb;
new String:s_c4_model[PLATFORM_MAX_PATH],
String:s_gameDir[8];
public Plugin:myinfo =
{
name = "Bomb Events",
author = "Parlament",
description = "c4 еффекты и события",
version = "1.5f2"
};
public OnPluginStart()
{
new Handle:cvar;
HookConVarChange((cvar = CreateConVar("sm_bombpp_enabled", "1", "Включить/Выключить плагин", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_gBombEvents);
gBombEvents = GetConVarBool(cvar);
HookConVarChange((cvar = CreateConVar("sm_bombpp_planted", "1", "Включить/Выключить оповещение Установка бомбы", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_gBombPlanted);
gBombPlanted = GetConVarBool(cvar);
HookConVarChange((cvar = CreateConVar("sm_bombpp_defused", "1", "Включить/Выключить оповещение Бомба разминирована", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_gBombDefused);
gBombDefused = GetConVarBool(cvar);
HookConVarChange((cvar = CreateConVar("sm_bombpp_planting", "0", "Включить/Выключить оповещение Бомбу устанавливают", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_gBombPlanting);
gBombPlanting = GetConVarBool(cvar);
HookConVarChange((cvar = CreateConVar("sm_bombpp_exploded", "0", "Включить/Выключить оповещение Бомба взорвана", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_gBombExploded);
gBombExploded = GetConVarBool(cvar);
HookConVarChange((cvar = CreateConVar("sm_bombpp_abort", "0", "Включить/Выключить оповещение Бомба не установлена", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_gBombAbort);
gBombAbort = GetConVarBool(cvar);
HookConVarChange((cvar = CreateConVar("sm_bombpp_pickup", "0", "Включить/Выключить оповещение Бомба поднята", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_gBombPickUp);
gBombPickUp = GetConVarBool(cvar);
HookConVarChange((cvar = CreateConVar("sm_bombpp_dropped", "0", "Включить/Выключить оповещение Бомба сброшена", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_gBombDropped);
gBombDropped = GetConVarBool(cvar);
HookConVarChange((cvar = CreateConVar("sm_bombpp_defusing", "0", "Включить/Выключить оповещение Дефьюз бомбы", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_gBombDefusing);
gBombDefusing = GetConVarBool(cvar);
HookConVarChange((cvar = CreateConVar("sm_bombpp_abortdefuse", "0", "Включить/Выключить оповещение Дефьюз бомбы прекращен", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_gBombAbortDef);
gBombAbortDef = GetConVarBool(cvar);
HookConVarChange((cvar = CreateConVar("sm_bombpp_plandsc", "0", "Включить/Выключить смена модели c4", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_gPlandsc);
gPlandsc = GetConVarBool(cvar);
HookConVarChange((cvar = CreateConVar("sm_bombpp_printtype", "2", "Куда оповещать игроков 1 - Панель подсказок, 2 - Чат, 3 - Центр, 4 - С правой стороны", FCVAR_PLUGIN, true, 1.0, true, 4.0)), Cvar_i_gPrintType); // 1 hint, 2 chat, 3 center
gPrintType = GetConVarInt(cvar);
HookConVarChange((cvar = CreateConVar("sm_bombpp_printbomb", "1", "Таймер бомбы", FCVAR_PLUGIN, true, 0.0, true, 1.0)), Cvar_b_gPrintBomb);
gPrintBomb = GetConVarBool(cvar);
CloseHandle(cvar);
g_TimeFind = GetConVarInt(FindConVar("mp_c4timer"));
GetGameFolderName(s_gameDir, sizeof(s_gameDir));
if (StrEqual("cstrike", s_gameDir))
{
b_cssGO = true;
c4_model = CreateConVar("sm_c4_model", "models/roller_spikes.mdl", "Модель установленной бомбы CSS", FCVAR_PLUGIN);
}
else if (StrEqual("csgo", s_gameDir))
{
b_cssGO = false;
c4_model = CreateConVar("sm_c4_model", "models/csgobomb.mdl", "Модель установленной бомбы CSGO", FCVAR_PLUGIN);
}
GetConVarString(c4_model, s_c4_model, sizeof(s_c4_model));
HookConVarChange(c4_model, ConVarChanges);
HookEvent("bomb_beginplant", Event_BeginPlant);
HookEvent("bomb_abortplant", Event_BombAbort);
HookEvent("bomb_planted", Event_BombPlanted);
HookEvent("bomb_defused", Event_BombDefused);
HookEvent("bomb_exploded", Event_BombExploded);
HookEvent("bomb_dropped", Event_BombDropped);
HookEvent("bomb_pickup", Event_BombPickup);
HookEvent("bomb_begindefuse", Event_BombBeginDefuse);
HookEvent("bomb_abortdefuse", Event_BombAbortDefuse);
HookEvent("bomb_beep", Event_BombBeep);
AutoExecConfig(true, "bomb++v15f2");
LoadTranslations("bomb++v15f2.phrases");
}
/*
public OnAutoConfigsBuffered()
{
if(!gBombEvents || !gPrintBomb)UnhookEvent("bomb_beep", Event_BombBeep);
}
*/
public OnMapStart()
{
if (b_cssGO)PrecacheModel(EFFECT_MODELS);
else PrecacheModel(EFFECT_MODELG);
PrecacheModel(Parlament_BEAM_MODEL, true);
}
public Cvar_b_gBombEvents(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
gBombEvents = GetConVarBool(cvar);
if (gBombEvents)
{
HookEvent("bomb_beginplant", Event_BeginPlant);
HookEvent("bomb_abortplant", Event_BombAbort);
HookEvent("bomb_planted", Event_BombPlanted);
HookEvent("bomb_defused", Event_BombDefused);
HookEvent("bomb_exploded", Event_BombExploded);
HookEvent("bomb_dropped", Event_BombDropped);
HookEvent("bomb_pickup", Event_BombPickup);
HookEvent("bomb_begindefuse", Event_BombBeginDefuse);
HookEvent("bomb_abortdefuse", Event_BombAbortDefuse);
HookEvent("bomb_beep", Event_BombBeep);
}
else if (!gBombEvents)
{
UnhookEvent("bomb_beginplant", Event_BeginPlant);
UnhookEvent("bomb_abortplant", Event_BombAbort);
UnhookEvent("bomb_planted", Event_BombPlanted);
UnhookEvent("bomb_defused", Event_BombDefused);
UnhookEvent("bomb_exploded", Event_BombExploded);
UnhookEvent("bomb_dropped", Event_BombDropped);
UnhookEvent("bomb_pickup", Event_BombPickup);
UnhookEvent("bomb_begindefuse", Event_BombBeginDefuse);
UnhookEvent("bomb_abortdefuse", Event_BombAbortDefuse);
UnhookEvent("bomb_beep", Event_BombBeep);
}
}
public Cvar_b_gBombPlanted(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
gBombPlanted = GetConVarBool(cvar);
}
public Cvar_b_gBombDefused(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
gBombDefused = GetConVarBool(cvar);
}
public Cvar_b_gBombPlanting(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
gBombPlanting = GetConVarBool(cvar);
}
public Cvar_b_gBombExploded(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
gBombExploded = GetConVarBool(cvar);
}
public Cvar_b_gBombAbort(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
gBombAbort = GetConVarBool(cvar);
}
public Cvar_b_gBombPickUp(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
gBombPickUp = GetConVarBool(cvar);
}
public Cvar_b_gBombDropped(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
gBombDropped = GetConVarBool(cvar);
}
public Cvar_b_gBombDefusing(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
gBombDefusing = GetConVarBool(cvar);
}
public Cvar_b_gBombAbortDef(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
gBombAbortDef = GetConVarBool(cvar);
}
public Cvar_b_gPlandsc(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
gPlandsc = GetConVarBool(cvar);
}
public Cvar_b_gPrintBomb(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
gPrintBomb = GetConVarBool(cvar);
}
public Cvar_i_gPrintType(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
gPrintType = GetConVarInt(cvar);
}
public ConVarChanges(Handle:convar, const String:oldValue[], const String:newValue[])
{
//if (convar == c4_model)
GetConVarString(c4_model, s_c4_model, sizeof(s_c4_model));
}
public Action:Event_BeginPlant(Handle:event, const String:name[], bool:dontBroadcast)
{
if (gBombPlanting)gBomb(GetClientOfUserId(GetEventInt(event, "userid")), 1);
}
public Action:Event_BombAbort(Handle:event, const String:name[], bool:dontBroadcast)
{
if (gBombAbort)gBomb(GetClientOfUserId(GetEventInt(event, "userid")), 2);
}
public Event_BombBeep(Handle:event, const String:name[], bool:dontBroadcast)
{
if (gPrintBomb)
{
new itemp = g_TimeBomb - GetTime();
if (itemp >= 0 && itemp <= g_TimeFind)PrintHintTextToAll("C4: %d", itemp);
}
}
public Action:Event_BombPlanted(Handle:event, const String:name[], bool:dontBroadcast)
{
if (gPrintBomb)g_TimeBomb = GetTime() + g_TimeFind;
Parlament_Plant_Index = FindEntityByClassname(MaxClients + 1, "planted_c4");
if (gPlandsc)
{
if (Parlament_Plant_Index > 0)
{
// модель
if (StrContains(s_c4_model, "models") == 0 && StrContains(s_c4_model, ".mdl") > 1)
{
PrecacheModel(s_c4_model, true);
SetEntityModel(Parlament_Plant_Index, s_c4_model);
}
}
}
g_iSmokeEntity = CreateEntityByName("env_smokestack");
DispatchKeyValue(g_iSmokeEntity, "SmokeMaterial", EFFECT_SMOKE);
GiSmoke(g_iSmokeEntity, "30", "100", "10", "10", "100", "150", "70", "255 16 5");
//BaseSpread = радиус кольца,
//Speed = скорость движения частиц дыма,
//StartSize = размер частиц дыма в начале столба дыма,
//EndSize = размер частицы дыма на конце столба дыма,
//Rate = скорость излучения частиц дыма в секунду,
//JetLength = длина столба дыма,
//Twist = скорость закручивания частиц дыма,
//rendercolor = цвет в R G B
new Planted_C4 = -1;
Planted_C4 = FindEntityByClassname(Planted_C4, "planted_c4");
new Float:flc4_position[3];
GetEntPropVector(Planted_C4, Prop_Send, "m_vecOrigin", flc4_position);
TeleportEntity(g_iSmokeEntity, flc4_position, NULL_VECTOR, NULL_VECTOR);
DispatchSpawn(g_iSmokeEntity);
AcceptEntityInput(g_iSmokeEntity, "TurnOn");
if (gBombPlanted)gBomb(GetClientOfUserId(GetEventInt(event, "userid")), 3);
return Plugin_Continue;
}
public Action:Event_BombDefused(Handle:event, const String:name[], bool:dontBroadcast)
{
if (gBombDefused)gBomb(GetClientOfUserId(GetEventInt(event, "userid")), 4);
}
public Action:Event_BombExploded(Handle:event, const String:name[], bool:dontBroadcast)
{
if (gBombExploded)gBomb(GetClientOfUserId(GetEventInt(event, "userid")), 5);
}
public Action:Event_BombDropped(Handle:event, const String:name[], bool:dontBroadcast)
{
if (gBombDropped)gBomb(GetClientOfUserId(GetEventInt(event, "userid")), 6);
}
public Action:Event_BombPickup(Handle:event, const String:name[], bool:dontBroadcast)
{
if (gBombPickUp)gBomb(GetClientOfUserId(GetEventInt(event, "userid")), 7);
}
public Action:Event_BombBeginDefuse(Handle:event, const String:name[], bool:dontBroadcast)
{
AcceptEntityInput(g_iSmokeEntity, "TurnOff");
DispatchKeyValue(g_iSmokeEntity, "SmokeMaterial", b_cssGO ? MODEL_ES : EFFECT_MODELG);
GiSmoke(g_iSmokeEntity, "40", "100", "10", "12", "100", "500", "500", "100 100 220");
//BaseSpread = радиус кольца,
//Speed = скорость движения частиц дыма,
//StartSize = размер частиц дыма в начале столба дыма,
//EndSize = размер частицы дыма на конце столба дыма,
//Rate = скорость излучения частиц дыма в секунду,
//JetLength = длина столба дыма,
//Twist = скорость закручивания частиц дыма,
//rendercolor = цвет в R G B
if (gBombDefusing)gBomb(GetClientOfUserId(GetEventInt(event, "userid")), 8);
}
public Action:Event_BombAbortDefuse(Handle:event, const String:name[], bool:dontBroadcast)
{
DispatchKeyValue(g_iSmokeEntity, "SmokeMaterial", EFFECT_SMOKE);
GiSmoke(g_iSmokeEntity, "30", "100", "10", "10", "100", "150", "70", "255 16 5");
//BaseSpread = радиус кольца,
//Speed = скорость движения частиц дыма,
//StartSize = размер частиц дыма в начале столба дыма,
//EndSize = размер частицы дыма на конце столба дыма,
//Rate = скорость излучения частиц дыма в секунду,
//JetLength = длина столба дыма,
//Twist = скорость закручивания частиц дыма,
//rendercolor = цвет в R G B
if (gBombAbortDef)gBomb(GetClientOfUserId(GetEventInt(event, "userid")), 9);
}
public OnEntityCreated(iEntity, const String:sClassName[])
{
if (StrEqual(sClassName, "weapon_c4"))
{
if (Parlament_Plant_Index)
{
new iGlowEntity = CreateEntityByName("env_glow");
DispatchKeyValue(iGlowEntity, "model", b_cssGO ? EFFECT_MODELS : EFFECT_MODELG);
DispatchKeyValue(iGlowEntity, "rendermode", "3"); // свечение
DispatchKeyValue(iGlowEntity, "scale", "1.0"); // размер свечения
DispatchKeyValue(iGlowEntity, "renderamt", "255"); // прозрачность
DispatchKeyValue(iGlowEntity, "rendercolor", "255 0 0"); // цвет
if (DispatchSpawn(iGlowEntity))
{
decl String:sTargetName[32], Float:fOrigin[3];
Format(sTargetName, sizeof(sTargetName), "weapon_c4_%d", iGlowEntity);
DispatchKeyValue(iEntity, "targetname", sTargetName);
GetEntPropVector(iEntity, Prop_Data, "m_vecOrigin", fOrigin);
SetVariantString(sTargetName);
AcceptEntityInput(iGlowEntity, "SetParent");
TeleportEntity(iGlowEntity, fOrigin, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(iGlowEntity, "ShowSprite");
AcceptEntityInput(iGlowEntity, "TurnOn");
}
}
}
}
gBomb(client, translit)
{
decl String:place[10], String:g_Msg[128];
switch (gPrintType)
{
case 1:
{
FormatEx(place, sizeof(place), "bombh%d", translit);
FormatEx(g_Msg, sizeof(g_Msg), " %t", place, client);
PrintHintTextToAll(g_Msg);
}
case 2:
{
FormatEx(place, sizeof(place), "bombs%d", translit);
FormatEx(g_Msg, sizeof(g_Msg), " \x04%t", place, client);
PrintToChatAll(g_Msg);
}
case 3:
{
FormatEx(place, sizeof(place), "bombc%d", translit);
FormatEx(g_Msg, sizeof(g_Msg), " %t", place, client);
PrintCenterTextAll(g_Msg);
}
case 4:
{
FormatEx(place, sizeof(place), "bombk%d", translit);
FormatEx(g_Msg, sizeof(g_Msg), " %t", place, client);
new Handle:Messages = StartMessageAll("KeyHintText");
if (Messages != INVALID_HANDLE)
{
BfWriteByte(Messages, 1);
BfWriteString(Messages, g_Msg);
EndMessage();
}
}
}
}
GiSmoke(g_iSmoke, const String:BaseSpread[], const String:Speed[], const String:StartSize[], const String:EndSize[], const String:Rate[], const String:JetLength[], const String:Twist[], const String:rendercolor[])
{
DispatchKeyValue(g_iSmoke, "BaseSpread", BaseSpread);
DispatchKeyValue(g_iSmoke, "Speed", Speed);
DispatchKeyValue(g_iSmoke, "StartSize", StartSize);
DispatchKeyValue(g_iSmoke, "EndSize", EndSize);
DispatchKeyValue(g_iSmoke, "Rate", Rate);
DispatchKeyValue(g_iSmoke, "JetLength", JetLength);
DispatchKeyValue(g_iSmoke, "Twist", Twist);
DispatchKeyValue(g_iSmoke, "rendercolor", rendercolor);
DispatchKeyValue(g_iSmoke, "RenderAmt", "255");
DispatchKeyValue(g_iSmoke, "Angles", "0");
AcceptEntityInput(g_iSmoke, "TurnOn");
}