Jump to content

[HELP]2 Gates / 1 Command


ViRuZGamiing

Recommended Posts

Posted

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

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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

Posted

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

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted (edited)
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

╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗

║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║

║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║

║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║

╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝

«سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك»

M7mdAl7arthy : لتواصل سكايب

Posted

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

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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

╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗

║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║

║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║

║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║

╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝

«سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك»

M7mdAl7arthy : لتواصل سكايب

Posted

Problem solve the "Army" or "MP" worked,

Thanks to keep it short "α7мα∂qтя"

@3ɑsн8 ɑʟsнɾq why you said it was wrong? You didn't try it

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted
if 'H' == 'S' or 'M' then 
    print( 'true' ) 
else 
    print( 'false' ) 
end 

Because this always return 'true', Although not equal.

╔═╦╦╦╗╔╦═╦═╦═╦═╦╦╦╦╦╦╦═╦╦╦╦╗

║║║║║╠╝║║╚╣║║║║║║║║║║║║║║║║║

║║║║║╚╦╦═╦╦╦╦╣║║║║║║║║║║║║║║

║║║║╠═╣╠╝╔══╝║║║║║╟╢║║║║║╟╢║

╚╩══╩══╩═╩═══╩╩══╩╩═╩╩╩═╩╩═╝

«سبحانك اللهم وبحمدك أشهد أن لا إله إلا أنت أستغفرك وأتوب إليك»

M7mdAl7arthy : لتواصل سكايب

Posted
Maybe
    if ( getTeamName ( getPlayerTeam ( source ) ) == "Army" or "MP" ) then 

should be

local TeamName = getTeamName(getPlayerTeam(source)) 
if (TeamName == "Army") or (TeamName == "MP") then 

CiTLh.png

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