feature(server/vehicle) Add support for getting OxVehicle even when vehicle not tracked #213
+112
−48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#212
This PR introduces some changes regarding OxVehicle and how we can get an instance of it.
As of right now to get an instance of OxVehicle the vehicle must be spawned in by either using:
Ox.CreateVehicle
Ox.SpawnVehicle
Or by getting an instance of it after being spawned by using the
Ox.GetVehicle*
functions.However there are instances where we to create a vehicle entry and get the
OxVehicle
from it, E.G. a car shop showing a notification of the plate that was assigned to your new vehicle after purchase, but you don't want to spawn it immediately, this is current not possible as if you do not spawn it when creating the entry you will not get an instance of OxVehicle.Theres also instances where we'd want to get an instance of
OxVehicle
by using its vin, this is so we can call functions such assetOwner
etc for when a vehicle transfer happens. But this is only possible if the vehicle is being tracked by ox_core. Sure we could run an update query manually, but if we can do everything with classes, why not let ox_core handle it.This change will allow OxVehicle class to be created without the need of an Entity by making it an nullable field and an internal ID taking its place for the member lookups.
This will add support for being able to use
Ox.GetVehicleFromVin
which will first get the vehicle if its already being tracked, otherwise it will query the database for the vehicle and create & cache the OxVehicle created from it.Changes:
/dv
command not using 2 as default radius when not in vehicle.Ox.CreateVehicle
Not creating an entry in the DB when coords are not provided.Ox.CreateVehicle
Not returning an instance of OxVehicle when coords not provided.vehicle.respawn
Not working providing coords & rotation.internalId
for OxVehicle trackingOxVehicle.entity
is now nullable and not required.stored
to the output ofVehicleRow
If this PR is okay to be merged in I will work on updating the docs to reflect the changes.