+
Skip to content

Conversation

andreutu
Copy link

@andreutu andreutu commented May 9, 2025

This PR aims to fix an oversight that mostly affects TypeScript users. Currently, the only way to get a vehicle using its entity ID in TypeScript is through GetVehicle. However, that function uses an export that does not exist, at least not anymore.
In lua, users are able to use the function Ox.GetVehicleFromEntity, which works as it should. In TS, there is no function under that name.

This PR aims to fix this problem by adding the GetVehicleFromEntity function to TypeScript and using the correct exports in GetVehicle functions, which are only kept because, if they were removed, it would break a lot of scripts no matter the environment.

I am however going to need a say from maintainers on whether if it is a good idea to keep the GetVehicle function or remove the GetVehicleFromEntity function and keep the first one.

Fixes #5.

@antond15
Copy link
Member

antond15 commented May 9, 2025

Thanks for the PR. The addition of GetVehicleFromEntity to TS is great.

However your change to GetVehicle is breaking.
GetVehicle should either take vin — or both vin and entityId and use the proper getter based on parameter type (string|number respectively).

OxVehicle can exist without being spawned - not having entityId assigned, therefore the default Get call should use vin.

@andreutu
Copy link
Author

andreutu commented May 9, 2025

Okay, think I got it. I'll implement these changes now.

@andreutu
Copy link
Author

andreutu commented May 9, 2025

Should be good to go 👍🏻

FjamZoo
FjamZoo previously approved these changes May 9, 2025
@FjamZoo
Copy link

FjamZoo commented May 11, 2025

will wait for @antond15 to double check before merging

@andreutu
Copy link
Author

All done :) Thank you for spotting these!

Copy link
Member

@antond15 antond15 left a comment

Choose a reason for hiding this comment

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

LGTM

@antond15 antond15 requested a review from FjamZoo May 13, 2025 20:06
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.

GetVehicle does not return a OxVehicle.

3 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载