RemovePlayerFromTeam: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
{{Server function}}
__NOTOC__
__NOTOC__
This function is for removing a player from his current team.
This function is for removing a player from his current team.
Line 11: Line 12:


===Returns===
===Returns===
Returns 'true' if the player was on a team and was successfully removed it, 'false' otherwise.
Returns ''true'' if the player was on a team and was successfully removed it, ''false'' otherwise.


==Example==
==Example==
This example creates a new team for a player, adds him to it, then removes him.
This example creates a new team for a player, adds him to it, then removes him.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler ( "gimmeATeam", "gimmeATeam" )
function gimmeATeam ( source, key, teamName )
function gimmeATeam ( source, key, teamName )
  team = createTeam ( teamName ) -- create a new team with the specified name
    local newTeam = createTeam ( teamName ) -- create a new team with the specified name
  if ( team ) then -- if it was successfully created
    if ( newTeam ) then                     -- if it was successfully created
    addPlayerToTeam ( source, team ) -- add the player to the new team
        addPlayerToTeam ( source, newTeam ) -- add the player to the new team
    removePlayerFromTeam ( source ) -- remove him from the team
        removePlayerFromTeam ( source )     -- remove him from the team
  end
    end
end
end
addCommandHandler ( "gimmeateam", gimmeATeam )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Team_functions}}
{{Team_functions}}

Revision as of 17:40, 16 August 2007

This function is for removing a player from his current team.

Syntax

bool removePlayerFromTeam ( player thePlayer )

Required Arguments

  • thePlayer: The player you wish to remove from his team.

Returns

Returns true if the player was on a team and was successfully removed it, false otherwise.

Example

This example creates a new team for a player, adds him to it, then removes him.

function gimmeATeam ( source, key, teamName )
    local newTeam = createTeam ( teamName )  -- create a new team with the specified name
    if ( newTeam ) then                      -- if it was successfully created
        addPlayerToTeam ( source, newTeam )  -- add the player to the new team
        removePlayerFromTeam ( source )      -- remove him from the team
    end
end
addCommandHandler ( "gimmeateam", gimmeATeam )

See Also

Shared