ZH-CN/GetAccountName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Server function}} __NOTOC__ This function retrieves the name of an account. ==Syntax== <syntaxhighlight lang="lua"> string getAccountName ( account theAccount ) </synt...")
 
No edit summary
Line 1: Line 1:
{{Server function}}
{{Server function}}
__NOTOC__
__NOTOC__
This function retrieves the name of an [[account]].
此函数用于获取帐户[[account]]的名称.


==Syntax==  
==语法==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getAccountName ( account theAccount )
string getAccountName ( account theAccount )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[account]]:getName|name|}}
{{OOP_ZH-CN||[[account]]:getName|name|}}
===Required Arguments===  
===必填函数===  
*'''theAccount:''' The account you wish to get the name of.
*'''theAccount:''' 你希望获得的帐户名称.


===Returns===
===Returns===
Returns a string containing the account's name, ''false'' if the account does not exist or an invalid argument was passed to the function.
如果帐户不存在或传递给函数的参数无效,则返回包含帐户名“false”的字符串.


==Example==  
==示例==  
This example announces into the console when a player logs into his account.
当一个玩家登录到他的帐户时,这个例子在控制台中显示.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function outputOnLogin ( previous_account, current_account, auto_login ) --when a player logs in
function outputOnLogin ( previous_account, current_account, auto_login ) --当玩家登陆时
outputConsole(getAccountName(previous_account).." Logged into "..getAccountName(current_account)) -- announce it into the console
outputConsole(getAccountName(previous_account).." Logged into "..getAccountName(current_account)) -- 在控制台上显示
end
end
addEventHandler("onPlayerLogin",root,outputOnLogin ) --add an event handler
addEventHandler("onPlayerLogin",root,outputOnLogin ) --添加事件处理程序
</syntaxhighlight>
</syntaxhighlight>



Revision as of 03:52, 4 February 2021

此函数用于获取帐户account的名称.

语法

string getAccountName ( account theAccount )

OOP 语法 什么是OOP?

方法: account:getName(...)
变量: .name

必填函数

  • theAccount: 你希望获得的帐户名称.

Returns

如果帐户不存在或传递给函数的参数无效,则返回包含帐户名“false”的字符串.

示例

当一个玩家登录到他的帐户时,这个例子在控制台中显示.

function outputOnLogin ( previous_account, current_account, auto_login ) --当玩家登陆时
	outputConsole(getAccountName(previous_account).." Logged into "..getAccountName(current_account)) -- 在控制台上显示
end
addEventHandler("onPlayerLogin",root,outputOnLogin ) --添加事件处理程序

See Also