Jump to content

[HELP]Leave Team


ViRuZGamiing

Recommended Posts

Hello Community,

Here's my script:

addEventHandler("onResourceStart",resourceRoot,function () 
     newTeam = createTeam ( "Police" , 0, 255 , 0 ) 
end) 
  
addCommandHandler("joinPD", function(source) 
     if not newTeam then outputChatBox("Team couldn't be created!") return end 
     if getPlayerTeam(source) == newTeam then 
           outputChatBox("You are already a Police Officer!") 
      else 
           setPlayerTeam(source,newTeam) 
           setElementModel(source,284) 
           giveWeapon ( source, 4, 1 ) 
           outputChatBox("Now you are a Police Officer!") 
      end 
end) 

My Problem:

I want to make a command /leavePD because when I write /joinPD i've joined but when I do /joinArmy after /joinPD i'm in both teams.

Greetings Billy

Link to comment
-- Try This 
createTeam ( "Police" , 0, 255 , 0 ) 
  
addCommandHandler ( "joinPD", 
    function ( source ) 
        local theTeam = getTeamFromName ( "Police" ) 
        if not theTeam then outputChatBox ( "Team couldn't be created!" ) return end 
        if getPlayerTeam ( source ) == theTeam then 
            outputChatBox ( "* You are already a Police Officer !", source, 255, 0, 0, true ) 
        else 
           setPlayerTeam ( source, theTeam ) 
           setElementModel ( source, 284 ) 
           giveWeapon ( source, 4, 1 ) 
           outputChatBox ( "* Now you are a Police Officer !", source, 0, 255, 0, true ) 
        end 
    end 
)  
  
addCommandHandler ( "leavePD", 
    function ( source ) 
        local theTeam = getTeamFromName ( "Police" ) 
        if getPlayerTeam ( source ) == theTeam then 
            setPlayerTeam ( source, nil ) 
            outputChatBox ( "* You Left the PD !", source, 0, 255, 0, true ) 
        else 
           outputChatBox ( "* You're not at PD !", source, 255, 0, 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...