CSGO: Distance between two players
Posted: Tue Oct 13, 2015 3:16 pm
by Kami
Hey guys, I'm currently trying to find a way to get the distance between two players. I could propably do it via some vector math, but maybe there is already something in the modules?
Thank you

Posted: Tue Oct 13, 2015 3:31 pm
by satoon101
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/src/core/modules/mathlib/mathlib_wrap.cpp#L177
That will return in "game units", so you will have to adjust it to get the feet/meters (or whatever type of distance you are looking for).
Posted: Tue Oct 13, 2015 3:55 pm
by Kami
Thank you very much!
I'm afraid I am more than rusty with all of this so could you please tell me if this is the right use:
Syntax: Select all
from mathlib import Vector
import players
player_orig = players.get_abs_origin(player_index)
other_orig = players.get_abs_origin(other_index)
distance = player_orig.Vector.get_distance(other_orig)
Posted: Tue Oct 13, 2015 3:58 pm
by satoon101
Syntax: Select all
from players.entity import PlayerEntity
first_player = PlayerEntity(player_index)
second_player = PlayerEntity(other_index)
distance = first_player.origin.get_distance(second_player.origin)
Posted: Tue Oct 13, 2015 4:05 pm
by Kami
Awesome, thank you!