ZH-CN/logIn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 14: Line 14:
*'''thePassword:''' 登录此帐户所需的密码
*'''thePassword:''' 登录此帐户所需的密码


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


Line 35: Line 35:
[[ru:logIn]]
[[ru:logIn]]
[[ar:logIn]]
[[ar:logIn]]
[[zh-cn:logIn]]
[[en:logIn]]

Revision as of 08:14, 5 February 2021

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

语法

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

OOP 语法 什么是OOP?

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

必填参数

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

返回值

如果玩家成功登录到给定帐户,则返回“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