Jump to content

[Help] Turning gate


jiirco

Recommended Posts

Hello everybody,

I have 2 problems

1.I have a gate script (see below) and i can move gate's up, down , left, right and diagonal but now i need my gates to turn when they open at about a 90° angle but when i try this my gate turns 90° and when i cole it it turns 90° again instead of going back to its original position so please help me with this.

2. When the gate opens and you type /gate again it already closes but i want it so that the gate has to be completely shut or open before it opens or shuts again how can i do this?

gate script:

local gate = createObject(988, -2864.5, 464, 4.6999998092651, 0, 0, 82.249145507813 ) 
local gate2 = createObject(988, -2863.7998046875, 469.3994140625, 4.6999998092651, 0, 0, 83.248901367188 ) 
local gate3 = createObject(988, -2947.7998046875, 486.7998046875, 2.7000000476837, 0, 0, 180 ) 
local gate4= createObject(988, -2976.2998046875, 486.69921875, 2.7000000476837, 0, 0, 180 ) 
megusta = false 
  
addCommandHandler("gate", 
function (source) 
    if ( getTeamName ( getPlayerTeam ( source ) ) == "Grove" ) then 
        if (megusta == false) then 
            moveObject(gate, 3000, -2864.5, 464, 4.6999998092651, 0, 0, 0 ) 
            moveObject(gate2, 3000, -2863.7998046875, 469.3994140625, 4.6999998092651, 0, 0, 0 ) 
            moveObject(gate3, 3000, -2947.7998046875, 486.7998046875, 2.7000000476837, 0, 0, 0 ) 
            moveObject(gate4, 3000, -2976.2998046875, 486.69921875, 2.7000000476837, 0, 0, 0 ) 
            megusta = true 
        elseif (megusta == true) then 
            moveObject(gate, 3000, -2867.5, 461.39999389648, 4.6999998092651, 0, 0, 0 ) 
            moveObject(gate2, 3000, -2866.3000488281, 472.10000610352, 4.6999998092651, 0, 0, 0 ) 
            moveObject(gate3, 3000, -2947.8000488281, 486.79998779297, -2.2999999523163, 0, 0, 0 ) 
            moveObject(gate4, 3000, -2976.3000488281, 486.70001220703, -2.2999999523163, 0, 0, 0 ) 
            megusta = false 
    else 
        outputChatBox( "You're not in the Grove Family", source, 0, 255, 0, true ) 
        end 
    end 
end) 

P.S. it is gate 1 and 2 that should turn 3 & 4 just go in the ground

Link to comment

change;

moveObject(gate, 3000, -2864.5, 464, 4.6999998092651, 0, 0, 0) 

too

local gateMoved = moveObject(gate, 3000, -2864.5, 464, 4.6999998092651) 
if (gateMoved) then 
local rotX, rotY, rotZ = getElementRotation(gate) 
setElementRotation (gate, rotX, rotY, rotZ+90) 
end 

Edited by Guest
Link to comment

ADD:

For problem 2 i'm not sure, If i'm right;

addCommandHandler("gate", 
function (source)  
local position = getElementPositon (x,y,z of the move location) 
 if (position) then 
  -- moveObject or setElementRotation 
 else 
 outputChatBox("wait till the gate is closed", source, 0, 255, 0, true ) 
 end 
end 
) 

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