Untitled diff

Created Diff never expires
1 removal
49 lines
2 additions
50 lines
RegisterNetEvent('esx_jobs:spawnJobVehicle')
RegisterNetEvent('esx_jobs:spawnJobVehicle')
AddEventHandler('esx_jobs:spawnJobVehicle', function(spawnPoint, vehicle)
AddEventHandler('esx_jobs:spawnJobVehicle', function(spawnPoint, vehicle)
local playerPed = GetPlayerPed(-1)
local playerPed = GetPlayerPed(-1)
local coords = spawnPoint.Pos
local coords = spawnPoint.Pos
local vehicleModel = GetHashKey(vehicle.Hash)
local vehicleModel = GetHashKey(vehicle.Hash)


RequestModel(vehicleModel)
RequestModel(vehicleModel)
while not HasModelLoaded(vehicleModel) do
while not HasModelLoaded(vehicleModel) do
Citizen.Wait(0)
Citizen.Wait(0)
end
end


if not IsAnyVehicleNearPoint(coords.x, coords.y, coords.z, 5.0) then
if not IsAnyVehicleNearPoint(coords.x, coords.y, coords.z, 5.0) then
local veh = CreateVehicle(vehicleModel, coords.x, coords.y, coords.z, spawnPoint.Heading, true, false)
local veh = CreateVehicle(vehicleModel, coords.x, coords.y, coords.z, spawnPoint.Heading, true, false)


if vehicle.Trailer ~= "none" then
if vehicle.Trailer ~= "none" then
RequestModel(vehicle.Trailer)
RequestModel(vehicle.Trailer)


while not HasModelLoaded(vehicle.Trailer) do
while not HasModelLoaded(vehicle.Trailer) do
Citizen.Wait(0)
Citizen.Wait(0)
end
end


local trailer = CreateVehicle(vehicle.Trailer, coords.x, coords.y, coords.z, spawnPoint.Heading, true, false)
local trailer = CreateVehicle(vehicle.Trailer, coords.x, coords.y, coords.z, spawnPoint.Heading, true, false)
AttachVehicleToTrailer(veh, trailer, 1.1)
AttachVehicleToTrailer(veh, trailer, 1.1)
end
end


SetVehicleHasBeenOwnedByPlayer(veh, true)
SetVehicleHasBeenOwnedByPlayer(veh, true)
SetEntityAsMissionEntity(veh, true, true)
SetEntityAsMissionEntity(veh, true, true)
local id = NetworkGetNetworkIdFromEntity(veh)
local id = NetworkGetNetworkIdFromEntity(veh)
SetNetworkIdCanMigrate(id, true)
SetNetworkIdCanMigrate(id, true)


local plate = 'WORK' .. math.random(100, 900)
local plate = 'WORK' .. math.random(1000, 9000)
SetVehicleNumberPlateText(veh, plate)
SetVehicleNumberPlateText(veh, plate)
table.insert(myPlate, plate)
table.insert(myPlate, plate)
plate = string.gsub(plate, " ", "")
plate = string.gsub(plate, " ", "")


SetVehRadioStation(veh, "OFF")
SetVehRadioStation(veh, "OFF")
TaskWarpPedIntoVehicle(playerPed, veh, -1)
TaskWarpPedIntoVehicle(playerPed, veh, -1)
isJobVehicleDestroyed = false
isJobVehicleDestroyed = false
TriggerEvent('ls:newVehicle', plate, nil, nil)


if vehicle.HasCaution then
if vehicle.HasCaution then
vehicleInCaseofDrop = veh
vehicleInCaseofDrop = veh
vehicleHashInCaseofDrop = vehicle.Hash
vehicleHashInCaseofDrop = vehicle.Hash
vehicleObjInCaseofDrop = vehicle
vehicleObjInCaseofDrop = vehicle
vehicleMaxHealthInCaseofDrop = GetEntityMaxHealth(veh)
vehicleMaxHealthInCaseofDrop = GetEntityMaxHealth(veh)
vehicleOldHealthInCaseofDrop = vehicleMaxHealthInCaseofDrop
vehicleOldHealthInCaseofDrop = vehicleMaxHealthInCaseofDrop
end
end
end
end
end)
end)