Jump to content

Move object


Recommended Posts

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
    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
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
  
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
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

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

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...