Jump to content

remove a player from team?


Recommended Posts

here you go. :)

playerTeam = getPlayerTeam ( source ) -- gets the current players team 
if ( playerTeam ) then --checks if the player is in a team by checking if playerTeam returned true 
        setPlayerTeam ( source, nil ) -- set the players team to nil (no team ). 
end 

edit: now that I think about it, the wiki has an example of this for setPlayerTeam... http://development.mtasa.com/index.php? ... PlayerTeam

Link to comment

Hi, i have a other question. Thats a little bit off-topic but i don´t want to create a new topic for this:

currently i tried to script a chat command "jointeam [name]". So wen a player types "jointeam testteam" in the chat, he gets in the team "testteam".

but it don´t work, i don´t joins the team.

Here is the code:

  
function assignNewTeam ( source, commandName, teamName ) 
    setPlayerTeam ( source, teamName )    -- add the player to a team 
    outputChatBox ( "test", source, 128, 206, 206 )  
end 
 addCommandHandler ( "team", assignNewTeam ) 
  

But i gets the outputChatBox "test", so the script are called. I don´t get any warnings, infos or errors with /debugscript 3

Any ideas pleas? :)

Link to comment

this is mi command for join in a team ;D.

  
function jointeam ( playerSource, commandName) 
       setPlayerTeam(playerSource, teamDm) 
end 
addCommandHandler ("jointeam", jointeam ) 

but you need this definitons and events.

team = {} 
teamDm = nil 
  

function createTeamsOnStart () 
teamDm = createTeam ( "Deathmach", 200, 0, 100 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart  )  

Link to comment

No, thats not waht i want, but thanks for help.

I don´t want to sing out my script now, but i tried to create a dynamic command, so you can write team lol or team yeaateam - everything.

I don´t want creates a team with the script, there should be dynamic teams. I just need a script to gets this command working: team anyteamnamehere

but this don´t work:

  
function assignNewTeam ( source, commandName, teamName ) 
    setPlayerTeam ( source, teamName )    -- add the player to a team 
    outputChatBox ( "test", source, 128, 206, 206 ) 
end 
 addCommandHandler ( "team", assignNewTeam ) 
  

Any ideas?

Link to comment

Like this:

  
function assignNewTeam ( source, commandName, teamName ) 
    local team = getTeamFromName(teamName) 
  
    if team then 
        setPlayerTeam ( source, team )    -- add the player to a team 
        outputChatBox ( "test", source, 128, 206, 206 ) 
    end 
end 
  
addCommandHandler ( "team", assignNewTeam ) 
  

This relies on the player entering the EXACT name of the team. Alternatively you could do partial team name matches (e.g. "race" for "Mad Racing") by spinning a loop through all "team" elements and doing you own string comparisons of the team name - getTeamName().

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