Jump to content

[HELP]2 Gates / 1 Command


ViRuZGamiing

Recommended Posts

Hello Community,

I have 2 Gates and "apart" they work 100% but...

Together only 1 Opens and after that nothing happens.

My 2 Gate scripts:

local gate = createObject(971, -2182.5, 1009.3994140625, 82.599998474121, 0, 0, 0) 
megusta = false 
  
addCommandHandler("gate", 
function (source) 
    if ( getTeamName ( getPlayerTeam ( source ) ) == "West Coast Cribs" ) then 
        if (megusta == false) then 
            moveObject(gate, 2500, -2182.5, 1009.3994140625, 82.599998474121, 0, 0, 0 ) 
            megusta = true 
        elseif (megusta == true) then 
            moveObject(gate, 2500, -2176.5, 1009.3994140625, 82.599998474121, 0, 0, 0 ) 
            megusta = false 
    else 
        outputChatBox( "you're not a member of the West Coast Cribs!", source, 0, 255, 0, true ) 
        end 
    end 
end) 

local gate = createObject(971, -2191.2998046875, 1009.3994140625, 82.599998474121, 0, 0, 0) 
megusta = false 
  
addCommandHandler("gate", 
function (source) 
    if ( getTeamName ( getPlayerTeam ( source ) ) == "West Coast Cribs" ) then 
        if (megusta == false) then 
            moveObject(gate, 2500, -2191.2998046875, 1009.3994140625, 82.599998474121, 0, 0, 0 ) 
            megusta = true 
        elseif (megusta == true) then 
            moveObject(gate, 2500, -2198.2998046875, 1009.3994140625, 82.599998474121, 0, 0, 0 ) 
            megusta = false 
    else 
        outputChatBox( "you're not a member of the West Coast Cribs!", source, 0, 255, 0, true ) 
        end 
    end 
end) 

I want they both to open when I write /gate

Thanks,

Greetings Billy

Link to comment
-- Try this 
gate1 = createObject(971, -2182.5, 1009.3994140625, 82.599998474121, 0, 0, 0) 
gate2 = createObject(971, -2191.2998046875, 1009.3994140625, 82.599998474121, 0, 0, 0) 
megusta = false 
  
addCommandHandler ( "gate", 
    function ( source ) 
        if ( getPlayerTeam ( source ) == getTeamFromName ( "West Coast Cribs" ) ) then 
            if ( megusta ~= true ) then 
                moveObject ( gate1, 2500, -2182.5, 1009.3994140625, 82.599998474121 ) 
                moveObject ( gate2, 2500, -2191.2998046875, 1009.3994140625, 82.599998474121 ) 
                megusta = true 
            else 
                moveObject ( gate1, 2500, -2176.5, 1009.3994140625, 82.599998474121 ) 
                moveObject ( gate2, 2500, -2198.2998046875, 1009.3994140625, 82.599998474121 ) 
                megusta = false 
            end 
        else 
            outputChatBox( "you're not a member of the West Coast Cribs!", source, 0, 255, 0, true ) 
        end 
    end 
) 

Link to comment

Also here;

local gate = createObject(971, -1530.1999511719, 482.20001220703, 8.8000001907349, 0, 0, 0) 
megusta = false 
  
addCommandHandler("gate", 
function (source) 
    if ( getTeamName ( getPlayerTeam ( source ) ) == "Army" ) then 
        if (megusta == false) then 
            moveObject(gate, 2500, -1530.1999511719, 482.20001220703, 1.9, 0, 0, 0 ) 
            megusta = true 
        elseif (megusta == true) then 
            moveObject(gate, 2500, -1530.1999511719, 482.20001220703, 8.8000001907349, 0, 0, 0 ) 
            megusta = false 
    else 
        outputChatBox( "you're not a member of the Army!", source, 0, 255, 0, true ) 
        end 
    end 
end) 

It's possible to open this only as Army know but i want the MP also be able to open it

Link to comment
Maybe
    if ( getTeamName ( getPlayerTeam ( source ) ) == "Army" or "MP" ) then 

Wrong.

aTeamName =  
{ 
    [ 'Army' ] = true ; 
    [ 'MP' ] = true ; 
} 
  
if aTeamName[ getTeamName( getPlayerTeam( source ) ) ] then 
 -- etc.. 
end 

Edited by Guest
Link to comment

This in Complete?

aTeamName = 
{ 
    [ 'Army' ] = true ; 
    [ 'MP' ] = true ; 
} 
  
if aTeamName[ getTeamName( getPlayerTeam( source ) ) ] then 
local gate = createObject(971, -1530.1999511719, 482.20001220703, 8.8000001907349, 0, 0, 0) 
megusta = false 
  
addCommandHandler("gate", 
function (source) 
    if ( getTeamName ( getPlayerTeam ( source ) ) == "Army" ) then 
        if (megusta == false) then 
            moveObject(gate, 2500, -1530.1999511719, 482.20001220703, 1.9, 0, 0, 0 ) 
            megusta = true 
        elseif (megusta == true) then 
            moveObject(gate, 2500, -1530.1999511719, 482.20001220703, 8.8000001907349, 0, 0, 0 ) 
            megusta = false 
    else 
        outputChatBox( "you're not a member of the Army!", source, 0, 255, 0, true ) 
        end 
    end 
end) 
end 

Correct me if i'm wrong

Link to comment
aTeamName = 
{ 
    [ 'Army' ] = true ; 
    [ 'MP' ] = true ; 
} 
  
local gate = createObject(971, -1530.1999511719, 482.20001220703, 8.8000001907349, 0, 0, 0) 
megusta = false 
  
addCommandHandler("gate", 
    function (source) 
        if aTeamName[ getTeamName( getPlayerTeam( source ) ) ] then 
            if (megusta == false) then 
                moveObject(gate, 2500, -1530.1999511719, 482.20001220703, 1.9, 0, 0, 0 ) 
                megusta = true 
            elseif (megusta == true) then 
                moveObject(gate, 2500, -1530.1999511719, 482.20001220703, 8.8000001907349, 0, 0, 0 ) 
                megusta = false 
        else 
            outputChatBox( "you're not a member of the Army!", source, 0, 255, 0, true ) 
            end 
        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...