Ressource to Teleport the current Player if stuck under map

Hi there,

I am currently creating a help command for players which had the issue to fall through the map into nothing and do not respawn. Instead they are standing in nowhere position. On DB side this looks like {“z”:1.0,“y”:0.0,“x”:0.0} position in the users database. Sometimes also y = 1.0. I created a simple ressource if there is no admin online. So the player is able to trigger the command /stuck to set him free and teleport to a specified position.

That’s the theory. I managed it to update the users table to have a proper position again. But in this specific situation, the player is not moving when I trigger the teleportation.

This is my current attempt to move player out of the dark:

    local ped = GetPlayerPed(-1)

	RequestCollisionAtCoord(-4.0012941360474, 154.50444030762, 94.289237976074)
	SetEntityCoordsNoOffset(ped, -4.0012941360474, 154.50444030762, 94.289237976074, true, true, false)

	while (not HasCollisionLoadedAroundEntity(ped)) do
	       Citizen.Wait(0)
    end
    print("Should be fine now!")

I found out that its possible to use noclip but this is not available to the players and also shouldn’t.
Just disconnecting or sending quit to restart fivem is also not a solution cause the last position is saved in DB.

So hopefully someone has an idea to help me out to get this thing done. MAybe theres another event I could trigger to let the Player respawn.

Thanks in advance for your help!

Try this

    local playerped = GetPlayerPed(-1)
    local waypt = GetWaypointCoords()
    
    local Vehicle = Citizen.InvokeNative(0x9A9112A0FE9A4713, playerped,false) -- player arabada mı?
	local at = GetMount(playerped) -- playerin bindiği at id
	local pattami = Citizen.InvokeNative(0x95CBC65780DE7EB1, playerped,false) -- player ata biniyor mu?
	local entity
    for height = 1, 1000 do
        if Citizen.InvokeNative(0xA3EE4A07279BB9DB, playerped,Vehicle,true) then
			entity = Vehicle
		elseif pattami then
			entity = at
        else
			entity = playerped            
        end
		SetEntityCoords(entity, waypt.x, waypt.y, height + 0.0, true, true, true, false)
		local foundGround, zPos = GetGroundZAndNormalFor_3dCoord(waypt.x, waypt.y, height + 0.0)
		if foundGround then
			SetEntityCoords(entity, waypt.x, waypt.y, height + 0.0, true, true, true, false)
			break
		end
		Citizen.Wait(5)
    end  

Hi,

thanks for the suggestion. But still no effect. The player is still below the map without any movement.
As I have no “GetWaypointCoords” I changed this to my stored Config.Zone. I used in the other example. Shouldn’t be the issue why this is not working.

Added some log outputs to see what happens inside, but it seems that your code is running trough, but does not move the player.

Finally got it working using parts of your code. Thank you!

    local playerped = GetPlayerPed(-1)
    local waypt = Config.Zones.MD
    
    local vehicle = Citizen.InvokeNative(0x9A9112A0FE9A4713, playerped,false)
	local entity
    for height = 1, 1000 do
        if Citizen.InvokeNative(0xA3EE4A07279BB9DB, playerped,vehicle,true) then
			entity = vehicle
		else
			entity = playerped            
        end
			
		SetEntityCoords(entity, waypt.x, waypt.y, height + 0.0, true, true, true, false)
		local foundGround, zPos = GetGroundZAndNormalFor_3dCoord(waypt.x, waypt.y, height + 0.0)
		
		if foundGround then
			SetEntityCoords(playerped , waypt.x, waypt.y, height + 0.0, true, true, true, false)
			break
		end
		
		Citizen.Wait(5)
		SetEntityCoords(playerped , waypt.x, waypt.y + height, height + 0.0, true, true, true, false)
    end