fix(getNearbyPlayers): More reliable coord getter for players in vehicle#757
Conversation
Signed-off-by: Marcelo Silva <25794492+tugamars@users.noreply.github.com>
Signed-off-by: Marcelo Silva <25794492+tugamars@users.noreply.github.com>
Signed-off-by: Marcelo Silva <25794492+tugamars@users.noreply.github.com>
unitysync
left a comment
There was a problem hiding this comment.
I sense this could possibly cause issues with large vehicles like trucks, since you could technically be far away from the chassis bone at the centre of the vehicle. Are you able to test your changes with a scenario like that with a few different large vehicles (bus, phantom, dump)?
That is precisely what this aims to solve. Currently (before update) the logic goes like this:
This is not really "too bad" with small vehicles because the offset from the actual player location to the vehicle center is small. New logic with the update:
So on small vehicles it will be a more accurate position (and therefor distance from the client that calculated it) and in big vehicles where it previously would return no one was nearby (due to being far from center of vehicle) it will return an accurate reading. This was tested with the bus and the limo vehicles |
Signed-off-by: Marcelo Silva <25794492+tugamars@users.noreply.github.com>
Modified the getClosestPlayer function to return the closest vehicle along with player ID, ped, and coordinates. Signed-off-by: Marcelo Silva <25794492+tugamars@users.noreply.github.com>
Update player coordinates retrieval to account for vehicle presence. Signed-off-by: Marcelo Silva <25794492+tugamars@users.noreply.github.com>
|
Excellent ty |
When a player is inside a vehicle GetEntityCoords returns the center of the vehicle, which is not necessarily the players coords in the world.
This PR improves the reliability of getNearbyPlayers by using the actual position of the player in the world.