setPlayerTeam | Multi Theft Auto: Wiki Skip to content

setPlayerTeam

Client-side
Server-side
Shared

Pair: getPlayerTeam

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function adds a player to an existing team. The player will automatically be removed from his current team if he's on one.

Syntax

setPlayerTeam ( )

Code Examples

server

This example adds a command to create a new team for a player, then add him to it. It also adds a command to remove him from his team.

function assignNewTeam ( source, commandName, teamName )
local theTeam = createTeam ( teamName ) -- create a new team with the specified name
if theTeam then -- if it was successfully created
setPlayerTeam ( source, theTeam ) -- add the player to the new team
end
end
addCommandHandler ( "gimmeateam", assignNewTeam )
function unassignTeam ( source, commandName )
local theTeam = getPlayerTeam ( source ) -- Check if the player is on a team
if theTeam then -- this player is on a team, so we can remove them from it
setPlayerTeam ( source, nil ) -- remove the player from the current team
end
end
addCommandHandler ( "takeawaymyteam", unassignTeam )

See Also