GetTeamName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(OOP syntax added)
Line 14: Line 14:
Returns a string representing the team's name if the team object was valid, ''false'' otherwise.
Returns a string representing the team's name if the team object was valid, ''false'' otherwise.


==Example==
==مــثــال==
This example gets the current team of a player, then prints its name to the chatbox.
هذا المثال يحصل على فريق اللاعب ويقوم بإرساله في الشات
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function whatTeamAmIOn (source)
function whatTeamAmIOn (source)
     -- Get the player's team (source is the player who entered the command)
     -- تحصل على الفريق من المصدر اللي هو اللاعب
     local playerTeam = getPlayerTeam(source)
     local playerTeam = getPlayerTeam(source)
    
    
     if (playerTeam) then -- if he was on a team
     if (playerTeam) then -- اذا كان في فريق
         outputChatBox(getPlayerName(source).." is on team: "..getTeamName(playerTeam))
         outputChatBox(getPlayerName(source).." في فريق : "..getTeamName(playerTeam))
     else
     else -- اما اذا كان ماهو بفريق
         outputChatBox(getPlayerName(source).. " isn't on a team")
         outputChatBox(getPlayerName(source).. " ليس بأي فريق ")
     end
     end
end
end


-- Add console command to find your team when 'whatTeamAmIOn' is typed.
-- يعمل عند كتابة الامر التالي "whatTeamAmIOn"
addCommandHandler("whatTeamAmIOn", whatTeamAmIOn)
addCommandHandler("whatTeamAmIOn", whatTeamAmIOn)
</syntaxhighlight>
</syntaxhighlight>

Revision as of 06:59, 13 July 2019

This function gets the team name of a team object.

Syntax

string getTeamName ( team theTeam )

OOP Syntax Help! I don't understand this!

Method: team:getName(...)
Variable: .name
Counterpart: setTeamName


Required Arguments

  • theTeam: The team you want to retrieve the name of.

Returns

Returns a string representing the team's name if the team object was valid, false otherwise.

مــثــال

هذا المثال يحصل على فريق اللاعب ويقوم بإرساله في الشات

function whatTeamAmIOn (source)
    -- تحصل على الفريق من المصدر اللي هو اللاعب
    local playerTeam = getPlayerTeam(source)
  
    if (playerTeam) then -- اذا كان في فريق
        outputChatBox(getPlayerName(source).." في فريق : "..getTeamName(playerTeam))
    else -- اما اذا كان ماهو بفريق
        outputChatBox(getPlayerName(source).. " ليس بأي فريق ")
    end
end

-- يعمل عند كتابة الامر التالي "whatTeamAmIOn"
addCommandHandler("whatTeamAmIOn", whatTeamAmIOn)

See Also