Jump to content

getting distance from an object model?


Lukkaz

Recommended Posts

Hey everyone I was just wondering how I can get the distance from an object model, for example a safe. What functions could I use to determine where it is for the getDistanceBetween3d function.

example:

  
x,y,z = getElementPosition(getLocalPlayer()) 
wx,wy,wz = (idk what goes here) 
local dis = getDistanceBetweenPoints3D(x,y,z,wx,wy,wz) 
if dis >5 then 
outputChatbox("your not near a safe") 
else  
outputChatBox ("you ARE near a safe") 
  

Can someone help me out here?

Link to comment
  
local x,y,z = getElementPosition(getLocalPlayer()) 
local wx,wy,wz = getElementPosition(safeObject) 
local dis = getDistanceBetweenPoints3D(x,y,z,wx,wy,wz) 
if dis >5 then 
  outputChatBox("your not near a safe") 
else 
  outputChatBox ("you ARE near a safe") 
end 
  

Link to comment
  
local x,y,z = getElementPosition(getLocalPlayer()) 
local wx,wy,wz = getElementPosition(safeObject) ---is that the model ID of the object? 
local dis = getDistanceBetweenPoints3D(x,y,z,wx,wy,wz) 
if dis >5 then 
  outputChatBox("your not near a safe") 
else 
  outputChatBox ("you ARE near a safe") 
end 
  

Link to comment
  
local safeObject = createObject(1337, 0, 0, 0) 
local x,y,z = getElementPosition(getLocalPlayer()) 
local wx,wy,wz = getElementPosition(safeObject) 
local dis = getDistanceBetweenPoints3D(x,y,z,wx,wy,wz) 
if dis >5 then 
  outputChatBox("your not near a safe") 
else 
  outputChatBox ("you ARE near a safe") 
end 
  

safeObject is the safe OBJECT. Is the safe object already made? If so, copy the createObject line.

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