Raised This Month: $12 Target: $400
 3% 

Solved Directions to Entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iNvectus
Member
Join Date: Sep 2014
Location: Bulgaria
Old 03-13-2019 , 04:13   Directions to Entity
Reply With Quote #1

Greetings. I want to ask for any ideas how I can create something like a beam that gives directions towards an entity.

Example: I have menu with 5 zones on dust2, I press 2. B Site and it writes a beam towards the B site info zone origin. I don't care if it goes through walls or not. I can create the bounding box myself.

How can I create such directions? If unclear, you may say so. I will do my best to re-describe.

Last edited by iNvectus; 03-14-2019 at 05:43.
iNvectus is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 03-13-2019 , 09:26   Re: Directions to Entity
Reply With Quote #2

If you have two ents send TE_BEAMENTS message. If not, send TE_BEAMPOINTS (beam between two points) or TE_BEAMENTPOINT (between a point and an entity (player)).

https://www.amxmodx.org/api/messages/message_begin
https://www.amxmodx.org/api/message_const
__________________
My English is A0
E1_531G is offline
iNvectus
Member
Join Date: Sep 2014
Location: Bulgaria
Old 03-14-2019 , 03:43   Re: Directions to Entity
Reply With Quote #3

Fixed. Here is a snippet.
PHP Code:
#include <amxmodx>
#include <engine>

// #define DEBUG_
// #define _THINK
#define _FASTVIS

const TASK_POINT 1337;

#if defined DEBUG_

#if !defined _THINK
    
public plugin_init()
    
register_clcmd("radio2""test");
    public 
test(id)
    
#else
    
public client_PostThink(id)
    
#endif
    
{
        static 
fOriginE[3], fOriginS[3];
        
get_user_origin(idfOriginS);            // Start point
        
get_user_origin(idfOriginE, .mode 3);    // End point
 
        
test_vector(
            .
vStart fOriginS,
            .
vEnd fOriginE,
            .
time 0.1,
            .
width 10
        
);
 
        
// return PLUGIN_HANDLED;
    
}
#endif    // DEBUG_

new g_pBeamSprite;
new const 
SPRITE_BEAM[] = "sprites/arrow1.spr";
new const 
SPRITE_POINT[] = "sprites/3dmflared.spr";

public 
plugin_precache()
{
    
g_pBeamSprite precache_model(SPRITE_BEAM);
    
precache_model(SPRITE_POINT);
}

public 
test_vector(start[3], end[3], Floattimewidth)
{
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(TE_BEAMPOINTS);
    
write_coord(end[0]);
    
write_coord(end[1]);
    
write_coord(end[2]);
    
write_coord(start[0]);
    
write_coord(start[1]);
    
write_coord(start[2]);
    
write_short(g_pBeamSprite);
    
write_byte(1);            //Start Point
    
write_byte(1);            //Anim speed
    
write_byte(floatround(time 10));    //Time to show
    
write_byte(width);        //Width
    
write_byte(0);            //Distortion
    
write_byte(255);            //Red
    
write_byte(0);            //Green
    
write_byte(0);            //Blue
    
write_byte(1000);        //Brightness
    
write_byte(10);
    
message_end();

#if !defined _FASTVIS
    
CreatePoint(start, .time time);
    
CreatePoint(end, .time time);
#else
    // Create_Sparks(start);
    
Create_Sparks(end);
#endif
}

stock CreatePoint(vecOrigin[3], Floattime)
{
    static 
pEntFloatfOrigin[3];
    
pEnt create_entity("info_target");
    
IVecFVec(vecOriginfOrigin);

    if(
is_valid_ent(pEnt))
    {
        
// entity_set_string(pEnt, EV_SZ_classname, "points");
        
entity_set_model(pEntSPRITE_POINT);
        
entity_set_origin(pEntfOrigin);
        
entity_set_int(pEntEV_INT_solidSOLID_NOT);
        
entity_set_int(pEntEV_INT_movetypeMOVETYPE_NONE);
        
entity_set_float(pEntEV_FL_scale0.1);
        
entity_set_float(pEntEV_FL_nextthinkget_gametime());
        
entity_set_int(pEntEV_INT_rendermodekRenderTransAdd);
        
entity_set_float(pEntEV_FL_renderamt100.0);
    
        
set_task(time"DeleteEnt"TASK_POINT pEnt);
    }
}

stock Create_Sparks(vecOrigin[3])
{
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(TE_SPARKS);
    
write_coord(vecOrigin[0]);
    
write_coord(vecOrigin[1]);
    
write_coord(vecOrigin[2]);
    
message_end();
}


public 
DeleteEnt(pEnt)
{
    
pEnt -= TASK_POINT;
    if(
is_valid_ent(pEnt))
        
remove_entity(pEnt);


Last edited by iNvectus; 03-14-2019 at 03:47.
iNvectus is offline
Reply


Thread Tools
Display Modes

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 05:52.


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