ZH-CN/logIn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server function}} This functions logs the given player in to the given account. You need to provide the password needed to log into that account. ==Syntax==...")
 
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}
{{Server function}}
This functions logs the given player in to the given [[account]]. You need to provide the password needed to log into that account.
此函数用于将给定的玩家登录到给定的帐户.您需要提供登录该帐户所需的密码.


==Syntax==  
==语法==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool logIn ( player thePlayer, account theAccount, string thePassword )
bool logIn ( player thePlayer, account theAccount, string thePassword )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[player]]:logIn||logOut}}
{{OOP_ZH-CN||[[player]]:logIn||logOut}}


===Required Arguments===  
===必填参数===  
*'''thePlayer:''' The player to log into an account
*'''thePlayer:''' 登录账户的玩家
*'''theAccount:''' The account to log the player into
*'''theAccount:''' 要登录的账户
*'''thePassword:''' The password needed to sign into this account
*'''thePassword:''' 登录此帐户所需的密码


===Returns===
===Returns===
Returns ''true'' if the player was successfully logged into the given account. Returns ''false'' or ''nil'' if the log in failed for some reason, ie. the player was already logged in to some account (use [[logOut]] first), if the account was already in use or if it failed for some other reason.
如果玩家成功登录到给定帐户,则返回“true”。如果由于某种原因登录失败,即玩家已经登录到某个帐户(首先使用[[logOut]]),如果该帐户已经在使用中或由于其他原因失败,则返回“false”或“nil”


==Example==  
==示例==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function loginPlayer ( thePlayer, command, username, password )
function loginPlayer ( thePlayer, command, username, password )
local account = getAccount ( username, password ) -- Return the account
local account = getAccount ( username, password ) -- 返回账户
if ( account ~= false ) then -- If the account exists.
if ( account ~= false ) then -- If the account exists.
logIn ( thePlayer, account, password ) -- Log them in.
logIn ( thePlayer, account, password ) -- 让他们登录.
else
else
outputChatBox ( "Wrong username or password!", thePlayer, 255, 255, 0 ) -- Output they got the details wrong.
outputChatBox ( "用户名或密码错误!", thePlayer, 255, 255, 0 ) -- 告诉他们参数错误了.
end
end
end
end
addCommandHandler ( "log-in", loginPlayer ) -- Make it trigger for "/log-in", NOTE: /login is hardcored and cannot be used.
addCommandHandler ( "log-in", loginPlayer ) -- 使其触发“/log-in”, 注意: /login is hardcored and cannot be used.
</syntaxhighlight>
</syntaxhighlight>



Revision as of 08:10, 4 February 2021

此函数用于将给定的玩家登录到给定的帐户.您需要提供登录该帐户所需的密码.

语法

bool logIn ( player thePlayer, account theAccount, string thePassword )

OOP 语法 什么是OOP?

方法: player:logIn(...)
对称函数: logOut

必填参数

  • thePlayer: 登录账户的玩家
  • theAccount: 要登录的账户
  • thePassword: 登录此帐户所需的密码

Returns

如果玩家成功登录到给定帐户,则返回“true”。如果由于某种原因登录失败,即玩家已经登录到某个帐户(首先使用logOut),如果该帐户已经在使用中或由于其他原因失败,则返回“false”或“nil”

示例

function loginPlayer ( thePlayer, command, username, password )
	local account = getAccount ( username, password ) -- 返回账户
		if ( account ~= false ) then -- If the account exists.
			logIn ( thePlayer, account, password ) -- 让他们登录.
		else
			outputChatBox ( "用户名或密码错误!", thePlayer, 255, 255, 0 ) -- 告诉他们参数错误了.
		end
end
addCommandHandler ( "log-in", loginPlayer ) -- 使其触发“/log-in”, 注意: /login is hardcored and cannot be used.

See Also