Hi!
I’ve wanted to create teleport option in personal menu for addon map in the skies. It should be an option only for people who are already got there via different teleport.
This teleporting feature inside this giant map is working, BUT when I want to set distance in which they can still use this teleport to start line, it behaves very weirdly. When I was using sphere as graphic marker for certain distance across this map, it looked very easy. But actual distance that enables the teleport from ESX menu doesn’t behave the same way. Upon using noclip, the allowed area for this teleport have been eg. 4000 units into northern direction, NW maybe around 500 and W about 3-4000 again.
Maybe I am doing something (again) wrong, but I though it will “GetDistanceBetweenCoords” native will behave same in all directions
function openpersonalmenu()
local plyCoords = GetEntityCoords(PlayerPedId())
local RingArea = 4381.696, -4250.229, 2102.323 -- same "non-spherical" problem
local RingArea1 = 3719.256, -2689.689, 2970.752
local RingArea2 = 6139.038, -3346.716, 2123.272
local RingArea3 = 3204.921, -6455.424, 2213.802
local RingArea4 = 2352.362, -5078.228, 2188.063
local IsInRingArea = GetDistanceBetweenCoords(plyCoords, RingArea, true)
local IsInRingArea1 = GetDistanceBetweenCoords(plyCoords, RingArea1, true)
local IsInRingArea2 = GetDistanceBetweenCoords(plyCoords, RingArea2, true)
local IsInRingArea3 = GetDistanceBetweenCoords(plyCoords, RingArea3, true)
local IsInRingArea4 = GetDistanceBetweenCoords(plyCoords, RingArea4, true)
local elements = {
{label = _U('id_card'), value = 'id_kort'},
{label = _U('bills'), value = 'bills'},
{label = _U('OpenAnimationsMenu'), value = 'OpenAnimationsMenu'}}
if (IsInRingArea1 <= 3000.0) or (IsInRingArea2 <= 3000.0) or (IsInRingArea3 <= 3000.0) or (IsInRingArea4 <= 3000.0) then
table.insert(elements, {label = _U('RingAreaMenu'), value = 'RingAreaMenu'})
end
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'personal_menu',
{ title = _U('personal_menu'),
align = 'left',
elements = elements
},
function(data, menu)
if data.current.value == 'id_kort' then
openMenu()
end
if data.current.value == 'RingAreaMenu' then
RingAreaTp()
end
end,
function(data, menu)
menu.close()
OpenCivilianActionsMenu()
end
)
end
function RingAreaTp()
local targetPed = PlayerPedId()
if (IsPedInAnyVehicle(targetPed)) then
targetPed = GetVehiclePedIsUsing(targetPed)
DoScreenFadeOut(100)
Citizen.Wait(750)
SetEntityCoordsNoOffset(targetPed, 3537.103, -6537.880, 2188.207, 0, 0, 1)
FreezeEntityPosition(targetPed, true) -- prevention for falling though texture
Citizen.Wait(250)
FreezeEntityPosition(targetPed, false)
DoScreenFadeIn(100)
end
end
Bit of visual explanation, where words might have failed