Target player closes to crosshair
How would I get the player closes to your crosshair? i.e. in the following picture it would be the guy on the right. I need it for a rocket launcher plugin I'm making.
http://img.kult-mag.com/photos/00/00...00011560_2.jpg |
One method, although probably not quite what you want, is you could use get_origin with the parameter that gets the bullet hit point (I can't remember the number) and store it. Then loop through all players and get their origins. Then use some kind of bubble sort method to figure out which one is closest. However, this would get player closest to what the crosshair is aiming at (ie: the wall at the end of the map) as opposed to the position of the crosshair on the user's screen.
I don't know if it will work, I'm not sure what you plan to do. |
Float: get_user_aiming ( index, &id, &body, [ distance ] )
This gets what the player is aiming at. If they are aiming at an entity or a player, it returns the id of the ent into "id". so, for example: Code:
Sorry there are no indents. Anyway, you just have to check to see if the entity thats returned is a living player, and then you have the player inside id's crosshairs ^^ |
Actually I figured something like this:
Get the distance of all the players in my view to me, however only the x,y coordinates |
Thats a little excessive. get_user_aiming will get whomeever your directly looking at. I suppose you could get the angles and find out who is in your view point, but thats REALLY excessive.
|
Suzuka, read the question over again. He wants to find the player closest to his crosshair, not the player directly in his crosshair.
|
Edit: NM this code anymore.
|
Code:
gets the origins in front of you. But I dont know how to use this to get people. |
I changed "get_user_origin(id,aimvec,3)" to "get_user_origin(id,aimvec,1)".
Code:
|
gj id hope to learn something from you...
still a n00b scripter with dreams bigger than my current skills allow :) |
| All times are GMT -4. The time now is 09:58. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.