distance between players
Hello, I wanted to know if there is a way to obtain the distance between players, I am doing it this way, but since it is done repeatedly, it does not seem very light to me to call the engine twice each time it is executed, is there another way?
PHP Code:
PHP Code:
|
Re: distance between players
If you are interested, here's this native you've used inside engine.cpp:
Code:
static cell AMX_NATIVE_CALL entity_range(AMX *amx, cell *params) |
Re: distance between players
Quote:
|
Re: distance between players
Huh? EFFx confirmed that you found the correct function to solve your problem.
|
Re: distance between players
Quote:
|
Re: distance between players
There's a lot of informations about how natives looks like inside github. The engine.cpp is the one that you should search about.
Code:
static cell AMX_NATIVE_CALL entity_get_vector(AMX *amx, cell *params)The get_distance_f() is provided by vector.cpp Code:
static cell AMX_NATIVE_CALL get_distance_f(AMX *amx, cell *params)- The idea is to make the code the shortest possible, so it is easy to edit, fix or read. Keep in mind that entity_get_vector() wasn't meant just for origin information, as you can see in the code inside engine.cpp. So if your goal was only to get the distance and nothing else, using entity_range() is way faster. Different natives for different purposes. |
Re: distance between players
Quote:
|
Re: distance between players
What makes you say that? Why would I write a large code to do something easy, if I can use a smaller one which is faster and easy to understand, but with the same end goal?
|
Re: distance between players
Quote:
|
Re: distance between players
Quote:
Similarly, the length of code, generally, has no direct correlation to any performance metric (execution speed or memory). Also similarly, you can make "short" code that is inefficient. I made the reply to your post because many new coders get it in their head that "shorter code is better" when they need to, instead, be thinking about how to write coded that is efficient and easy to read/edit. |
| All times are GMT -4. The time now is 15:34. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.