Putting Dead Bodies in a vehicle

Hey, I have tried to use both TaskWarpPedIntoVehicle and SetPedIntoVehicle to put a dead player into a vehicle and i’m having issues getting the player into the vehicle.

All help is appreciated!

    local playerPed = PlayerPedId()
	local coords = GetEntityCoords(playerPed)

	if IsPedDeadOrDying(playerPed, true) then
		if IsAnyVehicleNearPoint(coords, 5.0) then
			local vehicle = VehicleInFront() --GetClosestVehicle(coords, 5.0, 0, 71)
			
			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
					TaskWarpPedIntoVehicle(playerPed, vehicle, freeSeat)
					dragStatus.isDragged = false
				end
			end
		end
	end

When the player gets put in the vehicle, they get un-dragged but their bodies never go into the vehicle

here you are checking if freeSeat == true

but here

You are giving it int and/or float values.

if freeSeat then is checking to see if it has a value not if it’s true or false. This part of it works completely fine, the part that’s giving issues seems to be

TaskWarpPedIntoVehicle(playerPed, vehicle, freeSeat)

dragStatus.isDragged = false also works fine so I know the if statement doesn’t have any issues

Try unattaching the entity and waiting at least a frame before warping them into the vehicle.

Use GetEntityHealth instead of ispeddying native

1 Like

I’ll change it to that but it works with isPedDeadorDying native, just the task warp method isn’t working when they are dead. I have found a workaround temporarily but i’m still going to try what @anders said above. Thanks for the suggestions guys

EDIT:@anders, doesn’t seem to work :confused:

Strange, this is all I do

	if DoesEntityExist(closestVehicle) and closestVehicleSeat ~= nil then
		DetachEntity(ped, true, true)
		if IsEntityDead(ped) or IsPedRagdoll(ped) then
			TaskWarpPedIntoVehicle(ped, closestVehicle, closestVehicleSeat)
		else
                      ...
                      ...

It still feels like whatever you have detaching the entity is happening from this

dragStatus.isDragged = false

which is a line after you’re trying to warp them into the vehicle. I don’t think the ped will warp anywhere if it’s still attached to another entity, but I could be wrong :slight_smile:

2 Likes

@anders, The workaround I’m using still detaches after and still works for some reason but I’ll try what you mentioned, thanks a lot!

How did you end up getting it to work if you don’t mind. I’ve been trying to get something like this so our EMS can transport back to pillbox @blueeyedjoe

2 Likes

anyone have the script

Did you find a solution for this?? im desperatly trying to find a solution and can’t find pin points anywhere :confused:

Well SetPedIntoVehicle() is working fine with dead ped but the problem I found it mostly only dead player see themselves warp into the vehicle… but other players around that area mostly see them just lying near the vehicle and doesn’t go in the car… but sometimes it just works fine everyone sees the same things they all went in the car but not that long after that it gonna buggy again… I hope there is a way to do this thing and it works just fine cause it gonna make RP more fun and realistic.
And I saw one on the forum say about making players that suppose to be dead not that really dead in-game way but just put them in some state that makes it feel like they are dead cause some native gonna functional with alive ped more than dead ped and maybe we can just put them in vehicles bra bra bra and no more for falling through the ground after dead? or some dead ped appears in different pos for one player and another player… but it kinda needs to rewrite a lot of scripts that involve a dead player it kinda good idea? but for someone lazy like me I’m just hoping for some easy solutions for this buggy dead ped put in vehicle :stuck_out_tongue:
sorry for my English btw.^^

You have to network network resurrect ped and loop a dead emote while isDead. then have in different emote while player is in vehicle.

1 Like

Hi, can you help me out with the full script? Thanks