AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   entity aim info using traceline (https://forums.alliedmods.net/showthread.php?t=280279)

Kowalsky 03-12-2016 15:21

entity aim info using traceline
 
Hey. So I have come across a problem that I don't know how to solve.

In order to set hud displaying some player's status I am using something like this :

Code:
        register_event( "StatusValue"   , "on_ShowStatus"       , "be"  , "1=2"     ,"2!0"                  );         register_event( "StatusValue"   , "on_HideStatus"       , "be"  , "1=1"     ,"2=0"                  ); public on_ShowStatus( )          // show hudmessage with information here public on_HideStatus( )          set_hudmessage( 0, 0, 0, 0.0, 0.0, 0, 0.0, 0.0, 0.0, 0.0, iChannel );          show_hudmessage( id, "" );

So as long as I am aiming at a player, the hud message will show up. When I move away my cursor, the hudmessage is instantly hidden because I catched the event on_HideStatus() and cleared my hud there.

How can I do the same thing with entities (using traceline?). I mean I can catch the moment when I am aiming at some entity and show the hudmessage, however this hudmessage will dissapear only after some time after I move my aim from the entity. Could you please help me with the algorytm or maybe provide some example code? An idea on how to catch the moment, when I stopped aiming at that particular entity would be nice!

E: I could also send the "clear hud" function to a client every time I see the conditions for my entity are not met, but that would be too inefficient (sending every 0.000...1s or so a message to clear HUD)

Chihuahuax 03-12-2016 19:15

Re: entity aim info using traceline
 
Use sync hud
Theres a function to remove sync hud easily

Kowalsky 03-12-2016 19:18

Re: entity aim info using traceline
 
Quote:

Originally Posted by Chihuahuax (Post 2401943)
Use sync hud
Theres a function to remove sync hud easily

I am not asking remove sync hud, I know how to do it. I am asking WHEN to do this in this forward. Since I don't have any particular event, when I am not aiming at entity

Bugsy 03-13-2016 00:03

Re: entity aim info using traceline
 
Look at this plugin: https://forums.alliedmods.net/showthread.php?t=277524

Kowalsky 03-13-2016 07:02

Re: entity aim info using traceline
 
Okay, thank you for your answers. I have decided I will do it in the following way :

Code:
new bool:bTrigger[ 33 ] FW_Traceline( ..., id ) {       //before it hits my entity       bTrigger[ id ] = false;       // It has hit my ent       bTrigger[ id ] = true;       if( !task_exists( SOME_TASK_ID+id ) )              set_task( params... ) // repeat this task every 0.1-0.4 secs, dunno which is the optimal value } public some_task( id ) {    if( !bTrigger[ id ] )       remove_task //otherwise show hud message }


All times are GMT -4. The time now is 09:18.

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