Jump to content

Need help with gate script!


xScatta

Recommended Posts

Yeah so there we are here its a problem

function brama() 
lol = createObject ( 987, 316.79, -1191.80, 74.90, 0, 0, 40 ) 
x, y, z = 316.79, -1191.80, 74.90 
x1, y1, z1 = getElementPosition ( lol ) 
if ( x1, y1, z1 == x, y, z ) then  
moveObject ( lol, 2.5, 316.79, -1191.80, 69, 0, 0, 40 ) 
elseif ( x1, y1, z1 == x, y, z ) then  
moveObject ( lol, 2.5, 316.79, -1191.80, 74.90, 0, 0, 40 ) 
end 
end 
  
  
addCommandHandler("brama", brama ) 

problem is in the

if ( x1, y1, z1 == x, y, z ) then debug script says ')' expected near ','

i dont know why because i maked many scripts like this but this dont work why?

any repair

Link to comment

((Not Tested))

lol = createObject ( 987, 316.79, -1191.80, 74.90, 0, 0, 40 ) 
local isGateOpen = false; 
function brama() 
    if ( not isGateOpen ) then 
        moveObject ( lol, 2.5, 316.79, -1191.80, 69, 0, 0, 40 ) 
        isGateOpen = true 
    else 
        moveObject ( lol, 2.5, 316.79, -1191.80, 74.90, 0, 0, 40 ) 
        isGateOpen = false 
    end 
end 
 addCommandHandler("brama", brama ) 

Link to comment
lol = createObject ( 987, 316.79, -1191.80, 74.90, 0, 0, 40 ) 
function move() 
    if lol then 
        moveObject ( lol, 2.5, 316.79, -1191.80, 69, 0, 0, 40 ) 
    else 
        moveObject ( lol, 2.5, 316.79, -1191.80, 74.90, 0, 0, 40 ) 
    end 
end 
 addCommandHandler("brama", move ) 

Link to comment
local lol = createObject ( 987, 316.79, -1191.80, 74.90, 0, 0, 40 ) 
local state = 0 
function move() 
    if state == 0 then 
        moveObject ( lol, 2.5, 316.79, -1191.80, 69, 0, 0, 40 ) 
        state = state + 1 
    elseif state == 1 then 
        moveObject ( lol, 2.5, 316.79, -1191.80, 74.90, 0, 0, 40 ) 
        state = state - 1 
    end 
end 
 addCommandHandler("brama", move ) 

Try this

Link to comment
local lol = createObject ( 987, 316.79, -1191.80, 74.90, 0, 0, 40 ) 
local state = 0 
function move() 
    if state == 0 then 
        moveObject ( lol, 2.5, 316.79, -1191.80, 69 ) 
        state = state + 1 
    elseif state == 1 then 
        moveObject ( lol, 2.5, 316.79, -1191.80, 74.90) 
        state = state - 1 
    end 
end 
 addCommandHandler("brama", move ) 

It must be work this way now! :)

I tested it.

The problem was that, the rotation is relative when you use moveObject() :)

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