(NEED HELP) Putting dead players in vehicles

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 :confused: 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.

:pray: lots of appreciation to any one who can point me out whats wrong

1 Like

The position of dead players isn’t updated very well, for other players on the network.
The best solution to avoid invisible dead players, placing dead players into vehicles, etc. is to instantly revive players on death but place them into a false dead state. The scripts will treat them as dead, but the game thinks they are alive, so everything will work as intended.

I explained the same here → [REQUEST] Script that makes player's ped stay in vehicle when he dies in vehicle - #2 by DrAceMisanthrope

Oh i see ! I’m not quite advanced enough with my knowledged to know how to do that tho. Could you explain it to me?

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.