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