Jump to content

Open/Close a gate with the same command.


lJames

Recommended Posts

Hi, i'm new and very noob in all this scripting thing, but I want to learn, at least, basic things.

I tried to create myself a script to open/close a gate, which is the following.

puerta = createObject (971, -2136.599609375, 208.599609375, 38, 0, 0, 270) 
function abrirPuerta(player) 
moveObject (puerta, 5000, -2136.6000976563, 208.60000610352, 29) 
end 
addCommandHandler ("james", abrirPuerta) 
  
function cerrarPuerta(player) 
moveObject (puerta, 5000, -2136.599609375, 208.599609375, 38) 
end 
addCommandHandler ("james2", cerrarPuerta) 

I know it's very very simple, but it's the best I can do.

The thing is, I want to make that door open and close with the same command. I think I have to use an if, but I'm not sure how to do it.

If someone could help me, I'd appreciate it.[/i]

Edited by Guest
Link to comment

Try this:

puerta = createObject (971, -2136.599609375, 208.599609375, 38, 0, 0, 270) 
function abrirPuerta(player) 
    moveObject (puerta, 5000, -2136.6000976563, 208.60000610352, 29) 
    setTimer( 
        function () 
            moveObject(puerta, 5000, -2136.599609375, 208.599609375, 38) 
        end, 3500, 1 
    ) 
end 
addCommandHandler ("james", abrirPuerta) 
  

Edited by Guest
Link to comment
Try this:
puerta = createObject (971, -2136.599609375, 208.599609375, 38, 0, 0, 270) 
function abrirPuerta(player) 
    moveObject (puerta, 5000, -2136.6000976563, 208.60000610352, 29) 
    setTimer( 
        function () 
            moveObjct(puerta, 5000, -2136.599609375, 208.599609375, 38) 
        end, 3500, 1 
    ) 
end 
addCommandHandler ("james", abrirPuerta) 
  

Your code is wrong. Line 6, "moveObjct"?

Link to comment
Try this:
puerta = createObject (971, -2136.599609375, 208.599609375, 38, 0, 0, 270) 
function abrirPuerta(player) 
    moveObject (puerta, 5000, -2136.6000976563, 208.60000610352, 29) 
    setTimer( 
        function () 
            moveObjct(puerta, 5000, -2136.599609375, 208.599609375, 38) 
        end, 3500, 1 
    ) 
end 
addCommandHandler ("james", abrirPuerta) 
  

Your code is wrong. Line 6, "moveObjct"?

yea .. LOL

Link to comment

Try this:

  
local open = false 
addCommandHandler("james",  
    function() 
        if not open then 
            moveObject(puerta, 5000, -2136.6000976563, 208.60000610352, 29) 
            open = true 
        elseif open then 
            moveObject(puerta, 5000, -2136.599609375, 208.599609375, 38) 
        end 
    end 
) 

Link to comment
Try this:
puerta = createObject (971, -2136.599609375, 208.599609375, 38, 0, 0, 270) 
function abrirPuerta(player) 
    moveObject (puerta, 5000, -2136.6000976563, 208.60000610352, 29) 
    setTimer( 
        function () 
            moveObjct(puerta, 5000, -2136.599609375, 208.599609375, 38) 
        end, 3500, 1 
    ) 
end 
addCommandHandler ("james", abrirPuerta) 
  

Your code is wrong. Line 6, "moveObjct"?

lmao, fail :D

Link to comment
Try this:
  
local open = false 
addCommandHandler("james",  
    function() 
        if not open then 
            moveObject(puerta, 5000, -2136.6000976563, 208.60000610352, 29) 
            open = true 
        elseif open then 
            moveObject(puerta, 5000, -2136.599609375, 208.599609375, 38) 
        end 
    end 
) 

I edited some things, and it worked. ¡Thanks!

I leave here the definitive script, so someone who wants the same thing can obtain it.

puerta = createObject (971, -2136.599609375, 208.599609375, 37.898998260498, 0, 0, 270) 
local open = false 
    function movePuerta (player) 
        if not open then 
            moveObject(puerta, 5000, -2136.6000976563, 208.60000610352, 29) 
            open = true 
        else if open then 
            moveObject(puerta, 5000, -2136.599609375, 208.599609375, 37.898998260498) 
            end 
        end 
    end 
addCommandHandler("james", movePuerta) 

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