Raised This Month: $ Target: $400
 0% 

Distanse


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 03-09-2013 , 05:27   Distanse
Reply With Quote #1

How can i get distanse between players? E.g. i want all players in range 250 of me to write in chat Hello. i'm close to you. How can i getall players in a certain distanse from me?
Podarok is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 03-09-2013 , 05:51   Re: Distanse
Reply With Quote #2

find_ent_in_sphere
SpeeDeeR is offline
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 03-09-2013 , 06:00   Re: Distanse
Reply With Quote #3

Thanks a lot. Any example of using it to find players? And do smth with them after we find them? Please
Podarok is offline
Infernuz
Member
Join Date: May 2011
Old 03-09-2013 , 06:28   Re: Distanse
Reply With Quote #4

Find first players origins, and second one. Create a straight line betwen them and calculate the length of that line. There you go, distance.
Infernuz is offline
Send a message via ICQ to Infernuz
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 03-09-2013 , 06:44   Re: Distanse
Reply With Quote #5

Why do i have to create a straight line? I just want to find all players in lets say 250.0 radius and make some function on them e.g. wadress a message to them
Podarok is offline
Infernuz
Member
Join Date: May 2011
Old 03-09-2013 , 07:01   Re: Distanse
Reply With Quote #6

To find the distance betwen one player. You'll have later on loop throw other ones and make a check if they are in range.

This is just my idea of how it can be done, there'r of course other ways.
Infernuz is offline
Send a message via ICQ to Infernuz
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 03-09-2013 , 07:01   Re: Distanse
Reply With Quote #7

Code:
new iPlayer // origin of the entity to look around, player in your case new Float: vecEntityOrigin[ 3 ] entity_get_vector( iEntity, EV_VEC_origin, vecEntityOrigin ) while( ( iPlayer = find_ent_in_sphere( iPlayer, vecEntityOrigin, 250.0 ) ) ) {     if( is_user_alive( iPlayer ) )     {         client_print( iPlayer, print_chat, "Hello" )     } }
Backstabnoob is offline
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 03-09-2013 , 07:44   Re: Distanse
Reply With Quote #8

Can i use instead of iEntity players id, because i have to calculate distance between players.?
Podarok is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 03-09-2013 , 08:00   Re: Distanse
Reply With Quote #9

Yes, that's what you have to do (reason for my comment above it)
Backstabnoob is offline
Podarok
BANNED
Join Date: Jan 2011
Location: Narnia
Old 03-10-2013 , 05:53   Re: Distanse
Reply With Quote #10

Thanks but it does not work. It writes me this : "Hello muthahacka lol!" but not people around me.
Here is my code
Code:
public myfunction( id ) {     new iEnemy         // origin of the entity to look around, player in your case     new Float: vecOrigin[ 3 ]     entity_get_vector( id, EV_VEC_origin, vecOrigin )         while( ( iEnemy = find_ent_in_sphere( id, vecOrigin, 250.0 ) ) && iEnemy != id )     {         if( is_user_alive( iEnemy ) )         {                        client_print( iEnemy, print_chat, "Hello muthahacka lol!" );         }     } }

Last edited by Podarok; 03-10-2013 at 07:50.
Podarok 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 21:41.


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