#pragma semicolon 1
#pragma tabsize 0
#include <sourcemod>
#include <sdktools_stringtables>
#include <halflife>
#include <clients>
#include <sdktools_functions>
#include <sdktools_entinput>
#include <sdktools_engine>
#include <sdktools_trace>
new String:NEED_CONTROL_POINT_PARTICLE_NAME[][] ={"blood_impact_synth_01_arc","blood_impact_synth_01_arc2","blood_impact_synth_01_arc3","blood_impact_synth_01_arc4","blood_impact_synth_01_arc_parents","muzzle_autorifles","muzzle_machinegun","muzzle_pistols","muzzle_rifles","muzzle_shotguns"};
new String:NEED_CENTER_POSITION_PARTICLE_NAME[][] ={"embers_small_01","env_fire_small_coverage_base","env_fire_small_coverage_base_smoke","water_splash_02_continuous"};
#define IsValidPlayer(%1) (1 <= %1 <= MaxClients && IsClientInGame(%1))
new NumTexture[MAXPLAYERS+1];
public Plugin:myinfo =
{
name = "Particle TEST Spawner",
author = "SeReGa_M",
version = "1.0",
url = "skype:serega123152"
};
public OnMapStart()
{
PrecacheGeneric("particles/AMBIENT.PCF" ,true);
PrecacheGeneric("particles/EXPLOSIONS_FX.PCF" ,true);
PrecacheGeneric("particles/LIGHTING.pcf" ,true);
PrecacheGeneric("particles/INFERNO_FX.pcf" ,true);
PrecacheGeneric("particles/WATER_IMPACT.pcf" ,true);
PrecacheGeneric("particles/CS_OFFICE.pcf" ,true);
PrecacheGeneric("particles/error.pcf" ,true);
PrecacheGeneric("particles/antlion_blood.pcf" ,true);
PrecacheGeneric("particles/blood_impact.pcf" ,true);
PrecacheGeneric("particles/water_impact.pcf" ,true);
PrecacheGeneric("particles/fire_01.pcf" ,true);
PrecacheGeneric("particles/burning_fx.pcf" ,true);
PrecacheGeneric("particles/combineball.pcf" ,true);
PrecacheGeneric("particles/vortigaunt_fx.pcf" ,true);
PrecacheGeneric("particles/rocket_fx.pcf" ,true);
}
public OnPluginStart()
{
RegConsoleCmd("t_menu", ParticleMenu);
RegConsoleCmd("menu_setnum", ParticleMenuSetnum);
}
public Action:ParticleMenu(client, args)
{
if (client) Particle_Menu(client);
return Plugin_Handled;
}
public Action:ParticleMenuSetnum(client, args)
{
if (args < 1) PrintToConsole(client,"Используйте: menu_setnum <номер> - Устанавливаем номер");
new String:arg1[32];
GetCmdArg(1, arg1, sizeof(arg1));
NumTexture[client] = StringToInt(arg1);
Particle_Menu(client);
return Plugin_Handled;
}
Particle_Menu(client)
{
if(NumTexture[client]>=9) NumTexture[client]=0;
PrintToChat(client,"%d",NumTexture[client]);
new Handle:Particles_Menu = CreateMenu(HandlerMenu);
decl String:In[128];
SetMenuTitle(Particles_Menu, "Particl под номером [%d]\n\n",NumTexture[client]+1);
Format(In, sizeof(In), "Показать\n");
AddMenuItem(Particles_Menu, "ShowEffect", In);
Format(In, sizeof(In), "След\n");
AddMenuItem(Particles_Menu, "NextEffect", In);
Format(In, sizeof(In), "Пред.Показать\n");
AddMenuItem(Particles_Menu, "PreviousEffect", In);
Format(In, sizeof(In), "Узнать Имя");
AddMenuItem(Particles_Menu, "show", In);
Format(In, sizeof(In), "чтобы переместится используте \n\n menu_setnum <№>");
AddMenuItem(Particles_Menu, "", In,ITEMDRAW_DISABLED);
DisplayMenu(Particles_Menu, client, MENU_TIME_FOREVER);
}
public HandlerMenu(Handle:Particles_Menu, MenuAction:action, client, param2)
{
if(action==MenuAction_Select)
{
decl String:info[32];
GetMenuItem(Particles_Menu, param2, info, sizeof(info));
if(IsValidPlayer(client))
{
if(StrEqual(info, "ShowEffect"))
{
AttachParticle(client, NEED_CONTROL_POINT_PARTICLE_NAME[NumTexture[client]],10.0);
}
else if(StrEqual(info, "NextEffect"))
{
NumTexture[client]++;
AttachParticle(client, NEED_CONTROL_POINT_PARTICLE_NAME[NumTexture[client]],10.0);
}
else if(StrEqual(info, "PreviousEffect"))
{
NumTexture[client]--;
AttachParticle(client, NEED_CONTROL_POINT_PARTICLE_NAME[NumTexture[client]],10.0);
}
if(StrEqual(info, "show"))
{
PrintToChat(client," PArticle NAME \x04\"\x01%s\x04\"",NEED_CONTROL_POINT_PARTICLE_NAME[NumTexture[client]]);
AttachParticle(client, NEED_CONTROL_POINT_PARTICLE_NAME[NumTexture[client]],10.0);
}
}
Particle_Menu(client);
}
else if(action == MenuAction_Cancel)
{
if(param2 == MenuCancel_ExitBack)
{
}
}
else if(action==MenuAction_End)
{
CloseHandle(Particles_Menu);
}
}
public OnClientPostAdminCheck(client)
{
NumTexture[client] = 0;
}
public OnClientDisconnect(client)
{
NumTexture[client] = 0;
}
GetLookPos(client, Float:Pos[3])
{
decl Float:EyePosition[3], Float:EyeAngles[3], Handle:h_trace;
GetClientEyePosition(client, EyePosition);
GetClientEyeAngles(client, EyeAngles);
h_trace = TR_TraceRayFilterEx(EyePosition, EyeAngles, MASK_SOLID, RayType_Infinite, GetLookPos_Filter, client);
TR_GetEndPosition(Pos, h_trace);
CloseHandle(h_trace);
}
public bool:GetLookPos_Filter(ent, mask, any:client)
{
return client != ent;
}
AttachParticle(client, String:particleType[], Float:time)
{
decl String:tName[64];
new particle = CreateEntityByName("info_particle_system");
if (IsValidEdict(particle))
{
new Float:pos[3];
GetLookPos(client, pos);
pos[2]+=30.0;
TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR);
GetEntPropString(client, Prop_Data, "m_iName", tName, sizeof(tName));
DispatchKeyValue(particle, "targetname", "particle"); // was tf2particle
DispatchKeyValue(particle, "parentname", tName);
DispatchKeyValue(particle, "effect_name", particleType);
DispatchSpawn(particle);
SetVariantString(tName);
AcceptEntityInput(particle, "SetParent", particle, particle, 0);
ActivateEntity(particle);
AcceptEntityInput(particle, "start");
CreateTimer(time, DeleteParticles, particle);
}
}
public Action:DeleteParticles(Handle:timer, any:particleRef)
{
DeleteParticle(particleRef);
return Plugin_Stop;
}
stock DeleteParticle(particleRef)
{
new particle = EntRefToEntIndex(particleRef);
if (particle > 0 && IsValidEntity(particle))
{
AcceptEntityInput(particle, "stop");
RemoveEdict(particle);
}
}