View Single Post
FoxMulder
Senior Member
Join Date: Jan 2009
Location: Orlando, FL
Old 07-10-2010 , 22:08   Re: Medic gun healing beam between two entities
Reply With Quote

PHP Code:
AttachParticle(entString:particleType[],controlpoint)
{
    
//This is used to attach a particle that has two control points
    //such as the medic gun beam. One originates from the medic
    //and the other to its healer
    
    //This particle is attached to the source player
    //This will be visible
    
new particle  CreateEntityByName("info_particle_system");
    
    
//This particle is attached to the destination player
    //This will not be visibile, we only need it so the source particle
    //is attached in the apropriate place
    
new particle2 CreateEntityByName("info_particle_system");

    if (
IsValidEdict(particle))
    {    
        
//Name the originating source, usually the player
        
new String:tName[128];
        
Format(tNamesizeof(tName), "target%i"ent);
        
DispatchKeyValue(ent"targetname"tName);
        
        
//Name the destination, usually another player
        
new String:cpName[128];
        
Format(cpNamesizeof(cpName), "target%i"controlpoint);
        
DispatchKeyValue(controlpoint"targetname"cpName);
        
        
//Name the particle (this particle is attached to the source player)
        
new String:particleName[128];
        
Format(particleNamesizeof(particleName), "tf2particle%i"particle);
        
DispatchKeyValue(particle"targetname"particleName);
        
        
//Tell it what effect name it is then spawn it so we can use it
        
DispatchKeyValue(particle"effect_name"particleType);
        
DispatchSpawn(particle);
        
        
//--------------------------------------
        
new String:cp2Name[128];
        
        
//Give the destination particle a unique anme
        
Format(cp2Namesizeof(cp2Name), "tf2particle%i"particle2);
        
        
DispatchKeyValue(particle2"targetname"cp2Name);
        
        
//Attach the destination particle to the destined player
        
DispatchKeyValue(particle2"parentname"cpName);
        
        
SetVariantString(cpName);
        
AcceptEntityInput(particle2"SetParent");
        
        
//Attach the destination particle to the "flag" (stomach area)
        
SetVariantString("flag");
        
AcceptEntityInput(particle2"SetParentAttachment");
        
//-----------------------------------------------
        
        //Here's where we "join" the two particles
        //Parent the source particle to the source player
        
DispatchKeyValue(particle"parentname"tName);
        
SetVariantString(tName);
        
AcceptEntityInput(particle"SetParent");
        
        
//Join the source particle to the destination particle
        
DispatchKeyValue(particle"cpoint1"cp2Name);
        
        
//Attach the source particle to the "flag" (stomach area)
        
SetVariantString("flag");
        
AcceptEntityInput(particle"SetParentAttachment");
        
        
//The particle is finally ready
        
ActivateEntity(particle);
        
AcceptEntityInput(particle"start");
        
        
//PrintToChatAll("Particle 1: %i   Particle 2: %i",particle,particle2);
    
}

This is a snippet from some code I have although I haven't used it in a good while so I really don't know how well it works now.
When it was working I would do something like

Code:
AttachParticle(Client1, "medicgun_beam_blue" ,Client2)
and that would attach the heal beam from Client 1 to Client 2.

Edit: Damn, I knew this seemed like Déjà vu https://forums.alliedmods.net/showpo...89&postcount=7
__________________

Last edited by FoxMulder; 07-10-2010 at 22:12.
FoxMulder is offline