Skip to content

feat(es_extended): Optimize Tracking Of Ped Coords#1651

Merged
Kenshiin13 merged 8 commits into
esx-framework:devfrom
Meyndflay:feature
Jul 6, 2025
Merged

feat(es_extended): Optimize Tracking Of Ped Coords#1651
Kenshiin13 merged 8 commits into
esx-framework:devfrom
Meyndflay:feature

Conversation

@Meyndflay

@Meyndflay Meyndflay commented Jun 9, 2025

Copy link
Copy Markdown

Description

Optimizes the tracking of ped coords from ESX.PlayerData.coords

Motivation

Updating the ESX.PlayerData.coords via a while loop adds CPU msec overhead, that's why we aim to optimize its tracking.

Implementation Details

Since the main function of ESX.PlayerData.coords is to return the coords of the player's ped, we can use Lua's metatables to alter the function of ESX.PlayerData.coords.

Usage Example

-- Old version
print(ESX.PlayerData.coords) -- This returns the coords of the player's ped as the .coords key is updated every interval. (Not efficient)

-- New version
print(ESX.PlayerData.coords) -- Still returns the coords of the player's ped but makes use of metamethods to get the ped's coords. (More efficient and only called as needed)

PR Checklist

  • My commit messages and PR title follow the Conventional Commits standard.
  • My changes have been tested locally and function as expected.
  • My PR does not introduce any breaking changes.
  • I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.

@github-project-automation github-project-automation Bot moved this to 🆕 To be Discussed in ESX Roadmap Jun 9, 2025
@Kenshiin13 Kenshiin13 changed the base branch from main to dev June 9, 2025 11:52
@Meyndflay Meyndflay force-pushed the feature branch 2 times, most recently from 358b923 to c10097d Compare June 9, 2025 13:11
@Kenshiin13

Copy link
Copy Markdown
Contributor

@Meyndflay This won't work for importing resources. The metatable approach is solid and something I was planning to do myself, but you should do it in the imports.lua as well.

@Kenshiin13 Kenshiin13 self-assigned this Jun 11, 2025
@Meyndflay

Copy link
Copy Markdown
Author

@Kenshiin13 Good catch! I added it to the imports.lua now.

@Zykem Zykem 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.

LGTM, Thanks

@github-project-automation github-project-automation Bot moved this from 🆕 To be Discussed to Ready for Next Update in ESX Roadmap Jul 6, 2025
@Kenshiin13 Kenshiin13 merged commit aced015 into esx-framework:dev Jul 6, 2025
1 check passed
@Meyndflay Meyndflay deleted the feature branch July 7, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for Next Update

Development

Successfully merging this pull request may close these issues.

4 participants