Jump to content

markers issue...


aintaro

Recommended Posts

use a loop, firstly make a table in all the positions:

  
pos = { 
--{x,y,z} 
} 
  
  
for i,v in ipairs(pos) do 
local x,y,z = unpack(pos[i]) 
createMarker(x,y,z ......) 
end 
  
closestMarker  = 9999999999999999  
  
addEventHandler("onMarkerHit",root,  
function (player) 
for i,v in ipairs(pos) do 
local x,y,z = unpack(pos) 
x1 , y1,z1 = getElementPosition(player) 
distance2 = getDistanceBetweenPoints3D(x,y,z,x1,y1,z1) 
--tell me what do you want then? 
end 
end 
) 
  
  
  

Link to comment
addEventHandler("onMarkerHit",root,  
function (player) 
    -- source is the marker that you hit when root is the attached element, to get the distance, use this 
    local max,may,maz = getElementPosition(source) 
    local px,py,pz = getElementPosition(player) 
    local distance = getDistanceBetweenPoints3D( max,may,maz, px,py,pz ) 
end) 

Don't use loops where it's not needed, this will give you both the marker element and the distance from this marker element to the player or element that just hit it, I'm not sure what you are trying to do but this should cover anything you need in a way more efficient way.

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