AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to detect if a button is in range (https://forums.alliedmods.net/showthread.php?t=320604)

sekac 12-30-2019 10:52

How to detect if a button is in range
 
How do I know if a player can press a button (he is close enough) to use it?

OciXCrom 12-30-2019 14:08

Re: How to detect if a button is in range
 
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


All times are GMT -4. The time now is 17:44.

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