CreateTeam: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 14: Line 14:


===Returns===
===Returns===
Returns a team object if it was successfully created, 'false' otherwise.
Returns a team element if it was successfully created, 'false' otherwise.


==Example==
==Example==
This example creates a new team for a player, then adds him to it.
'''Example 1:''' This example creates a new team for a player, then adds him to it.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler ( "gimmeATeam", "gimmeATeam" )
addCommandHandler ( "gimmeATeam", "gimmeATeam" )
Line 26: Line 26:
   end
   end
end
end
</syntaxhighlight>
'''Example 2:''' This example creates two teams, one for grove and one for ballas, when the resource is started.
<syntaxhighlight lang="lua">
function createTeamsOnStart ( resource )
teamGrove = createTeam ( "grove", 0,255,0 )
teamBallas = createTeam ( "ballas", 200, 0, 100 )
end
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart  )
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 22:16, 15 July 2007

This function is for creating a new team, which can be used to group players.

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' otherwise.

Example

Example 1: This example creates a new team for a player, then adds him to it.

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

Example 2: This example creates two teams, one for grove and one for ballas, when the resource is started.

function createTeamsOnStart ( resource )
	teamGrove = createTeam ( "grove", 0,255,0 )
	teamBallas = createTeam ( "ballas", 200, 0, 100 )
end
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart  )

See Also