SetTeamFriendlyFire: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (→See Also) |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | |||
This function sets the friendly fire value for the specified team. | This function sets the friendly fire value for the specified team. | ||
Line 6: | Line 7: | ||
bool setTeamFriendlyFire ( team theTeam , bool friendlyFire ) | bool setTeamFriendlyFire ( team theTeam , bool friendlyFire ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[team]]:setFriendlyFire|friendlyFire|getTeamFriendlyFire}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theTeam:''' The team that will have friendly fire set | *'''theTeam:''' The [[team]] that will have friendly fire set | ||
*'''friendlyFire:''' | *'''friendlyFire:''' A boolean denoting whether the players from the same team can kill each other (''true'') or whether the players can't kill each other (''false''). | ||
===Returns=== | ===Returns=== | ||
Line 17: | 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"> | ||
--for every team, | -- get a table with all teams | ||
for index, theTeam in | local allTeams = getElementsByType ( "team" ) | ||
--if friendly fire is off, | -- for every team, | ||
for index, theTeam in ipairs(allTeams) do | |||
-- if friendly fire is off, | |||
if ( getTeamFriendlyFire ( theTeam ) == false ) then | if ( getTeamFriendlyFire ( theTeam ) == false ) then | ||
--switch it on | -- switch it on | ||
setTeamFriendlyFire ( theTeam, true ) | setTeamFriendlyFire ( theTeam, true ) | ||
end | end | ||
Line 28: | Line 31: | ||
==See Also== | ==See Also== | ||
{{ | {{Team_functions|server}} |
Latest revision as of 23:02, 6 September 2024
This function sets the friendly fire value for the specified team.
Syntax
bool setTeamFriendlyFire ( team theTeam , bool friendlyFire )
OOP Syntax Help! I don't understand this!
- Method: team:setFriendlyFire(...)
- Variable: .friendlyFire
- Counterpart: getTeamFriendlyFire
Required Arguments
- theTeam: The team that will have friendly fire set
- friendlyFire: A boolean denoting whether the players from the same team can kill each other (true) or whether the players can't kill each other (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
- createTeam
- setPlayerTeam
- setTeamColor
- setTeamFriendlyFire
- setTeamName
- Shared
- countPlayersInTeam
- getPlayerTeam
- getPlayersInTeam
- getTeamColor
- getTeamFriendlyFire
- getTeamFromName
- getTeamName