Raised This Month: $ Target: $400
 0% 

[SOLVED?]Laser Beam - How to block it when it hits an object or entity?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
stupok
Veteran Member
Join Date: Feb 2006
Old 12-23-2008 , 07:14   Re: Laser Beam - How to block it when it hits an object or entity?
Reply With Quote #4

Out of curiosity, I made a plugin to see how snappy the "laser pointer" would be.

In conclusion, it can't be made snappy enough. It'll always have some "lag", not really usable. You might want to try the metamod plugin that does the same thing, but I doubt that it'll be much quicker.

I included some extra code, feel free to ask questions:

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 server_frame()
{
    for(new i = 1; i < 33; i++)
    {
        if(is_user_alive(i))
        {
            show_beam2(i)
        }
    }
}
*/

/*
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(idpev_originfStart)
    
    
pev(idpev_v_anglefEnd)
    
engfunc(EngFunc_MakeVectorsfEnd)
    
global_get(glb_v_forwardfEnd)
    
xs_vec_mul_scalar(fEnd9999.0fEnd)
    
xs_vec_add(fStartfEndfEnd)
    
    
tr create_tr2()
    
engfunc(EngFunc_TraceLinefStartfEndDONT_IGNORE_MONSTERSidtr)
    
get_tr2(trTR_vecEndPosfEnd)
    
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(TE_BEAMENTPOINT);
    
write_short(id 0x1000); // start entity
    
engfunc(EngFunc_WriteCoordfEnd[0])
    
engfunc(EngFunc_WriteCoordfEnd[1])
    
engfunc(EngFunc_WriteCoordfEnd[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;

__________________
stupok is offline
 



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 09:19.


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