GetTeamName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 11: Line 11:
*'''theTeam:''' الفريق اللي تبي تستخرج اسمه
*'''theTeam:''' الفريق اللي تبي تستخرج اسمه


==مــثــال==
==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 (playerTeam) then -- if he was on a team
         outputChatBox(getPlayerName(source).." في فريق : "..getTeamName(playerTeam))
         outputChatBox(getPlayerName(source).." is on team: "..getTeamName(playerTeam))
     else -- اما اذا كان ماهو بفريق
     else
         outputChatBox(getPlayerName(source).. " ليس بأي فريق ")
         outputChatBox(getPlayerName(source).. " isn't on a team")
     end
     end
end
end


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

Revision as of 07:06, 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


الحجج المطلوبة

  • theTeam: الفريق اللي تبي تستخرج اسمه

Example

This example gets the current team of a player, then prints its name to the chatbox.

function whatTeamAmIOn (source)
    -- Get the player's team (source is the player who entered the command)
    local playerTeam = getPlayerTeam(source)
  
    if (playerTeam) then -- if he was on a team
        outputChatBox(getPlayerName(source).." is on team: "..getTeamName(playerTeam))
    else
        outputChatBox(getPlayerName(source).. " isn't on a team")
    end
end

-- Add console command to find your team when 'whatTeamAmIOn' is typed.
addCommandHandler("whatTeamAmIOn", whatTeamAmIOn)

مـشـابهــه