mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 01:08:57 +00:00
Vehicle server-spawning functions/callback
This commit is contained in:
@@ -167,6 +167,30 @@ function QBCore.Functions.GetEntitiesInBucket(bucket --[[ int ]])
|
||||
end
|
||||
end
|
||||
|
||||
-- Server side vehicle creation with optional callback
|
||||
-- the CreateVehicle RPC still uses the client for creation so players must be near
|
||||
function QBCore.Functions.SpawnVehicle(model, cb, coords, warp)
|
||||
model = type(model) == 'string' and GetHashKey(model) or model
|
||||
if not coords then coords = GetEntityCoords(GetPlayerPed(source)) 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 TaskWarpPedIntoVehicle(GetPlayerPed(source), veh, -1) end
|
||||
if cb then cb(veh) end
|
||||
end
|
||||
|
||||
-- Server side vehicle creation with optional callback
|
||||
-- the CreateAutomobile native is still experimental but doesn't use client for creation
|
||||
-- doesn't work for all vehicles!
|
||||
function QBCore.Functions.CreateVehicle(model, cb, 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
|
||||
if cb then cb(veh) end
|
||||
end
|
||||
|
||||
-- Paychecks (standalone - don't touch)
|
||||
|
||||
function PaycheckInterval()
|
||||
|
||||
Reference in New Issue
Block a user