ZH-CN/logOut: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server function}} This function logs the given player out of his current account. ==Syntax== <syntaxhighlight lang="lua"> bool logOut ( player thePlayer ) <...")
 
m (Добавление языков)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}
{{Server function}}
This function logs the given player out of his current [[account]].
此函数用于将给定的玩家从其当前[[帐户]]中注销.


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


===Required Arguments===  
===必填参数===  
*'''thePlayer:''' The player to log out of his current account
*'''thePlayer:''' 要注销的玩家账户


===Returns===
===返回值===
Returns ''true'' if the player was successfully logged out, ''false'' or ''nil'' if it failed for some reason, ie. the player was never logged in.
如果玩家成功注销,则返回“true”;如果由于某种原因失败,则返回“false”或“nil”,即玩家从未登录


==Example==  
==示例==  
This example logs every player out of their account when the resource is (re)started. This would be handy for resources that show a login screen onClientResourceStart.
此示例在资源(重新)启动时将每个玩家从其帐户中注销。这对于在onClientResourceStart上显示登录屏幕的资源来说非常方便
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function logoutAll ()
function logoutAll ()
Line 27: Line 27:
end
end
end
end
  -- Trigger it when the resource (re)starts
  -- 当资源(重新)启动时触发它
addEventHandler ( "onResourceStart", getResourceRootElement(), logoutAll )</syntaxhighlight>
addEventHandler ( "onResourceStart", getResourceRootElement(), logoutAll )</syntaxhighlight>


Line 33: Line 33:
{{Account_functions}}
{{Account_functions}}


[[en:logOut]]
[[ru:logOut]]
[[ru:logOut]]
[[es:logOut]]
[[es:logOut]]
[[zh-cn:logOut]]
[[zh-cn:logOut]]

Latest revision as of 15:07, 12 April 2021

此函数用于将给定的玩家从其当前帐户中注销.

语法

bool logOut ( player thePlayer )

OOP 语法 什么是OOP?

方法: player:logOut(...)

必填参数

  • thePlayer: 要注销的玩家账户

返回值

如果玩家成功注销,则返回“true”;如果由于某种原因失败,则返回“false”或“nil”,即玩家从未登录

示例

此示例在资源(重新)启动时将每个玩家从其帐户中注销。这对于在onClientResourceStart上显示登录屏幕的资源来说非常方便

function logoutAll ()
	local players = getElementsByType ( "player" ) -- Get every player
		for k, player in ipairs ( players ) do -- For every player do the following...
			account = getPlayerAccount ( player ) -- Get every player's account
				if ( not isGuestAccount ( account ) ) then -- For every player that's logged in....
					logOut ( player ) -- Log them out.
				end
		end
end
 -- 当资源(重新)启动时触发它
addEventHandler ( "onResourceStart", getResourceRootElement(), logoutAll )

See Also