Portside Posted February 1, 2014 Share Posted February 1, 2014 I just can't get my head around it at all! Is there anyway that I can use one command for this gate. For example, using the command /go to open the gate, can a timer be set on the script so it will close after so many seconds? Here's what I have: gate = createObject(980, 1579, 713.599609375, 12.5, 0, 0, 90) -- objID, X, Y, Z, Rotation X, Y, Z function gateOpen(source) local x, y, z = getElementPosition(source) local x1, y1, z1 = getElementPosition(gate) if getDistanceBetweenPoints3D(x, y, z, x1, y1, z1) <= 10 then moveObject(gate, 2000, 1579, 713.599609375, 7, 0, 0, 0) --moves the gate to the open position. time, X, Y, Z, Rotation X, Y, Z outputChatBox("Montana's Gate Is Now Open!", thePlayer, 0, 255, 0) end end addCommandHandler("go1", gateOpen)--Command /go1 to open gate function gateClose(source) local x, y, z = getElementPosition(source) local x1, y1, z1 = getElementPosition(gate) if getDistanceBetweenPoints3D(x, y, z, x1, y1, z1) <= 10 then moveObject(gate, 2000, 1579, 713.599609375, 12.5 , 0, 0, 0 ) --returns the gate to its starting position. X, Y, Z, Rotation X, Y, Z outputChatBox("Montana's Gate Is Now Closed!", thePlayer, 255, 0, 0) end end addCommandHandler("gc1", gateClose)--Command /gc1 to close gate Thanks in advance! Link to comment
Castillo Posted February 1, 2014 Share Posted February 1, 2014 Yes, you can use: setTimer Link to comment
Portside Posted February 1, 2014 Author Share Posted February 1, 2014 (edited) What do I need to remove from the script? Edited February 1, 2014 by Guest Link to comment
MTA Team 0xCiBeR Posted February 1, 2014 MTA Team Share Posted February 1, 2014 This will close the gate after 5 seconds: gate = createObject(980, 1579, 713.599609375, 12.5, 0, 0, 90) -- objID, X, Y, Z, Rotation X, Y, Z function gateOpen(source) local x, y, z = getElementPosition(source) local x1, y1, z1 = getElementPosition(gate) if getDistanceBetweenPoints3D(x, y, z, x1, y1, z1) <= 10 then moveObject(gate, 2000, 1579, 713.599609375, 7, 0, 0, 0) --moves the gate to the open position. time, X, Y, Z, Rotation X, Y, Z outputChatBox("Montana's Gate Is Now Open!", thePlayer, 0, 255, 0) setTimer(moveObject,5000,1,gate, 2000, 1579, 713.599609375, 12.5 , 0, 0, 0) end end addCommandHandler("go1", gateOpen)--Command /go1 to open gate Link to comment
MTA Team 0xCiBeR Posted February 1, 2014 MTA Team Share Posted February 1, 2014 You're Welcome. Link to comment
Portside Posted February 1, 2014 Author Share Posted February 1, 2014 One slight problem though, I need the; outputChatBox to activate when the gate is coming back up. Link to comment
MTA Team 0xCiBeR Posted February 1, 2014 MTA Team Share Posted February 1, 2014 gate = createObject(980, 1579, 713.599609375, 12.5, 0, 0, 90) -- objID, X, Y, Z, Rotation X, Y, Z function gateOpen(source) source = source local x, y, z = getElementPosition(source) local x1, y1, z1 = getElementPosition(gate) if getDistanceBetweenPoints3D(x, y, z, x1, y1, z1) <= 10 then moveObject(gate, 2000, 1579, 713.599609375, 7, 0, 0, 0) --moves the gate to the open position. time, X, Y, Z, Rotation X, Y, Z outputChatBox("Montana's Gate Is Now Open!", source, 0, 255, 0) setTimer(function () outputChatBox("Montana's Gate Is Now Closing!", source, 0, 255, 0) moveObject(gate, 2000, 1579, 713.599609375, 12.5 , 0, 0, 0)end,5000,1) end end addCommandHandler("go1", gateOpen)--Command /go1 to open gate Link to comment
Portside Posted February 1, 2014 Author Share Posted February 1, 2014 Thanks for all your help, that was bugging me lol. Much appreciated! Link to comment
MTA Team 0xCiBeR Posted February 1, 2014 MTA Team Share Posted February 1, 2014 No problem. 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