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

How to detect if a button is in range


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sekac
Senior Member
Join Date: Nov 2016
Old 12-30-2019 , 10:52   How to detect if a button is in range
Reply With Quote #1

How do I know if a player can press a button (he is close enough) to use it?
sekac is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-30-2019 , 14:08   Re: How to detect if a button is in range
Reply With Quote #2

Loop all "func_button" entities in a X radius around the player using the "find_sphere_class" function.
You can find the X by doing a simple test - adding a chat message when you press a button that prints out the distance between the player and the button entity.

Or I guess you can look in the game's code to find the 100% accurate distance.

//Edit: I believe the radius is 64 according to this:

Code:
// // PlayerUse - handles USE keypress // #define PLAYER_SEARCH_RADIUS (float)64
__________________

Last edited by OciXCrom; 12-30-2019 at 15:20.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 20:16.


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