Jump to content

Distance help


Fox261098

Recommended Posts

Hello i made a gate the gate is in lv but i can open it in ls so how to make so it opens just when u in front of the gate 

 

local gate = createObject(10828,1838.3000488281,908.90002441406,22.10000038147,0,0,90);
local thegang = "TheGhosts";

addCommandHandler("ogate", function(player)
	local gang = getElementData(player, "gang") or false;
	if (gang and gang == thegang) then
		moveObject(gate, 4000,1838.3000488281,941.79998779297,22.10000038147);
	end
end);

addCommandHandler("cgate", function(player)
	local gang = getElementData(player, "gang") or false;
	if (gang and gang == thegang) then
		moveObject(gate, 4000,1838.3000488281,908.90002441406,22.10000038147);
	end
end);

 

Link to comment
local gate = createObject(10828,1838.3000488281,908.90002441406,22.10000038147,0,0,90)
local col = createColSphere(1838.3000488281,908.90002441406,22.10000038147, 4)
local thegang = "TheGhosts"

addEventHandler("onColShapeHit", col, function(hitElement)
    if getElementType(hitElement) == "player" then
	local gang = getElementData(hitElement, "gang")
	if (gang and gang == thegang) then
		moveObject(gate, 4000,1838.3000488281,941.79998779297,22.10000038147)
	end
    end
end)
  
addEventHandler("onColShapeLeave", col,
  function(hitElement)
    if getElementType(hitElement) == "player" then
	local gang = getElementData(hitElement, "gang")
	if (gang and gang == thegang) then
		moveObject(gate, 4000,1838.3000488281,908.90002441406,22.10000038147)
	end
    end
end)

Try it

Also, those '  ;  ' are not needed in lua.

Edited by Miika822
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...