Jump to content

close/open door with a command private


Thivenin

Recommended Posts

hai, I need again help.... like everyday ^^

local allowedTeams = {  
["USOC Member"] = true 
} 
  
firstObject = createObject ( 974, 1153.8, -1766.09, 18.39 ) 
secoundObject = createObject ( 974, 1154.69, -1766.09, 18.39 ) 
local open = false 
  
function USOCDoor () 
local playerTeam = getPlayerTeam ( source ) 
    if getTeamName ( playerTeam ) == "USOC Member" then 
        if open then  
            moveObject ( firstObject, 3000, 1153.8, -1766.09, 18.39 ) 
            moveObject ( secoundObject, 3000, 1154.69, -1766.09, 18.39 ) 
            open = true 
        else if not open then 
                  moveObject ( firstObject, 3000, 1153.8, -1766.09, 0 ) 
                  moveObject ( secoundObject, 3000, 1154.69, -1766.09, 0 ) 
             end 
        end 
    end 
end 
  
addCommandHandler ( "USOCdoor", USOCDoor ) 

that should open/close the door if we do /USOCdoor and only if we are in USOC Member team

but I have 2 error :

Bad argument @ 'getPlayerTeamName'

Bad argument @ 'getTeamName'

I tried alot of thing, nothing working :(

Link to comment

Try this.

local allowedTeams = {  
["USOC Member"] = true 
} 
  
firstObject = createObject ( 974, 1153.8, -1766.09, 18.39 ) 
secoundObject = createObject ( 974, 1154.69, -1766.09, 18.39 ) 
local open = false 
  
function USOCDoor () 
local playerTeam = getPlayerTeam ( source ) 
    if (getTeamName ( playerTeam ) == "USOC Member") then 
        if open then  
            moveObject ( firstObject, 3000, 1153.8, -1766.09, 18.39 ) 
            moveObject ( secoundObject, 3000, 1154.69, -1766.09, 18.39 ) 
            open = true 
        else if not open then 
                  moveObject ( firstObject, 3000, 1153.8, -1766.09, 0 ) 
                  moveObject ( secoundObject, 3000, 1154.69, -1766.09, 0 ) 
             end 
        end 
    end 
end 
  
addCommandHandler ( "USOCdoor", USOCDoor ) 

Link to comment
local allowedTeams =  
    { 
        [ "USOC Member" ] = true 
    } 
  
firstObject = createObject ( 974, 1153.8, -1766.09, 18.39 ) 
secoundObject = createObject ( 974, 1154.69, -1766.09, 18.39 ) 
local open = false 
  
function USOCDoor ( source ) 
    local team = getPlayerTeam ( source ) 
    if ( team and allowedTeams [ getTeamName ( team ) ] ) then 
        if ( open ) then 
            moveObject ( firstObject, 3000, 1153.8, -1766.09, 18.39 ) 
            moveObject ( secoundObject, 3000, 1154.69, -1766.09, 18.39 ) 
            open = false 
        else 
            moveObject ( firstObject, 3000, 1153.8, -1766.09, 0 ) 
            moveObject ( secoundObject, 3000, 1154.69, -1766.09, 0 ) 
            open = true 
        end 
    end 
end 
addCommandHandler ( "USOCdoor", USOCDoor ) 

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