Skip to content

Commit

Permalink
fix: admincar command (Qbox-project#59)
Browse files Browse the repository at this point in the history
* fix: admincar command

* fix linting
  • Loading branch information
Manason authored Jun 14, 2024
1 parent 5ed2795 commit 0ed7b28
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions server/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 existingVehicleId = Entity(vehicle).state.vehicleid
if existingVehicleId 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(existingVehicleId, 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)
Expand Down

0 comments on commit 0ed7b28

Please sign in to comment.