PDA

View Full Version : TE_Setupbeamlaser spawns at wrong location


Dr. Greg House
02-02-2012, 15:40
Hi guys.

public Action:TestCommand_Used(client, args)
{
decl targetid;

targetid = GetClientAimTarget(client, true);

if(targetid > 0)
{
if(IsClientConnected(targetid))
{
if(IsClientInGame(targetid) && !IsFakeClient(targetid))
{
if(GetUserAdmin(targetid) == INVALID_ADMIN_ID)
{

decl String:username[MAX_NAME_LENGTH];
decl String:targetname[MAX_NAME_LENGTH];

GetClientName(client, username, MAX_NAME_LENGTH);
GetClientName(targetid, targetname, MAX_NAME_LENGTH);

TE_SetupBeamLaser(client, targetid, g_sprite, 0, 0, 0, 1.0, 2.0, 2.0, 3, 0.0, beamcolor, 1);

for(new i=1;i<=MaxClients;i++)
{
if(IsClientConnected(i))
{
if(IsClientInGame(i) && !IsFakeClient(i))
{
if(GetUserAdmin(i) != INVALID_ADMIN_ID)
{
PrintToChat(i, "%s used testcommand on %s", username, targetname);

TE_SendToClient(i);
}
}
}
}
}
}
}
}

return Plugin_Handled;
}Somehow this beam does not appear between the two entities. However, when I turn around a bit, I see a red flicker (color is 255,0,0,100), so the material (materials/sprites/laserbeam.vmt) is definately being precached correctly when the plugin starts. I have no idea why the beam is not between the two entities but somewhere else and only visible in a glitchy and dislocated/disoriented way in front of my eyes if I turn around and stand still in a certain position.
Clientid and targetid are definately correct because the nicknames in the debugline are as well.

I'm using L4D2 btw.

Any ideas?
I'm clueless on that one.


Also, I wanted to play a laserbeam-sound but unfortunately I can't find any in the L4D2-soundlib, although I'm sure that I just haven't looked properly yet. Maybe one of you can give me the path of a useable soundfile, I'm pretty sure I heard one in a l4d2-plugin before.


Thanks in advance!
House

Dr. Greg House
02-04-2012, 11:58
No ideas?

Bacardi
02-04-2012, 12:53
Try different beam materials...

or quick try this. Haven't tested now because using another computer

#include <sdktools>
new mdlindx;

public OnPluginStart()
{
RegAdminCmd("sm_beam", beam, ADMFLAG_GENERIC);
}

public OnMapStart()
{
mdlindx = PrecacheModel("materials/sprites/purplelaser1.vmt");
}

public Action:beam(client, args)
{
new target;

if((target = GetClientAimTarget(client, false)) > 0) // && target <= MaxClients)
{
new colour[4];
colour[0] = 255;
colour[1] = 0;
colour[2] = 0;
colour[3] = 255;

TE_SetupBeamLaser( target, // StartEntity Entity index from where the beam starts.
client, // EndEntity Entity index from where the beam ends.
mdlindx, // ModelIndex Precached model index.
0, // HaloIndex Precached model index.
0, // StartFrame Initital frame to render.
0, // FrameRate Beam frame rate.
20.0, // Life Time duration of the beam.
1.0, // Width Initial beam width.
1.0, // EndWidth Final beam width.
0, // FadeLength Beam fade time duration.
0.0, // Amplitude Beam amplitude.
colour, // color Color array (r, g, b, a).
0); // Speed Speed of the beam.
TE_SendToAll(0.5);
}
return Plugin_Handled;
}
Just aim someone human player and use command sm_beam

Have read that it could make beam but you see it from up to down or vice versa.
But not show better from sides... Assuming now.

Dr. Greg House
02-04-2012, 13:25
No difference, sorry :(

What I've also noticed on both commands: Sometimes the game just crashes (only the client not the server, no error message on both sides, the server just registers a timeout). I mean, wtf?

blodia
02-04-2012, 18:02
for HaloIndex use g_sprite aswell.
also the origins of the entities are used for the start/end points so if both entities are clients then the origin is at the feet so it will be feet to feet.
i'd also move the tempent setup to just before where you send it, no point setting it up if you're not going to send it because of certain conditions.

Dr. Greg House
02-04-2012, 21:53
Still no difference. Also there is no connection between the feet.

blodia
02-05-2012, 09:19
try using TE_SetupBeamPoints instead and use the client/target eye posisiton as the start/end points, also add a check to see if client/target is a alive unless you want to be able to track them when they're dead too.

Dr. Greg House
02-05-2012, 12:04
That works, but has the disadvantage that it's not attached to the players.

Bacardi
02-06-2012, 13:42
I update my post #3

Ok, TE_SetupBeamLaser (http://docs.sourcemod.net/api/index.php?fastload=show&id=385&) works but maybe not way you like it.
It have laser effect.

You can see beam from one direction (look entity where beam start) and when your view is close between two entities.
Otherwise it fade out when look other way or move far.


But try this, using env_beam (I tested in Cs:s)

#include <sdktools>

public OnPluginStart()
{
RegAdminCmd("sm_beam", cmd_beam, ADMFLAG_GENERIC);
}

public Action:cmd_beam(client, args)
{
new target;

if((target = GetClientAimTarget(client, true)) > 0 && target <= MaxClients)
{
new beam = CreateEntityByName("env_beam");
if(beam > MaxClients)
{
new String:end[30];
new String:start[30];
Format(end, sizeof(end), "end%i", target);
DispatchKeyValue(target, "targetname", end); // Set player targetname
Format(start, sizeof(start), "start%i", client);
DispatchKeyValue(client, "targetname", start); // Set client targetname

DispatchKeyValue(beam, "BoltWidth", "2");
DispatchKeyValue(beam, "damage", "0");
DispatchKeyValue(beam, "decalname", "Bigshot");
DispatchKeyValue(beam, "framerate", "0");
DispatchKeyValue(beam, "framestart", "0");
DispatchKeyValue(beam, "TouchType", "0");
DispatchKeyValue(beam, "HDRColorScale", "1.0");
DispatchKeyValue(beam, "TextureScroll", "35");
DispatchKeyValue(beam, "life", "20"); // Beam lifetime
DispatchKeyValue(beam, "texture", "sprites/laserbeam.spr");
DispatchKeyValue(beam, "NoiseAmplitude", "0");
DispatchKeyValue(beam, "StrikeTime", "1");
DispatchKeyValue(beam, "Radius", "256");
DispatchKeyValue(beam, "spawnflags", "1");
DispatchKeyValue(beam, "renderamt", "100");
DispatchKeyValue(beam, "LightningEnd", end);
DispatchKeyValue(beam, "renderfx", "0");
DispatchKeyValue(beam, "LightningStart", start);
DispatchKeyValue(beam, "rendercolor", "255 0 0");
DispatchSpawn(beam);

SetVariantString("OnUser1 !self:kill::1.0:-1"); // Not need entity beam anymore
AcceptEntityInput(beam, "AddOutput");
AcceptEntityInput(beam, "FireUser1");
AcceptEntityInput(beam, "TurnOff");
AcceptEntityInput(beam, "TurnOn");
}
}
return Plugin_Handled;
}



*
by the way... can be done custom TempEnts ??


*edit
Here, I made stock in same code... this should be included in SM sdktools.
TE_SetupBeamEnts()
#include <sdktools>

new mdlindx;

public OnPluginStart()
{
RegAdminCmd("sm_beam", cmd_beam, ADMFLAG_GENERIC);
}

public OnMapStart()
{
mdlindx = PrecacheModel("materials/sprites/purplelaser1.vmt");
}

public Action:cmd_beam(client, args)
{
new target;

if((target = GetClientAimTarget(client, false)) > 0 && target <= MaxClients)
{
new colour[4];
colour[0] = 255;
colour[1] = 0;
colour[2] = 0;
colour[3] = 255;

TE_SetupBeamEnts(target, client, mdlindx, 0, 0, 0, 10.0, 1.0, 1.0, 0, 0.0, colour, 0);
TE_SendToAll(0.1);
}
return Plugin_Handled;
}

stock TE_SetupBeamEnts(StartEntity, EndEntity, ModelIndex, HaloIndex, StartFrame, FrameRate, Float:Life,
Float:Width, Float:EndWidth, FadeLength, Float:Amplitude, const Color[4], Speed)
{
TE_Start("BeamEnts");
TE_WriteEncodedEnt("m_nStartEntity", StartEntity);
TE_WriteEncodedEnt("m_nEndEntity", EndEntity);
TE_WriteNum("m_nModelIndex", ModelIndex);
TE_WriteNum("m_nHaloIndex", HaloIndex);
TE_WriteNum("m_nStartFrame", StartFrame);
TE_WriteNum("m_nFrameRate", FrameRate);
TE_WriteFloat("m_fLife", Life);
TE_WriteFloat("m_fWidth", Width);
TE_WriteFloat("m_fEndWidth", EndWidth);
TE_WriteFloat("m_fAmplitude", Amplitude);
TE_WriteNum("r", Color[0]);
TE_WriteNum("g", Color[1]);
TE_WriteNum("b", Color[2]);
TE_WriteNum("a", Color[3]);
TE_WriteNum("m_nSpeed", Speed);
TE_WriteNum("m_nFadeLength", FadeLength);
}

Dr. Greg House
08-20-2013, 14:07
Unfortunately, none of these examples are working, no errors, nothing happens. I'm using "materials/sprites/laserbeam.vmt".