diff --git a/server/events.lua b/server/events.lua index 1c64c55..7d6bd88 100644 --- a/server/events.lua +++ b/server/events.lua @@ -269,18 +269,7 @@ end) -- use the netid on the client with the NetworkGetEntityFromNetworkId native -- convert it to a vehicle via the NetToVeh native QBCore.Functions.CreateCallback('QBCore:Server:SpawnVehicle', function(source, cb, model, coords, warp) - local ped = GetPlayerPed(source) - model = type(model) == 'string' and joaat(model) or model - if not coords then coords = GetEntityCoords(ped) end - local veh = CreateVehicle(model, coords.x, coords.y, coords.z, coords.w, true, true) - while not DoesEntityExist(veh) do Wait(0) end - if warp then - while GetVehiclePedIsIn(ped) ~= veh do - Wait(0) - TaskWarpPedIntoVehicle(ped, veh, -1) - end - end - while NetworkGetEntityOwner(veh) ~= source do Wait(0) end + local veh = QBCore.Functions.SpawnVehicle(source, model, coords, warp) cb(NetworkGetNetworkIdFromEntity(veh)) end) @@ -289,12 +278,7 @@ end) -- use the netid on the client with the NetworkGetEntityFromNetworkId native -- convert it to a vehicle via the NetToVeh native QBCore.Functions.CreateCallback('QBCore:Server:CreateVehicle', function(source, cb, model, coords, warp) - model = type(model) == 'string' and GetHashKey(model) or model - if not coords then coords = GetEntityCoords(GetPlayerPed(source)) end - local CreateAutomobile = GetHashKey("CREATE_AUTOMOBILE") - local veh = Citizen.InvokeNative(CreateAutomobile, model, coords, coords.w, true, true) - while not DoesEntityExist(veh) do Wait(0) end - if warp then TaskWarpPedIntoVehicle(GetPlayerPed(source), veh, -1) end + local veh = QBCore.Functions.CreateAutomobile(source, model, coords, warp) cb(NetworkGetNetworkIdFromEntity(veh)) end)