ZH-CN/AclGetName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}  
{{Server function}}  
Get the name of given ACL.
获取给定ACL的名称.


==Syntax==  
==语法==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string aclGetName ( acl theAcl )
string aclGetName ( acl theAcl )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[acl]]:getName|name|}}
{{OOP_ZH-CN||[[acl]]:getName|name|}}
===Required Arguments===  
===必填参数===  
*'''theACL:''' The ACL to get the name of
*'''theACL:''' 要获取其名称的ACL


===Returns===
===返回值===
Returns the name of the given ACL as a string if successful. Returns ''false''/''nil'' if unsuccessful, ie the ACL is invalid.
如果成功,则以字符串形式返回给定ACL的名称。如果不成功,则返回“false”/“nil”,即ACL无效.


==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 38: Line 38:
==See Also==
==See Also==
{{ACL_functions}}
{{ACL_functions}}
[[ar:aclGetName]]
[[en:AclGetName]]
[[en:AclGetName]]
[[zh-cn:AclGetName]]

Latest revision as of 18:24, 21 February 2021

获取给定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