RemovePlayerFromTeam: Difference between revisions

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


==Example==
==Example==
This example creates a new team for a player, adds him to it, then removes him.
This example adds two new commands in console.  One to create a new team for a player, and another to remove the player from that team
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function gimmeATeam ( source, key, teamName )
function gimmeATeam ( source, key, teamName )
Line 21: Line 21:
     if ( newTeam ) then                      -- if it was successfully created
     if ( newTeam ) then                      -- if it was successfully created
         addPlayerToTeam ( source, newTeam )  -- add the player to the new team
         addPlayerToTeam ( source, newTeam )  -- add the player to the new team
    end
end
addCommandHandler ( "gimmeateam", gimmeATeam )
function removeMyTeam ( source, key, teamName )
    local myTeam = getPlayerTeam ( source )--get his team
    if ( myTeam ) then --if he does have a team
         removePlayerFromTeam ( source )      -- remove him from the team
         removePlayerFromTeam ( source )      -- remove him from the team
        destroyElement ( myTeam ) --destroy his team
     end
     end
end
end
addCommandHandler ( "gimmeateam", gimmeATeam )
addCommandHandler ( "removemyteam", removeMyTeam )
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 15:47, 30 August 2007

This function is for removing a player from his current team.

Syntax

bool removePlayerFromTeam ( player thePlayer )

Required Arguments

  • thePlayer: The player you wish to remove from his team.

Returns

Returns true if the player was on a team and was successfully removed it, false otherwise.

Example

This example adds two new commands in console. One to create a new team for a player, and another to remove the player from that team

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

function removeMyTeam ( source, key, teamName )
    local myTeam = getPlayerTeam ( source )--get his team
    if ( myTeam ) then --if he does have a team
        removePlayerFromTeam ( source )      -- remove him from the team
        destroyElement ( myTeam ) --destroy his team
    end
end
addCommandHandler ( "removemyteam", removeMyTeam )

See Also

Shared