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

entity aim info using traceline


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kowalsky
Senior Member
Join Date: Mar 2015
Location: Poland
Old 03-12-2016 , 15:21   entity aim info using traceline
Reply With Quote #1

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)

Last edited by Kowalsky; 03-12-2016 at 15:25.
Kowalsky is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 03-12-2016 , 19:15   Re: entity aim info using traceline
Reply With Quote #2

Use sync hud
Theres a function to remove sync hud easily
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
Kowalsky
Senior Member
Join Date: Mar 2015
Location: Poland
Old 03-12-2016 , 19:18   Re: entity aim info using traceline
Reply With Quote #3

Quote:
Originally Posted by Chihuahuax View Post
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
Kowalsky is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-13-2016 , 00:03   Re: entity aim info using traceline
Reply With Quote #4

Look at this plugin: https://forums.alliedmods.net/showthread.php?t=277524
__________________
Bugsy is offline
Kowalsky
Senior Member
Join Date: Mar 2015
Location: Poland
Old 03-13-2016 , 07:02   Re: entity aim info using traceline
Reply With Quote #5

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 }

Last edited by Kowalsky; 03-13-2016 at 07:02.
Kowalsky is offline
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 16:42.


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