gokalpfirat Posted July 16, 2011 Share Posted July 16, 2011 local x,y,z = getElementPosition(door) function onResourceStart() door = createObject(3095,1279.9134521484,-2054.0205078125,62.628402709961,0,271.07666015625,0) end addEventHandler("onResourceStart", resourceRoot, onResourceStart) function move(thePlayer,cmd) if ( z = 62.628402709961 ) then moveObject ( door, 10000, x, y, z + 10 ) else outputChatBox("Door is already open",thePlayer,0,255,0,true) end end addCommandHandler ( "dooropen", move) function movez(thePlayer,cmd) if ( z = 72.628402709961 ) then moveObject ( door, 10000, x, y, z - 10 ) outputChatBox("Door is already closed",thePlayer,0,255,0,true) else end end addCommandHandler ( "doorclose", movez) Can you fix it Link to comment
Try Posted July 16, 2011 Share Posted July 16, 2011 local x,y,z = getElementPosition(door) door = createObject(3095,1279.9134521484,-2054.0205078125,62.628402709961,0,271.07666015625,0) function move(thePlayer,cmd) if ( z = 62.628402709961 ) then moveObject ( door, 10000, x, y, z + 10 ) else outputChatBox("Door is already open",thePlayer,0,255,0,true) end end addCommandHandler ( "dooropen", move) function movez(thePlayer,cmd) if ( z = 72.628402709961 ) then moveObject ( door, 10000, x, y, z - 10 ) else outputChatBox("Door is already closed",thePlayer,0,255,0,true) end end addCommandHandler ( "doorclose", movez) Link to comment
qaisjp Posted July 16, 2011 Share Posted July 16, 2011 local x,y,z = getElementPosition(door) function onResourceStart() door = createObject(3095,1279.9134521484,-2054.0205078125,62.628402709961,0,271.07666015625,0) end addEventHandler("onResourceStart", resourceRoot, onResourceStart) function move(thePlayer,cmd) if ( z == 62.628402709961 ) then moveObject ( door, 10000, x, y, z + 10 ) else outputChatBox("Door is already open",thePlayer,0,255,0,true) end end addCommandHandler ( "dooropen", move) function movez(thePlayer,cmd) if ( z == 72.628402709961 ) then moveObject ( door, 10000, x, y, z - 10 ) outputChatBox("Door is already closed",thePlayer,0,255,0,true) else end end addCommandHandler ( "doorclose", movez) The real fixed verison ^^ (untested) Link to comment
JR10 Posted July 16, 2011 Share Posted July 16, 2011 function onResourceStart() door = createObject(3095,1279.9134521484,-2054.0205078125,62.628402709961,0,271.07666015625,0) x,y,z = getElementPosition(door) end addEventHandler("onResourceStart", resourceRoot, onResourceStart) function move(thePlayer,cmd) if ( z == 62.628402709961 ) then moveObject ( door, 10000, x, y, z + 10 ) else outputChatBox("Door is already open",thePlayer,0,255,0,true) end end addCommandHandler ( "dooropen", move) function movez(thePlayer,cmd) if ( z == 72.628402709961 ) then moveObject ( door, 10000, x, y, z - 10 ) outputChatBox("Door is already closed",thePlayer,0,255,0,true) else end end addCommandHandler ( "doorclose", movez) Link to comment
Aibo Posted July 17, 2011 Share Posted July 17, 2011 function onResourceStart() door = createObject(3095, 1279.9134521484, -2054.0205078125, 62.628402709961, 0, 271.07666015625, 0) end addEventHandler("onResourceStart", resourceRoot, onResourceStart) function move(thePlayer,cmd) local x, y, z = getElementPosition(door) if cmd == "dooropen" then if z < 72 then moveObject ( door, 10000, x, y, 72.628402709961) else outputChatBox("Door is already open",thePlayer,0,255,0,true) end elseif cmd == "doorclose" then if z > 63 then moveObject ( door, 10000, x, y, 62.628402709961) else outputChatBox("Door is already closed", thePlayer,0,255,0,true) end end end addCommandHandler("dooropen", move) addCommandHandler("doorclose", move) Link to comment
Wojak Posted July 17, 2011 Share Posted July 17, 2011 i don't understand how can you be so trustful... z == 62.628402709961 z == 72.628402709961 and what if z will be somehow equal 72.628402709960 ? function onResourceStart() door = createObject(3095,1279.9134521484,-2054.0205078125,62.628402709961,0,271.07666015625,0) x,y,z = getElementPosition(door) dorstate = false end addEventHandler("onResourceStart", resourceRoot, onResourceStart) function move(thePlayer,cmd) if not dorstate then dorstate = true moveObject ( door, 10000, x, y, 72.628402709961 ) else outputChatBox("Door is already open",thePlayer,0,255,0,true) end end addCommandHandler ( "dooropen", move) function movez(thePlayer,cmd) if dorstate then dorstate = false moveObject ( door, 10000, x, y, 62.628402709961 ) outputChatBox("Door is already closed",thePlayer,0,255,0,true) else end end addCommandHandler ( "doorclose", movez) 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