ZH-CN/AclCreateGroup: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server function}} This function creates a group in the ACL. An ACL group can contain objects like players and resources. They specify who has access to the ACL's...")
 
mNo edit summary
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}
{{Server function}}
This function creates a group in the ACL. An ACL group can contain objects like players and resources. They specify who has access to the ACL's in this group.
此函数用于在ACL中创建组。ACL组可以包含玩家和资源等对象.它们指定谁有权访问此组中的ACL


==Syntax==  
==语法==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
aclgroup aclCreateGroup ( string groupName )
aclgroup aclCreateGroup ( string groupName )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[aclgroup|ACLGroup]]||}}
{{OOP_ZH-CN||[[aclgroup|ACLGroup]]||}}
===Required Arguments===  
===必填参数===  
*'''groupName:''' The name of the group to create
*'''groupName:''' 要创建的组的名称


===Returns===
===返回值===
Returns the pointer to the created aclgroup if successful. Returns false if failed.
如果成功,则返回指向已创建aclgroup的指针函数。如果失败,则返回false.


==Example==  
==示例==  
This example adds a command ''addobjecttogroup'' with which you can easily add new objects to specified access control list groups.
此示例添加了一个命令''addobjecttogroup'',使用该命令可以轻松地将新对象添加到指定的访问控制列表组中.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function addACLGroupObject ( thePlayer, commandName, groupName, objectName )
function addACLGroupObject ( thePlayer, commandName, groupName, objectName )
     local ourGroup = aclGetGroup ( groupName )
     local ourGroup = aclGetGroup ( groupName )
     -- if there is no previous group with this name, we need to create one
     -- 如果以前没有使用此名称的组,则需要创建一个
     if not ourGroup then
     if not ourGroup then
         ourGroup = aclCreateGroup ( groupName )
         ourGroup = aclCreateGroup ( groupName )
     end
     end


     -- if object name wasn't given
     -- 如果没有给出对象名
     if not objectName then
     if not objectName then
         -- print out message to chatbox
         -- 将消息发送到聊天室
         return outputChatBox ( "You need to specify the object!", thePlayer )
         return outputChatBox ( "You need to specify the object!", thePlayer )
     end
     end


     -- and finally let's add the object to it's group
     -- 最后,让我们将对象添加到它的组中
     aclGroupAddObject ( ourGroup, objectName )
     aclGroupAddObject ( ourGroup, objectName )
     -- don't forget to save the ACL after it has been modified
     -- 不要忘记在修改ACL后保存它
     aclSave ()
     aclSave ()
end
end
Line 40: Line 40:
==See Also==
==See Also==
{{ACL_functions}}
{{ACL_functions}}
[[ar:aclCreateGroup]]
[[en:aclCreateGroup]]
[[zh-cn:AclCreateGroup]]
[[zh-cn:AclCreateGroup]]

Latest revision as of 18:09, 21 February 2021

此函数用于在ACL中创建组。ACL组可以包含玩家和资源等对象.它们指定谁有权访问此组中的ACL

语法

aclgroup aclCreateGroup ( string groupName )

OOP 语法 什么是OOP?

方法: ACLGroup(...)

必填参数

  • groupName: 要创建的组的名称

返回值

如果成功,则返回指向已创建aclgroup的指针函数。如果失败,则返回false.

示例

此示例添加了一个命令addobjecttogroup,使用该命令可以轻松地将新对象添加到指定的访问控制列表组中.

function addACLGroupObject ( thePlayer, commandName, groupName, objectName )
    local ourGroup = aclGetGroup ( groupName )
    -- 如果以前没有使用此名称的组,则需要创建一个
    if not ourGroup then
        ourGroup = aclCreateGroup ( groupName )
    end

    -- 如果没有给出对象名
    if not objectName then
        -- 将消息发送到聊天室
        return outputChatBox ( "You need to specify the object!", thePlayer )
    end

    -- 最后,让我们将对象添加到它的组中
    aclGroupAddObject ( ourGroup, objectName )
    -- 不要忘记在修改ACL后保存它
    aclSave ()
end
addCommandHandler ( "addobjecttogroup", addACLGroupObject )

See Also