Raised This Month: $32 Target: $400
 8% 

Find players near given origin?>


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AwesomeMan
Member
Join Date: Jun 2013
Old 08-18-2013 , 09:36   Find players near given origin?>
Reply With Quote #1

Hey, I'm just wondering How would I find players (i dont need index, just amount is enough) within given origin. Basically, let's say the origin is 0.0.0 and I want to find if there is any players within 500m near the origin. So, if the origin is 0.0.0 but a player is at 499.0.0 it would detect him, but if he would be at 501.0.0 it wouldnt. How can i do that?
AwesomeMan is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-18-2013 , 09:51   Re: Find players near given origin?>
Reply With Quote #2

Well, there is several ways.

- Using one native :

new playersList[32];
new playersCount = find_sphere_class( 0, "player", RADIUS, playersList, sizeof playersList, ORIGIN );

- Possible to loop with find_ent_in_sphere() and counting.
-There is also looping among all players and checking each origin distance.

The first is probably the most efficient.
__________________

Last edited by Arkshine; 08-18-2013 at 09:51.
Arkshine is offline
AwesomeMan
Member
Join Date: Jun 2013
Old 08-18-2013 , 10:07   Re: Find players near given origin?>
Reply With Quote #3

Thank you Arkshine
I will try it, if I get any problems I will reply back
Cheers!
AwesomeMan is offline
AwesomeMan
Member
Join Date: Jun 2013
Old 08-18-2013 , 11:00   Re: Find players near given origin?>
Reply With Quote #4

new playersCount = find_sphere_class( 0, "player", 500.0, playersList, sizeof playersList, origin );

It gives me tag mismatch error when compiling.
AwesomeMan is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-18-2013 , 11:17   Re: Find players near given origin?>
Reply With Quote #5

what is "origin" ? It should be a Float.
__________________
Arkshine is offline
AwesomeMan
Member
Join Date: Jun 2013
Old 08-18-2013 , 11:23   Re: Find players near given origin?>
Reply With Quote #6

It location that is read from file.
set_user_origin(id, origin)
works.

origin[0] = str_to_num(a)
origin[1] = str_to_num(b)
origin[2] = str_to_num(c)

this is what i use to get the origin

How can I transform the origin[0/1/2] to a float?

Last edited by AwesomeMan; 08-18-2013 at 11:25.
AwesomeMan is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-18-2013 , 11:47   Re: Find players near given origin?>
Reply With Quote #7

Make origin a float.

new Float:origin[3];

and use str_to_float(a) etc.
__________________

Last edited by Arkshine; 08-18-2013 at 11:47.
Arkshine is offline
AwesomeMan
Member
Join Date: Jun 2013
Old 08-18-2013 , 12:02   Re: Find players near given origin?>
Reply With Quote #8

new float:porigin[3];
porigin[0] = str_to_float(a);
porigin[1] = str_to_float(b);
porigin[2] = str_to_float(c);

It gives me tag mismatch error on porigin[*] = str_to_float(*);
For each one. What am I doing wrong here, can't seem to figure out
AwesomeMan is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-18-2013 , 12:03   Re: Find players near given origin?>
Reply With Quote #9

Float: not float:

Case is sensitive.
__________________
Arkshine is offline
AwesomeMan
Member
Join Date: Jun 2013
Old 08-18-2013 , 12:10   Re: Find players near given origin?>
Reply With Quote #10

That fix the issue. Thank you very much!
AwesomeMan 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 01:08.


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