From 5c862d60684e10f91d903500c67151bd7cf3488c Mon Sep 17 00:00:00 2001 From: Manason Date: Fri, 14 Jun 2024 08:38:32 -0700 Subject: [PATCH] fix: admincar command --- server/commands.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/commands.lua b/server/commands.lua index 727a275..cdbb89b 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -54,23 +54,23 @@ lib.addCommand('admincar', { local playerData = exports.qbx_core:GetPlayer(source).PlayerData local vehName, props = lib.callback.await('qbx_admin:client:GetVehicleInfo', source) - if exports.qbx_vehicles:DoesEntityPlateExist(props.plate) then + local vehicleId = Entity(vehicle).state.vehicleid + if vehicleId then local response = lib.callback.await('qbx_admin:client:SaveCarDialog', source) if not response then return exports.qbx_core:Notify(source, 'Canceled.', 'inform') end - exports.qbx_vehicles:SetVehicleEntityOwner({ - citizenId = playerData.citizenid, - plate = props.plate - }) + local success, err = exports.qbx_vehicles:SetPlayerVehicleOwner(vehicleId, playerData.citizenid) + if not success then error(err) end else - exports.qbx_vehicles:CreateVehicleEntity({ - citizenId = playerData.citizenid, + local vehicleId, err = exports.qbx_vehicles:CreatePlayerVehicle({ model = vehName, - mods = props, - plate = props.plate + citizenId = playerData.citizenid, + props = props, }) + if err then error(err) end + Entity(vehicle).state:set('vehicleid', vehicleId, true) end exports.qbx_core:Notify(source, 'This vehicle is now yours.', 'success') end)