Hello !
I’m trying to modify my police and ambulance jobs to make them able to put dead players in their vehicles but it just doesn’t seem to work out for me So help would be appreciated !
So here’s what i tried with natives and through looking at some topics around here which weren’t helpful and didn’t bring a final solution:
RegisterNetEvent(‘esx_policejob:putInVehicle’)
AddEventHandler(‘esx_policejob:putInVehicle’, function()
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
if not isHandcuffed then
return
end
if IsAnyVehicleNearPoint(coords, 5.0) then
local vehicle = ESX.Game.GetVehicleInDirection()
if DoesEntityExist(vehicle) and IsEntityDead(playerPed) then
local maxSeats, freeSeat = GetVehicleMaxNumberOfPassengers(vehicle)
for i=maxSeats - 1, 0, -1 do
if IsVehicleSeatFree(vehicle, i) then
freeSeat = i
break
end
end
if freeSeat then
dragStatus.isDragged = false
Citizen.Wait(500)
SetPedIntoVehicle((playerPed, vehicle, freeSeat)
end
end
end
end)
Using the native SetPedIntoVehicle it works for the dead player. He sees himself in the car but we see them laying flat on the ground next to us or flying 20 feet away.
The Native TaskWarpPedIntoVehicle just flat out didn’t work at all.
lots of appreciation to any one who can point me out whats wrong