Skip to content

feat(extra-natives-rdr3): add GET_ENTITIES_IN_RADIUS for RedM#3283

Merged
prikolium-cfx merged 1 commit intocitizenfx:masterfrom
Ktos93:redm-extra-native-get-entities
Apr 7, 2025
Merged

feat(extra-natives-rdr3): add GET_ENTITIES_IN_RADIUS for RedM#3283
prikolium-cfx merged 1 commit intocitizenfx:masterfrom
Ktos93:redm-extra-native-get-entities

Conversation

@Ktos93
Copy link
Contributor

@Ktos93 Ktos93 commented Mar 24, 2025

Goal of this PR

This PR introduces a new native function that retrieves entities within a specified radius using various parameters. It addresses several key issues:

  • Entity Set Limitations: Current entity sets are limited to 255 entries, and many servers fail to clear them, leading to pool overflows.

  • Single Object Limitation: The existing GET_CLOSEST_OBJECT_OF_TYPE function returns only one object and one model, which restricts its usability.

  • Performance Improvements: Although servers can achieve similar results using Lua with the GET_GAME_POOL native, running this function every frame with same logic takes approximately 0.45ms in Lua, whereas the new native performs the task in around 0.05ms. [Done just for test performance no one use this every frame]

The new native function provides a more flexible and efficient solution for managing and querying entities.

How is this PR achieving the goal

This PR registers a new native function, GET_ENTITIES_IN_RADIUS, which iterates through the appropriate entity pool to filter entities based on their distance from a given point and an optional list of model hashes, with an option to sort results by proximity. It then serializes and returns a list of entits, providing a more efficient and flexible alternative for entity querying.

This PR applies to the following area(s)

RedM

Successfully tested on

Game builds: 1491

Platforms: Windows, Linux

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

@github-actions github-actions bot added RedM Issues/PRs related to RedM triage Needs a preliminary assessment to determine the urgency and required action labels Mar 24, 2025
@github-actions github-actions bot added invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels Apr 4, 2025
@Ktos93
Copy link
Contributor Author

Ktos93 commented Apr 4, 2025

I cant squash this commits ... because i cant discard ros changes just fails

@prikolium-cfx
Copy link
Collaborator

prikolium-cfx commented Apr 4, 2025

I cant squash this commits ... because i cant discard ros changes just fails

No problem. Thank you for FXServer implementation too. I will squash in merge process

@Ktos93 Ktos93 force-pushed the redm-extra-native-get-entities branch 2 times, most recently from 3a19534 to bc5e281 Compare April 4, 2025 18:32
@github-actions github-actions bot added triage Needs a preliminary assessment to determine the urgency and required action and removed invalid Requires changes before it's considered valid and can be (re)triaged labels Apr 4, 2025
@Ktos93 Ktos93 force-pushed the redm-extra-native-get-entities branch from 9218b1d to 3b81aeb Compare April 4, 2025 18:35
@prikolium-cfx prikolium-cfx added ready-to-merge This PR is enqueued for merging and removed triage Needs a preliminary assessment to determine the urgency and required action labels Apr 7, 2025
@prikolium-cfx prikolium-cfx merged commit af8bcca into citizenfx:master Apr 7, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR is enqueued for merging RedM Issues/PRs related to RedM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants