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

find_ent_in_sphere vs get_players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kowalsky
Senior Member
Join Date: Mar 2015
Location: Poland
Old 03-20-2016 , 18:47   find_ent_in_sphere vs get_players
Reply With Quote #1

Which is the most optimal way to find a player within a certain radius. I saw that in many plugins a loop through all players is being executed and check for entity_range (get_distance). However in my opinion it would be way more efficient to use find_ent_in_sphere (of course the fakemeta way) for such a case. Is it the truth?
Kowalsky is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-21-2016 , 06:02   Re: find_ent_in_sphere vs get_players
Reply With Quote #2

Yeah, I would say that's better too. Probably something like:
PHP Code:
while((iEnt find_ent_in_sphere(iEntfOriginfRadius)) > && iEnt <= MaxClients) {
    
// Do stuff to them

that will limit the search to only players. MaxClients is equal to get_maxplayers(), and you should use that global variable if you are using 1.8.3.
klippy is offline
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 03-21-2016 , 18:59   Re: find_ent_in_sphere vs get_players
Reply With Quote #3

Difference between them should be trival. Note that with origin version you can choose on Z axis to check a different point than the ent/player origin such as the feet origin or whatever Z origin +- X.

Last edited by Fr33m@n; 03-21-2016 at 19:16.
Fr33m@n 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 03:50.


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