ZH-CN/logIn: Difference between revisions
Jump to navigation
Jump to search
Qwe7769611 (talk | contribs) (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==...") |
Qwe7769611 (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server function}} | ||
此函数用于将给定的玩家登录到给定的帐户.您需要提供登录该帐户所需的密码. | |||
== | ==语法== | ||
<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_ZH-CN||[[player]]:logIn||logOut}} | ||
=== | ===必填参数=== | ||
*'''thePlayer:''' | *'''thePlayer:''' 登录账户的玩家 | ||
*'''theAccount:''' | *'''theAccount:''' 要登录的账户 | ||
*'''thePassword:''' | *'''thePassword:''' 登录此帐户所需的密码 | ||
===Returns=== | ===Returns=== | ||
如果玩家成功登录到给定帐户,则返回“true”。如果由于某种原因登录失败,即玩家已经登录到某个帐户(首先使用[[logOut]]),如果该帐户已经在使用中或由于其他原因失败,则返回“false”或“nil” | |||
== | ==示例== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function loginPlayer ( thePlayer, command, username, password ) | function loginPlayer ( thePlayer, command, username, password ) | ||
local account = getAccount ( username, password ) -- | 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 ) -- | logIn ( thePlayer, account, password ) -- 让他们登录. | ||
else | else | ||
outputChatBox ( " | outputChatBox ( "用户名或密码错误!", thePlayer, 255, 255, 0 ) -- 告诉他们参数错误了. | ||
end | end | ||
end | end | ||
addCommandHandler ( "log-in", loginPlayer ) -- | 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?
必填参数
- 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
- addAccount
- copyAccountData
- getAccount
- getAccountData
- getAccountName
- getAccountPlayer
- getAccountSerial
- getAccounts
- getAccountsBySerial
- getAllAccountData
- getPlayerAccount
- isGuestAccount
- logIn
- logOut
- removeAccount
- setAccountData
- setAccountPassword
- getAccountByID
- getAccountID
- getAccountIP
- getAccountsByData
- getAccountsByIP
- setAccountName