AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   vector beam problem (https://forums.alliedmods.net/showthread.php?t=134089)

Swear 07-31-2010 16:39

vector beam problem
 
Hello! I found some snippets on this board and i'm trying to make plugin that shows players aiming vector beam. it works but there's problem. when i'm fast moving mouse beams split up. old beams doesn't hide fast enought. image explaining it:
[IMG]http://img34.**************/img34/4726/bugdj.png[/IMG]

here's the code
Code:

#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <xs>

new sprite;

public plugin_init()
{
    register_plugin("Laser Beam", "1.0", "stupok")
   
    register_forward(FM_PlayerPreThink, "fw_playerprethink")
}

public plugin_precache()
{
    sprite = precache_model("sprites/laserbeam.spr");
}

public fw_playerprethink(id)
{
    show_beam2(id)
}


public show_beam2(id)
{
    static Float:fStart[3], Float:fEnd[3];
    static tr;
   
    // This block is interchangeable with get_user_origin(id,origin,3)
    pev(id, pev_origin, fStart)
   
    pev(id, pev_v_angle, fEnd)
    engfunc(EngFunc_MakeVectors, fEnd)
    global_get(glb_v_forward, fEnd)
    xs_vec_mul_scalar(fEnd, 9999.0, fEnd)
    xs_vec_add(fStart, fEnd, fEnd)
   
    tr = create_tr2()
    engfunc(EngFunc_TraceLine, fStart, fEnd, DONT_IGNORE_MONSTERS, id, tr)
    get_tr2(tr, TR_vecEndPos, fEnd)
    free_tr2(tr)
    //
   
    //get_user_origin(id,origin,3); // 3 - End position from eyes (hit point for weapon)
   
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    write_byte(1);
    write_short(id | 0x1000); // start entity
    engfunc(EngFunc_WriteCoord, fEnd[0])
    engfunc(EngFunc_WriteCoord, fEnd[1])
    engfunc(EngFunc_WriteCoord, fEnd[2])
    //write_coord(origin[0]); // endposition.x
    //write_coord(origin[1]); // endposition.y
    //write_coord(origin[2]); // endposition.z
    write_short(sprite); // sprite index
    write_byte(0); // starting frame
    write_byte(0); // frame rate in 0.1's
    write_byte(1); // life in 0.1's
    write_byte(10); // line wdith in 0.1's
    write_byte(0); // noise amplitude in 0.01's
    write_byte(0); // red
    write_byte(0); // green
    write_byte(255); // blue
    write_byte(255); // brightness
    write_byte(255); // scroll speed in 0.1's
    message_end();

    return PLUGIN_HANDLED;
}

sorry for my bad english.

minimiller 07-31-2010 16:48

Re: vector beam problem
 
your problem is with
PHP Code:

write_byte(1); // life in 0.1's 

unfortunately you cannot make them have less life so you have to live with it

i came across this problem a while ago =[

Swear 07-31-2010 16:54

Re: vector beam problem
 
damn. but i have seen admin_spectator_esp with aim vector beam, i think that didn't had this bug.

edit: ahh it's different, and it lags. theres must be solution i really need this :/

meTaLiCroSS 07-31-2010 17:56

Re: vector beam problem
 
Before calling the TE_ message TE_BEAMENTPOINT, call the message TE_KILLBEAM

It should be like this:

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <xs>

new sprite;

public 
plugin_init()
{
    
register_plugin("Laser Beam""1.0""stupok")
    
    
register_forward(FM_PlayerPreThink"fw_playerprethink")
}

public 
plugin_precache()
{
    
sprite precache_model("sprites/laserbeam.spr");
}

public 
fw_playerprethink(id)
{
    
show_beam(id)
}

public 
show_beam(id)
{
    static 
Float:fStart[3], Float:fEnd[3];
    static 
tr;
    
    
pev(idpev_originfStart)
    
velocity_by_aim(id9999fEnd)
    
xs_vec_add(fStartfEndfEnd)
    
trace_line(idfStartfEndfEnd)
    
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_KILLBEAM)
    
write_short(id)
    
message_end()
    
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    
write_byte(1);
    
write_short(id 0x1000); // start entity
    
engfunc(EngFunc_WriteCoordfEnd[0])
    
engfunc(EngFunc_WriteCoordfEnd[1])
    
engfunc(EngFunc_WriteCoordfEnd[2])
    
write_short(sprite); // sprite index
    
write_byte(0); // starting frame
    
write_byte(0); // frame rate in 0.1's
    
write_byte(1); // life in 0.1's
    
write_byte(10); // line wdith in 0.1's
    
write_byte(0); // noise amplitude in 0.01's
    
write_byte(0); // red
    
write_byte(0); // green
    
write_byte(255); // blue
    
write_byte(255); // brightness
    
write_byte(255); // scroll speed in 0.1's
    
message_end();
    
    return 
PLUGIN_HANDLED;


Btw, I optimized it.

Alka 07-31-2010 18:42

Re: vector beam problem
 
I think PlayerPrethink it's kinda useless, a 0.1 task should be enough.

Swear 08-01-2010 04:19

Re: vector beam problem
 
Still the same bug with your code, meTaLiCroSS


edit: got it working, thank you all!


All times are GMT -4. The time now is 00:06.

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