Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: admincar command #59

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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