Steve_Rogerzz Posted May 29, 2021 Share Posted May 29, 2021 If a player is inside a range then script executes else end , but i dont know how to make a script like that Link to comment
SpecT Posted May 29, 2021 Share Posted May 29, 2021 Hey, The function isElementInRange is called a "useful" function because it's not hardcoded but you have to put it in your script. On the documentation (^) page everything is explained. You haven't shown us any code where we can see what you tried. I don't know what your idea is so I'm just gonna give you an example how to use it (taken from the Wiki page). function playerInRange(player, cmd) local x, y, z = 1492, 1444, 0 -- example location coordinates if isElementInRange (player, x, y, z, 25) then -- check if the player is near the location; range 25m -- do your stuff here else outputChatBox("You are not in range!", player) end end addCommandHandler("check", playerInRange) function isElementInRange(ele, x, y, z, range) if isElement(ele) and type(x) == "number" and type(y) == "number" and type(z) == "number" and type(range) == "number" then return getDistanceBetweenPoints3D(x, y, z, getElementPosition(ele)) <= range -- returns true if it the range of the element to the main point is smaller than (or as big as) the maximum range. end return false end Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now