What is the best (most efficient) way to find entities within a certain position? Is it better to find all the entities of that specific class and then filter out the ones beyond the distance, or is it better to do a FindInSphere? The number of ents I’d be looking for of that class ranges from about 50 to 400 and I’d say at most they could be about 5000 units away while the distance I’d be constrained to looking for is 200units.
The reason I’m asking is because I do a check every second of these ents to see if I should give the player money if they are within a certain distance of the ents. So although it isn’t running every tick it still seems like a lot of work to do every second.
I was also wondering if someone knows a good place that talks about lua optimization and what gmod function are good and bad for efficiency. Right now I’m just having issues when there are over 26 people on the server and there are a lot of entities(props) on the map