ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. createTeam

Function

createTeam

ServerTeamsIdentical to MTA:SA

Creates a team. The name must be unique. Teams group players, and their colour shows on the player list and above heads.

Syntax

team createTeam(string teamName [, int r = 235, int g = 235, int b = 235])

Arguments

teamNamestring
The team name.
rint, optional = 235
Red 0-255.
gint, optional = 235
Green 0-255.
bint, optional = 235
Blue 0-255.

Returns

The team, or false when the name is empty or taken.

Example

Two teams, with new players joining the smaller one.

local police = createTeam("Policja", 40, 90, 255)
local gang = createTeam("Grove", 30, 200, 60)

addEventHandler("onPlayerJoin", root, function()
    if countPlayersInTeam(police) <= countPlayersInTeam(gang) then
        setPlayerTeam(source, police)
    else
        setPlayerTeam(source, gang)
    end
end)

See also