Enemy distance in M
Man, i was searching for the distance between me and the enemy but i dont found a good format.
Appearing in hud the player closer and its distance in meters. Like this: Enemy: EFFx - 17 meters I looked more wdo I thought were definitive codes for X distance, and I want to sample the distance from the closer, and I did not find it. Can you guys help me? |
Re: Enemy distance in M
Quote:
PHP Code:
|
Re: Enemy distance in M
1 Attachment(s)
What i made:
PHP Code:
|
Re: Enemy distance in M
%d -> %.0f
The number decides hos many decimals. |
Re: Enemy distance in M
2 Attachment(s)
Yes, your format made the plugin running successfly.
But this format is to all enemy, i want only one ( the closest ) Because when i'm by side the enemy, the distance is 56 meters/9 meters, wtf? Here's the screenshot: The first is when i'm alone, just me on the server. The second photo is when i'm by side the enemy. |
Re: Enemy distance in M
Quote:
Edit: If you want to get the closet player near you, then you should use find_ent_in_sphere or find_ent_class. Then use the code I gave you. |
Re: Enemy distance in M
And how will be? Can you make aa example?
|
Re: Enemy distance in M
There's no way around it. Loop through all enemies and compare the distance. Save the one with the lowest value.
find_ent_in_sphere will not give you the result you are looking for. |
Re: Enemy distance in M
hhaa, you are creating variable enemy and after that you use pev origin. You basically are getting server origin because it has ID 0. You shall loop all players, I will come with a loop soon:
Try : PHP Code:
And also i suggest you to set task on player spawn and remove it on death or disconnect, it will be more efficient because in your way task is running on dead player , disconnected player, on ct,spectate and or player.. It's not effiecient.... Like this one, it's more better (but uses hamsandwich module for player spawn hook): PHP Code:
|
Re: Enemy distance in M
1 Attachment(s)
The results from your codes:
|
| All times are GMT -4. The time now is 18:42. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.