Skip to content

SetPlayerTeam

Puts the player in a team - teammates cannot hurt each other.

Any number is a team; NO_TEAM (-1) is none. A hit between two players of one team is refused before OnPlayerDamage and starts no fight. Nothing else is implied - no colour, no label, no spawn: those are the mode’s to set alongside. A mode that wants friendly fire back writes its rule in OnPlayerDamage and leaves teams unset.

SetPlayerTeam(pid, team)
Parameter Type
pid number the player
team number the team; NO_TEAM (-1) = none

boolean - false when not connected

local function join(pid, team)
SetPlayerTeam(pid, team)
SetPlayerColour(pid, team == 1 and 0xFF4040FF or 0x4080FFFF)
SetPlayerState(pid, "team", team) -- the client scripts read KcdMp.state.player[pid].team
end

GetPlayerTeam · SetPlayerColour · OnPlayerDamage · SetPlayerState · the Players group of the index