Raised This Month: $ Target: $400
 0% 

vector beam problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Swear
Junior Member
Join Date: May 2009
Location: Latvia
Old 07-31-2010 , 16:39   vector beam problem
Reply With Quote #1

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.
Swear is offline
Send a message via Skype™ to Swear
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 07-31-2010 , 16:48   Re: vector beam problem
Reply With Quote #2

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 =[
__________________
minimiller is offline
Send a message via MSN to minimiller
Swear
Junior Member
Join Date: May 2009
Location: Latvia
Old 07-31-2010 , 16:54   Re: vector beam problem
Reply With Quote #3

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 :/

Last edited by Swear; 07-31-2010 at 17:07.
Swear is offline
Send a message via Skype™ to Swear
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 07-31-2010 , 17:56   Re: vector beam problem
Reply With Quote #4

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.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross

Last edited by meTaLiCroSS; 07-31-2010 at 18:04.
meTaLiCroSS is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-31-2010 , 18:42   Re: vector beam problem
Reply With Quote #5

I think PlayerPrethink it's kinda useless, a 0.1 task should be enough.
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Swear
Junior Member
Join Date: May 2009
Location: Latvia
Old 08-01-2010 , 04:19   Re: vector beam problem
Reply With Quote #6

Still the same bug with your code, meTaLiCroSS


edit: got it working, thank you all!

Last edited by Swear; 08-01-2010 at 06:30.
Swear is offline
Send a message via Skype™ to Swear
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 00:06.


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