Multiple coords within a list

Hello! I am trying to make my [Release] Safe Zone(s) Updated 9/10/18 able to have multiple locations.

Right now I have

local coords = {
         "1847.916015625, 3675.8190917968, 33.767009735108",
         "2000.916015625, 3432.8190917968, 37.767009735108"
}

for the list.

And for the Calling of your location i have

local dist = GetDistanceBetweenCoords(pedpos,[coords],true)

This doesnt work, obviously why im askng for help :stuck_out_tongue:

Is this because the coords are in " " and when the GetDist function uses [coords] it is placing the " " in there as well, which, the function does recognize?

2 Likes

Try to add a while for the text. Something like this:

While GetDistanceBetweenCoords(pedpos,1847.916015625,3675.8190917968,33.767009735108,true) <= 50.0 do
DrawMissionText2(“You are in a ~g~Safe Zone~w~.”, 5000)

EDIT

---------------------------------------------------------------------------
-- Coords Example One
---------------------------------------------------------------------------
local coords = {
	{ 1847.916015625, 3675.8190917968, 33.767009735108, 20.0 },
	{ 2000.916015625, 3432.8190917968, 37.767009735108, 20.0 }
}

Citizen.CreateThread(function()
	while true do
		local player_pos = GetEntityCoords(GetPlayerPed(-1), false)
		for a = 1, #coords do
			local distance = GetDistanceBetweenCoords(player_pos.x, player_pos.y, player_pos.z, coords[a][1], coords[a][2], coords[a][3], true)
			if distance < coords[a][4] then -- 20.0 4TH INDEX is the radius
				-- Inside Zone Radius
			end
		end
	end
end)

---------------------------------------------------------------------------
-- Coords Example Two
---------------------------------------------------------------------------
local coords = {
	{ x = 1847.916015625, y = 3675.8190917968, z = 33.767009735108, r = 20.0 },
	{ x = 2000.916015625, y = 3432.8190917968, z = 37.767009735108, r = 20.0 }
}

Citizen.CreateThread(function()
	while true do
		local player_pos = GetEntityCoords(GetPlayerPed(-1), false)
		for a = 1, #coords do
			local distance = GetDistanceBetweenCoords(player_pos.x, player_pos.y, player_pos.z, coords[a].x, coords[a].y, coords[a].z, true)
			if distance < coords[a].r then -- 20.0 4TH INDEX is the radius
				-- Inside Zone Radius
			end
		end
	end
end)