CreateTeam: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
Jay Deshaun (talk | contribs) |
||
Line 29: | Line 29: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
'''Example 2:''' This example creates two teams, one for | '''Example 2:''' This example creates two teams, one for Admin and one for Freeroamers, when the resource this script is in is started. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function createTeamsOnStart () | function createTeamsOnStart () | ||
teamAdmmin = createTeam ( "Admin", 0, 255, 0 ) --change the 3 numbers(0,255,0), the first number is ColourR, the second is ColourG, and the last one is ColourB | |||
teamFreeroamers = createTeam ( "Freeroamer", 200, 0, 100 ) | |||
end | end | ||
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) --we attach the function to this resource's root element | addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) --we attach the function to this resource's root element |
Revision as of 20:00, 15 March 2011
This function is for creating a new team, which can be used to group players. Players will not join the team until they are respawned.
Syntax
team createTeam ( string teamName, [int colorR = 255, int colorG = 255, int colorB = 255] )
Required Arguments
- teamName: A string representing the teams name.
- colorR: An integer representing the red color value.
- colorG: An integer representing the green color value.
- colorB: An integer representing the blue color value.
Returns
Returns a team element if it was successfully created, false if invalid arguments are passed or a team with that name already exists.
Example
Example 1: This example creates a new team for a player, then adds him to it.
function gimmeATeam ( source, commandName, teamName ) local newTeam = createTeam ( teamName ) -- create a new team with the specified name if newTeam then -- if it was successfully created setPlayerTeam ( source, newTeam ) -- add the player to the new team end end addCommandHandler ( "giveteam", gimmeATeam )
Example 2: This example creates two teams, one for Admin and one for Freeroamers, when the resource this script is in is started.
function createTeamsOnStart () teamAdmmin = createTeam ( "Admin", 0, 255, 0 ) --change the 3 numbers(0,255,0), the first number is ColourR, the second is ColourG, and the last one is ColourB teamFreeroamers = createTeam ( "Freeroamer", 200, 0, 100 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) --we attach the function to this resource's root element
See Also
- countPlayersInTeam
- getPlayerTeam
- getPlayersInTeam
- getTeamColor
- getTeamFriendlyFire
- getTeamFromName
- getTeamName