Help on GetDistanceBetweenCoords

Hello, I have a problem with my first own script, I user GetDistanceBetweenCoords, but it only checks it one time on the resource start, so when i am in the point and restart the resource I´ll get the notification, but when i´m outside of the point, restart the resource and go in, it doesnt show the notification, so what am I doing wrong?

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		local distance = GetDistanceBetweenCoords(coords, ziel, true)
		if transport then
			if distance <= 5 then
			ESX.ShowHelpNotification('Drücke ~INPUT_PICKUP~ um die Waffen aufzuladen')
			
			end
			DrawMarker(Config.PointMarker.Type, ziel , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.PointMarker.x, Config.PointMarker.y, Config.PointMarker.z, Config.PointMarker.r, Config.PointMarker.g, Config.PointMarker.b, 100, false, true, 2, false, nil, nil, false)
		end
	end
end)

Thanks for the help

2 Likes

We need more code to help you. Where is defined coords and ziel? Right now I have feeling that you get player coords only on start of resource. So fix might be to add

local coords = GetEntityCoords(PlayerPedId())

before local distance

1 Like

Ahh, that worked thanks

1 Like