diff --git a/server/functions.lua b/server/functions.lua index cca2f8e..cc69279 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -169,26 +169,26 @@ 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) +function QBCore.Functions.SpawnVehicle(source, model, 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 + return veh 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) +function QBCore.Functions.CreateVehicle(source, 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 - if cb then cb(veh) end + return veh end -- Paychecks (standalone - don't touch)