Skip to content

fix(getNearbyPlayers): More reliable coord getter for players in vehicle#757

Merged
thelindat merged 6 commits into
overextended:mainfrom
tugamars:main
May 3, 2026
Merged

fix(getNearbyPlayers): More reliable coord getter for players in vehicle#757
thelindat merged 6 commits into
overextended:mainfrom
tugamars:main

Conversation

@tugamars

Copy link
Copy Markdown
Contributor

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.

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 unitysync left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)?

@tugamars

Copy link
Copy Markdown
Contributor Author

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:

  • If player is out of a vehicle it will obtain your coords correctly (GetEntityCoords)
  • If player is in a vehicle, it will return the vehicles coords for that player - which may differ from the actual player location in the world

This is not really "too bad" with small vehicles because the offset from the actual player location to the vehicle center is small.
But for large vehicles (like the ones you mentioned) this will cause issues.

New logic with the update:

  • Inaltered for players outside of vehicle
  • For players in a vehicle it will obtain the Peds absolute bone location in the World

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

@tugamars tugamars requested a review from unitysync May 1, 2026 10:50
Comment thread imports/getClosestPlayer/client.lua Outdated
tugamars added 3 commits May 2, 2026 14:02
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>
@thelindat thelindat merged commit 8453521 into overextended:main May 3, 2026
@Legacy-TacticalGamingInteractive

Copy link
Copy Markdown

Excellent ty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants