This pull request optimizes utility functions for finding the closest entities (players, objects, vehicles, and peds) to a source player or specified coordinates within the QBCore framework. The key changes include:
Refactoring and Consolidation: The core logic for finding the closest entity has been consolidated into a single GetClosestEntity function, reducing code duplication and improving maintainability.
Improved Coordinate Handling: The handling of coordinates has been standardized, accepting either a vector3 or a table format, and defaulting to the source player's current position if none are provided.
Optimized Distance Calculation: The distance calculation has been optimized by ensuring the coordinates and entity checks are consistent and efficient.
These changes enhance the overall performance and readability of the code, while preserving existing functionality.
Checklist
[x] I have personally loaded this code into an updated qbcore project and checked all of its functionality.
Description
This pull request optimizes utility functions for finding the closest entities (players, objects, vehicles, and peds) to a source player or specified coordinates within the QBCore framework. The key changes include:
These changes enhance the overall performance and readability of the code, while preserving existing functionality.
Checklist