Jump to content

Price Distance between markers locations


KariiiM

Recommended Posts

Hey,

i tried to make the reward distance between markers positions but i failed,

thanks in advance

--Part of my code:

  
local markerlocations = { 
[1]={x=2220.43, y=2469.49, z=10.82}, 
[2]={x=1625.00, y=1850.43, z=10.82}, 
[3]={x= 1718.26, y=1484.68, z=10.82} 
} 
  
local theTable = { 
[1]={"LV", 2220.43, 2469.49, 11.82}, 
[2]={"LS", 1625.00, 1850.43, 11.82}, 
[3]={"SF", -2682.52, 574.32, 15.67} 
} 
  
addEventHandler("onResourceStart",resourceRoot, 
function () 
        local px, py, pz = getElementPosition(source) 
        local miniumDistance = 2000 
    for index, pos in pairs(markerlocations) do 
        local marker = createMarker(pos.x, pos.y, pos.z-1, "cylinder", 1.3,  247,187, 7, 120) 
        local x, y = pos[1], pos[2] 
        local distance = getDistanceBetweenPoints2D(px, py, x, y) 
            if (distance < miniumDistance) then 
                miniumDistance = distance    
        end 
    end 
end) 
  
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...