Raised This Month: $32 Target: $400
 8% 

[SOLVED]Attaching a circle to a player.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zylius
SourceMod Donor
Join Date: Nov 2009
Old 06-17-2012 , 10:57   [SOLVED]Attaching a circle to a player.
Reply With Quote #1

Hello, I'm trying to parent "ring" entity to a player.
Now the only entities which can do that, as far as I know, are env_beam and Temp entities (which cannot be hooked).
For simplicity I tried doing this, ongameframe
Code:
	for(new i = 1; i<=MAXPLAYERS; i++)
		if(IsValidClient(i,false) && IsPlayerAlive(i))
			{
				GetClientAbsOrigin(i, vec);
				vec[2] += 5.0;
				TE_SetupBeamRingPoint(vec,99.9,100.0,precache_beam, 0, 0, 66, 0.06, 3.0, 0.0, color, 0, 0);
				TE_SendToAll();
			}
As you would imagine it didn't work very well, it is quite hard on the server and especially on the client. Also, a temp ent with a life time <= 0.05 is a permanent one, so you get a "laggy" trail behind.
Now with env_beam, you need two brush entities, + env_beam itself I've been using this Bacardi's example of how to create a simple beam (it works great). Though if I try to spawn two func_train's (start and end) before that, set their origin, modify LightningStart, LightningEnd and spawnflags of env_beam it just does not appear, still the entity is created. I kept trying to make it work for a few days but then gave up and thought I should ask you guys
I hope there is someone who had some experience with this ;)

Last edited by Zylius; 06-17-2012 at 15:50.
Zylius is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 06-17-2012 , 11:15   Re: Attaching a circle to a player.
Reply With Quote #2

first of all using ongameframe is not isn't simplicity, using OnPlayerRunCmd is as its called on every player every gameframe and is only called if they're in game, so you don't need a loop or check if they're in game.

you can use any entity that has a model aswell as brushes for the start/end entities, you're better of using a prop_dynamic that is invisible and non solid.
blodia is offline
Zylius
SourceMod Donor
Join Date: Nov 2009
Old 06-17-2012 , 12:14   Re: Attaching a circle to a player.
Reply With Quote #3

Quote:
Originally Posted by blodia View Post
first of all using ongameframe is not isn't simplicity, using OnPlayerRunCmd is as its called on every player every gameframe and is only called if they're in game, so you don't need a loop or check if they're in game.

you can use any entity that has a model aswell as brushes for the start/end entities, you're better of using a prop_dynamic that is invisible and non solid.
Thanks, i'll try it and report back
-------------------------------------------
With huge support from blodia, we got it working ;)
PHP Code:
AttachBeam(client)
{
    
decl String:beamindex[30],String:start[30],String:end[30],String:parentName[64];
    
Format(parentNamesizeof(parentName), "%i:%N"clientclient);
    
DispatchKeyValue(client"targetname"parentName);
    new 
Float:vec[3];
    
GetClientAbsOrigin(clientvec);
    
    new 
startent CreateEntityByName("prop_dynamic");
    
Format(startsizeof(start), "start%i"startent);
    
DispatchKeyValue(startent"targetname"start); 
    
DispatchKeyValue(startent"model""models/advisor.mdl"); 
    
DispatchKeyValue(startent"solid""0");
    
DispatchKeyValue(startent"rendermode""10");
    
DispatchSpawn(startent);
    
ActivateEntity(startent);
    
vec[1] += 100//add 100 to the y axis, so it's away from the player itself
    
TeleportEntity(startentvecNULL_VECTORNULL_VECTOR);
    
SetVariantString(parentName);
    
AcceptEntityInput(startent"SetParent");
    
SetVariantString("defusekit");
    
AcceptEntityInput(startent"SetParentAttachmentMaintainOffset");
    
    new 
endent CreateEntityByName("prop_dynamic");
    
Format(endsizeof(end), "end%i"endent);
    
DispatchKeyValue(endent"targetname"end); 
    
DispatchKeyValue(endent"model""models/advisor.mdl"); 
    
DispatchKeyValue(endent"solid""0");
    
DispatchKeyValue(endent"rendermode""10");
    
DispatchSpawn(endent);
    
ActivateEntity(endent);
    
vec[1] -= 200// do the same here, only reverse
    
TeleportEntity(endentvecNULL_VECTORNULL_VECTOR);
    
SetVariantString(parentName);
    
AcceptEntityInput(endent"SetParent");
    
SetVariantString("defusekit");
    
AcceptEntityInput(endent"SetParentAttachmentMaintainOffset");
    
    new 
beament  CreateEntityByName("env_beam");
    if (
IsValidEdict(beament))
    {
        
        
Format(beamindexsizeof(beamindex), "Beam%i"beament);
        
        
// Set keyvalues on the beam.
        
DispatchKeyValue(beament"damage""0");
        
DispatchKeyValue(beament"framestart""0");
        
DispatchKeyValue(beament"BoltWidth""10");
        
DispatchKeyValue(beament"renderfx""0");
        
DispatchKeyValue(beament"TouchType""3");
        
DispatchKeyValue(beament"framerate""0");
        
DispatchKeyValue(beament"decalname""Bigshot");
        
DispatchKeyValue(beament"TextureScroll""35");
        
DispatchKeyValue(beament"HDRColorScale""1.0");
        
DispatchKeyValue(beament"texture""materials/sprites/laserbeam.vmt");
        
DispatchKeyValue(beament"life""0"); 
        
DispatchKeyValue(beament"targetname"beamindex);
        
DispatchKeyValue(beament"LightningStart"start);
        
DispatchKeyValue(beament"LightningEnd"end); 
        
DispatchKeyValue(beament"StrikeTime""1"); 
        
DispatchKeyValue(beament"spawnflags""8"); 
        
DispatchKeyValue(beament"NoiseAmplitude""0"); 
        
DispatchKeyValue(beament"Radius""256");
        
DispatchKeyValue(beament"rendercolor""255 255 255");
        
DispatchKeyValue(beament"renderamt""100");
        
        
DispatchSpawn(beament);
        
ActivateEntity(beament);
        
TeleportEntity(beamentvecNULL_VECTORNULL_VECTOR);
        
CreateTimer(0.5beam_enablebeament);
    }
}

public 
Action:beam_enable(Handle:timerany:beam)
{
    
AcceptEntityInput(beam"TurnOn");


Last edited by Zylius; 06-17-2012 at 15:51.
Zylius is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode