Quote:
Originally Posted by Aviram1994
Forgot many things as TeamNum,player which fired and more..
Edit:
Can you explain how do we spawn a "particle system entity"?
|
Not sure what you mean about forgetting TeamNum and player which fired. These aren't weapon projectiles, just visual effects using the particle systems that come with TF2.
Spawning a particle system entity can be done like this:
Code:
public Action:DeleteParticles(Handle:timer, any:particle)
{
if (IsValidEntity(particle))
{
new String:classname[STRLENGTH];
GetEdictClassname(particle, classname, sizeof(classname));
if (StrEqual(classname, "info_particle_system", false))
{
RemoveEdict(particle);
}
else
{
LogError("DeleteParticles: not removing entity - not a particle '%s'", classname);
}
}
}
public ShowParticle(Float:pos[3], String:particlename[], Float:time)
{
new particle = CreateEntityByName("info_particle_system");
if (IsValidEdict(particle))
{
TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR);
DispatchKeyValue(particle, "effect_name", particlename);
ActivateEntity(particle);
AcceptEntityInput(particle, "start");
CreateTimer(time, DeleteParticles, particle);
}
else
{
LogError("ShowParticle: could not create info_particle_system");
}
}
AttachParticle(ent, String:particleType[], Float:time)
{
new particle = CreateEntityByName("info_particle_system");
if (IsValidEdict(particle))
{
new Float:pos[3];
GetEntPropVector(ent, Prop_Send, "m_vecOrigin", pos);
TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR);
GetEntPropString(ent, Prop_Data, "m_iName", tName, sizeof(tName));
DispatchKeyValue(particle, "targetname", "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);
}
else
{
LogError("AttachParticle: could not create info_particle_system");
}
}
ShowParticle spawns it at a location. AttachParticle is basically the same thing but attaches it to an entity. You can also set attachement points by using SetParentAttachment (in the same way as SetParent above). For example, when I show healthgained_blu/red I attach it to the player's head.
You'll also need to set the entities targetname to something unique before calling AttachParticle (I use something like DispatchKeyValue(ent, "targetname", TargetName); where TargetName is "myentXXX" and the XXX is the entity ID or some other unique number).
__________________