LiOneLMeSsIShoT Posted November 23, 2013 Share Posted November 23, 2013 I've made a gate script works with bindKey...but i have to restart the script every join to make it work...if i'm in the server already i can't use it until i restart the gate..idk why ..no errors in debugscript too local gate = createObject ( 980, 2287,603.20001220703,12.60000038147,0,0,0) local open = false local closing = false -- Open the Gate function MoveObject (thePlayer) if open then -- Check is the gate is opened return outputChatBox ("The Gate's Already Open", thePlayer, 0, 255, 0) elseif closing then return outputChatBox ("The Gate's closing", thePlayer, 0, 255, 0) end local x, y, z = getElementPosition(thePlayer) local distance = getDistanceBetweenPoints3D(2287,603.20001220703,12.60000038147, x, y, z) if (distance <= 17) then -- Check if the player is in the zone moveObject (gate, 1000, 2287, 603.20001220703,6.4000000953674) setTimer (moveBack, 5000, 1) open = true -- Say the gate is opened end end -- Close the Gate function moveBack () moveObject (gate, 1000, 2287,603.20001220703,12.60000038147) open = false -- Say the gate is closed closing = true -- Say the gate is closing setTimer(function () closing = false end, 3000,1) addCommandHandler ("OpenTheGate", MoveObject, false, false) for _,player in ipairs(getElementsByType("player")) do bindKey(player, "tab", "down", MoveObject) end Link to comment
TAPL Posted November 23, 2013 Share Posted November 23, 2013 local gate = createObject ( 980, 2287,603.20001220703,12.60000038147,0,0,0) local open = false local closing = false -- Open the Gate function MoveObject (thePlayer) if open then -- Check is the gate is opened return outputChatBox ("The Gate's Already Open", thePlayer, 0, 255, 0) elseif closing then return outputChatBox ("The Gate's closing", thePlayer, 0, 255, 0) end local x, y, z = getElementPosition(thePlayer) local distance = getDistanceBetweenPoints3D(2287,603.20001220703,12.60000038147, x, y, z) if (distance <= 17) then -- Check if the player is in the zone moveObject (gate, 1000, 2287, 603.20001220703,6.4000000953674) setTimer (moveBack, 5000, 1) open = true -- Say the gate is opened end end -- Close the Gate function moveBack () moveObject (gate, 1000, 2287,603.20001220703,12.60000038147) open = false -- Say the gate is closed closing = true -- Say the gate is closing setTimer(function () closing = false end, 3000,1) end addCommandHandler ("OpenTheGate", MoveObject, false, false) addEventHandler("onResourceStart", resourceRoot, function() for _,player in ipairs(getElementsByType("player")) do bindKey(player, "tab", "down", MoveObject) end end) addEventHandler("onPlayerJoin", root, function() bindKey(source, "tab", "down", MoveObject) end) Link to comment
LiOneLMeSsIShoT Posted November 23, 2013 Author Share Posted November 23, 2013 local gate = createObject ( 980, 2287,603.20001220703,12.60000038147,0,0,0) local open = false local closing = false -- Open the Gate function MoveObject (thePlayer) if open then -- Check is the gate is opened return outputChatBox ("The Gate's Already Open", thePlayer, 0, 255, 0) elseif closing then return outputChatBox ("The Gate's closing", thePlayer, 0, 255, 0) end local x, y, z = getElementPosition(thePlayer) local distance = getDistanceBetweenPoints3D(2287,603.20001220703,12.60000038147, x, y, z) if (distance <= 17) then -- Check if the player is in the zone moveObject (gate, 1000, 2287, 603.20001220703,6.4000000953674) setTimer (moveBack, 5000, 1) open = true -- Say the gate is opened end end -- Close the Gate function moveBack () moveObject (gate, 1000, 2287,603.20001220703,12.60000038147) open = false -- Say the gate is closed closing = true -- Say the gate is closing setTimer(function () closing = false end, 3000,1) end addCommandHandler ("OpenTheGate", MoveObject, false, false) addEventHandler("onResourceStart", resourceRoot, function() for _,player in ipairs(getElementsByType("player")) do bindKey(player, "tab", "down", MoveObject) end end) addEventHandler("onPlayerJoin", root, function() bindKey(source, "tab", "down", MoveObject) end) Works Fine Thanks PRO ! 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