ZH-CN/GetAccountIP: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Server function}} __NOTOC__ {{New feature/item|3.0160|1.5.5|11747| This function retrieves the IP address of an account. }} ==Syntax== <syntaxhighlight lang="lua"> str...")
 
No edit summary
Line 2: Line 2:
__NOTOC__
__NOTOC__
{{New feature/item|3.0160|1.5.5|11747|
{{New feature/item|3.0160|1.5.5|11747|
This function retrieves the IP address of an [[account]].
此函数用于获取[[帐户]]的IP地址.
}}
}}


==Syntax==  
==语法==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getAccountIP ( account theAccount )
string getAccountIP ( account theAccount )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[account]]:getIP|ip|}}
{{OOP_ZH-CN||[[account]]:getIP|ip|}}
===Required Arguments===  
===Required Arguments===  
*'''theAccount:''' The [[account]] you wish to get the IP of.
*'''theAccount:''' 您希望获得的IP的[[帐户]].


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


==Example==  
==示例==  
This example announces into the debugscript when a player logs into his account.
当一个玩家登录到他的帐户时,这个例子会在debugscript中声明.
<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 ) --当玩家登录时
outputDebugString(getPlayerName(source) .. " logged into his account with IP " .. getAccountIP(current_account)) -- announce it into the debugscript
outputDebugString(getPlayerName(source) .. " logged into his account with IP " .. getAccountIP(current_account)) -- 将其公布到debugscript中
end
end
addEventHandler("onPlayerLogin", getRootElement(), outputOnLogin) --add an event handler
addEventHandler("onPlayerLogin", getRootElement(), outputOnLogin) --添加事件处理程序
</syntaxhighlight>
</syntaxhighlight>



Revision as of 08:49, 4 February 2021

此函数用于获取帐户的IP地址.

语法

string getAccountIP ( account theAccount )

OOP 语法 什么是OOP?

方法: account:getIP(...)
变量: .ip

Required Arguments

  • theAccount: 您希望获得的IP的帐户.

Returns

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

示例

当一个玩家登录到他的帐户时,这个例子会在debugscript中声明.

function outputOnLogin ( previous_account, current_account, auto_login ) --当玩家登录时
	outputDebugString(getPlayerName(source) .. " logged into his account with IP " .. getAccountIP(current_account)) -- 将其公布到debugscript中
end
addEventHandler("onPlayerLogin", getRootElement(), outputOnLogin) --添加事件处理程序

See Also