@overextended/ox_core
Version:
A modern FiveM framework.
69 lines (68 loc) • 2.14 kB
JavaScript
class VehicleInterface {
entity;
netId;
script;
plate;
model;
make;
id;
vin;
owner;
group;
constructor(entity, netId, script, plate, model, make, id, vin, owner, group) {
this.entity = entity;
this.netId = netId;
this.script = script;
this.plate = plate;
this.model = model;
this.make = make;
this.id = id;
this.vin = vin;
this.owner = owner;
this.group = group;
this.entity = entity;
this.netId = netId;
this.script = script;
this.plate = plate;
this.model = model;
this.make = make;
this.id = id;
this.vin = vin;
this.owner = owner;
this.group = group;
}
getCoords() {
return GetEntityCoords(this.entity);
}
getState() {
return Entity(this.entity).state;
}
}
Object.keys(exports.ox_core.GetVehicleCalls()).forEach((method) => {
VehicleInterface.prototype[method] = function (...args) {
return exports.ox_core.CallVehicle(this.entity, method, ...args);
};
});
VehicleInterface.prototype.toString = function () {
return JSON.stringify(this, null, 2);
};
function CreateVehicleInstance(vehicle) {
if (!vehicle)
return;
return new VehicleInterface(vehicle.entity, vehicle.netId, vehicle.script, vehicle.plate, vehicle.model, vehicle.make, vehicle.id, vehicle.vin, vehicle.owner, vehicle.group);
}
export function GetVehicle(entityId) {
return CreateVehicleInstance(exports.ox_core.GetVehicle(entityId));
}
export function GetVehicleFromNetId(netId) {
return CreateVehicleInstance(exports.ox_core.GetVehicleFromNetId(netId));
}
export function GetVehicleFromVin(vin) {
return CreateVehicleInstance(exports.ox_core.GetVehicleFromVin(vin));
}
export async function CreateVehicle(data, coords, heading) {
return CreateVehicleInstance(await exports.ox_core.CreateVehicle(data, coords, heading));
}
export async function SpawnVehicle(dbId, coords, heading) {
return CreateVehicleInstance(await exports.ox_core.SpawnVehicle(dbId, coords, heading));
}