SetTeamFriendlyFire: Difference between revisions

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


===Required Arguments===  
===Required Arguments===  
*'''theTeam:''' The team that will have friendly fire set
*'''theTeam:''' The [[team]] that will have friendly fire set
*'''friendlyFire:''' The friendly fire value
*'''friendlyFire:''' A boolean denoting whether friendly fire is on (''true'') or off (''false'').


===Returns===
===Returns===
Line 18: Line 18:
This example checks if friendly fire is on for every team, and toggles it on if it isn't.
This example checks if friendly fire is on for every team, and toggles it on if it isn't.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- get a table with all teams
local allTeams = getElementsByType ( "team" )
-- for every team,
-- for every team,
for index, theTeam in getElementsByType ( "team" ) do
for index, theTeam in ipairs(allTeams) do
-- if friendly fire is off,
-- if friendly fire is off,
if ( getTeamFriendlyFire ( theTeam ) == false ) then
if ( getTeamFriendlyFire ( theTeam ) == false ) then

Revision as of 17:13, 26 August 2007

This function sets the friendly fire value for the specified team.

Syntax

bool setTeamFriendlyFire ( team theTeam , bool friendlyFire )

Required Arguments

  • theTeam: The team that will have friendly fire set
  • friendlyFire: A boolean denoting whether friendly fire is on (true) or off (false).

Returns

Returns true if the friendly fire value is set for the specified team, false if the friendly fire value can't be set for the specified team or if invalid arguments are specified.

Example

This example checks if friendly fire is on for every team, and toggles it on if it isn't.

-- get a table with all teams
local allTeams = getElementsByType ( "team" )
-- for every team,
for index, theTeam in ipairs(allTeams) do
	-- if friendly fire is off,
	if ( getTeamFriendlyFire ( theTeam ) == false ) then
		-- switch it on
		setTeamFriendlyFire ( theTeam, true )
	end
end

See Also

Shared