ZH-CN/AclGetName

From Multi Theft Auto: Wiki
Revision as of 18:24, 21 February 2021 by Myonlake (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

获取给定ACL的名称.

语法

string aclGetName ( acl theAcl )

OOP 语法 什么是OOP?

方法: acl:getName(...)
变量: .name

必填参数

  • theACL: 要获取其名称的ACL

返回值

如果成功,则以字符串形式返回给定ACL的名称。如果不成功,则返回“false”/“nil”,即ACL无效.

示例

此示例添加命令“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