AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   TE_Setupbeamlaser spawns at wrong location (https://forums.alliedmods.net/showthread.php?t=177518)

Dr. Greg House 02-02-2012 15:40

TE_Setupbeamlaser spawns at wrong location
 
Hi guys.

Code:

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

Re: TE_Setupbeamlaser spawns at wrong location
 
No ideas?

Bacardi 02-04-2012 12:53

Re: TE_Setupbeamlaser spawns at wrong location
 
Try different beam materials...

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

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

Re: TE_Setupbeamlaser spawns at wrong location
 
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

Re: TE_Setupbeamlaser spawns at wrong location
 
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

Re: TE_Setupbeamlaser spawns at wrong location
 
Still no difference. Also there is no connection between the feet.

blodia 02-05-2012 09:19

Re: TE_Setupbeamlaser spawns at wrong location
 
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

Re: TE_Setupbeamlaser spawns at wrong location
 
That works, but has the disadvantage that it's not attached to the players.

Bacardi 02-06-2012 13:42

Re: TE_Setupbeamlaser spawns at wrong location
 
I update my post #3

Ok, TE_SetupBeamLaser 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)
Spoiler



*
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()
PHP Code:

#include <sdktools>

new mdlindx;

public 
OnPluginStart()
{
    
RegAdminCmd("sm_beam"cmd_beamADMFLAG_GENERIC);
}

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

public 
Action:cmd_beam(clientargs)
{
    new 
target;

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

        
TE_SetupBeamEnts(targetclientmdlindx00010.01.01.000.0colour0);
        
TE_SendToAll(0.1);
    }
    return 
Plugin_Handled;
}

stock TE_SetupBeamEnts(StartEntityEndEntityModelIndexHaloIndexStartFrameFrameRateFloat:Life
                
Float:WidthFloat:EndWidthFadeLengthFloat: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

Re: TE_Setupbeamlaser spawns at wrong location
 
Unfortunately, none of these examples are working, no errors, nothing happens. I'm using "materials/sprites/laserbeam.vmt".


All times are GMT -4. The time now is 13:49.

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