ZH-CN/GetAccountPlayer: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server function}} This function returns the player element that is currently using a specified account, i.e. is logged into it. Only one player can use an...")
 
m (Добавление языков)
 
(2 intermediate revisions by one other user not shown)
Line 2: Line 2:
{{Server function}}
{{Server function}}


This function returns the [[player]] element that is currently using a specified [[account]], i.e. is logged into it. Only one player can use an account at a time.
此函数返回当前正在使用指定账户[[account]]的玩家[[player]]元素,即已登录到该元素,一次只能有一个玩家使用一个帐号.
==Syntax==  
==语法==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
player getAccountPlayer ( account theAccount )
player getAccountPlayer ( account theAccount )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[account]]:getPlayer|player|}}
{{OOP_ZH-CN||[[account]]:getPlayer|player|}}
===Required Arguments===  
===必填函数===  
*'''theAccount:''' The [[account]] you wish to get the [[player]] of.
*'''theAccount:''' 您希望获得玩家[[player]]的那个账户[[account]].


===Returns===
===返回值===
Returns a [[player]] element if the account is currently in use, ''false'' otherwise.
如果帐户当前在线,则返回玩家[[player]]元素,否则返回“false”.


==Example==  
==示例==  
This example checks if the user attached to an account is a player, and if so if they're alive.
此示例检查附加到帐户的用户是否是玩家,如果是,是否还活着.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function isAccountUserAlive ( theAccount )
function isAccountUserAlive ( theAccount )
     local thePlayer = getAccountPlayer ( theAccount )      -- get the client attached to the account
     local thePlayer = getAccountPlayer ( theAccount )      -- 将客户端添加到帐户
     if ( getElementType ( thePlayer ) == "player" ) then    -- see if it really is a player (rather than a console admin for example)
     if ( getElementType ( thePlayer ) == "player" ) then    -- 看看它是否真的是一个玩家(而不是一个控制台管理员的例子)
         return not isPedDead(thePlayer)            -- if the player's health is greater than 0
         return not isPedDead(thePlayer)            -- 如果玩家生命值大于0
     end
     end
     return false
     return false
Line 29: Line 29:
{{Account functions}}
{{Account functions}}


[[en:getAccountPlayer]]
[[ru:getAccountPlayer]]
[[ru:getAccountPlayer]]
[[ar:getAccountPlayer]]
[[ar:getAccountPlayer]]
[[pl:GetAccountPlayer]]
[[pl:GetAccountPlayer]]
[[zh-cn:GetAccountPlayer]]
[[zh-cn:GetAccountPlayer]]

Latest revision as of 13:03, 12 April 2021

此函数返回当前正在使用指定账户account的玩家player元素,即已登录到该元素,一次只能有一个玩家使用一个帐号.

语法

player getAccountPlayer ( account theAccount )

OOP 语法 什么是OOP?

方法: account:getPlayer(...)
变量: .player

必填函数

返回值

如果帐户当前在线,则返回玩家player元素,否则返回“false”.

示例

此示例检查附加到帐户的用户是否是玩家,如果是,是否还活着.

function isAccountUserAlive ( theAccount )
    local thePlayer = getAccountPlayer ( theAccount )       -- 将客户端添加到帐户
    if ( getElementType ( thePlayer ) == "player" ) then    -- 看看它是否真的是一个玩家(而不是一个控制台管理员的例子)
        return not isPedDead(thePlayer)             -- 如果玩家生命值大于0 
    end
    return false
end

See Also