ZH-CN/aclList: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server function}} This function returns a list of all the ACLs. ==Syntax== <syntaxhighlight lang="lua"> table aclList () </syntaxhighlight> {{OOP|This functio...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}  
{{Server function}}  
This function returns a list of all the ACLs.
此函数返回所有ACL的列表.


==Syntax==  
==语法==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
table aclList ()
table aclList ()
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP|This function is a static function underneath the ACL class.|[[ACL]].list||}}
{{OOP_ZH-CN|This function is a static function underneath the ACL class.|[[ACL]].list||}}
===Returns===
===返回值===
Returns a table of all the ACLs. This table can be empty if no ACLs exist. It can also return ''false''/''nil'' if it failed for some reason.
返回所有ACL的表。如果不存在ACL,则此表可以为空。如果由于某种原因失败,它还可以返回“false”/“nil”.


==Example==  
==示例==  
This example adds a command ''listacls'' which prints out a name list of all ACLs to the console.
此示例添加了一个命令“listacls”,它将所有acl的名称列表打印到控制台.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function printOutAllACLs ( thePlayer )
function printOutAllACLs ( thePlayer )
     -- get a table over all the ACLs
     -- 在所有ACL上建立一个表
     local allACLs = aclList()
     local allACLs = aclList()
     -- if the table is empty (there are no ACLs)
     -- 如果表为空(没有ACL)
     if #allACLs == 0 then
     if #allACLs == 0 then
         -- print out a message to console and exit function
         -- 发送消息到控制台并退出功能
         return outputConsole ( "There are no ACLs!", thePlayer )
         return outputConsole ( "There are no ACLs!", thePlayer )
     else
     else
         -- print out a list of the names
         -- 发送名单列表
         outputConsole ( "List of all ACLs:", thePlayer )
         outputConsole ( "List of all ACLs:", thePlayer )
         for key, singleACL in ipairs ( allACLs ) do
         for key, singleACL in ipairs ( allACLs ) do
Line 35: Line 35:
==See Also==
==See Also==
{{ACL_functions}}
{{ACL_functions}}
[[zh-cn:aclList]]
[[en:aclList]]

Latest revision as of 07:02, 6 February 2021

此函数返回所有ACL的列表.

语法

table aclList ()

OOP 语法 什么是OOP?

提示: This function is a static function underneath the ACL class.
方法: ACL.list(...)

返回值

返回所有ACL的表。如果不存在ACL,则此表可以为空。如果由于某种原因失败,它还可以返回“false”/“nil”.

示例

此示例添加了一个命令“listacls”,它将所有acl的名称列表打印到控制台.

function printOutAllACLs ( thePlayer )
    -- 在所有ACL上建立一个表
    local allACLs = aclList()
    -- 如果表为空(没有ACL)
    if #allACLs == 0 then
        -- 发送消息到控制台并退出功能
        return outputConsole ( "There are no ACLs!", thePlayer )
    else
        -- 发送名单列表
        outputConsole ( "List of all ACLs:", thePlayer )
        for key, singleACL in ipairs ( allACLs ) do
            local ACLName = aclGetName ( singleACL )
            outputConsole ( "- " .. tostring ( ACLName ), thePlayer )
        end
   end
end
addCommandHandler ( "listacls", printOutAllACLs )

See Also