ZH-CN/AclGet: Difference between revisions
Jump to navigation
Jump to search
Qwe7769611 (talk | contribs) No edit summary |
Qwe7769611 (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server function}} | ||
获取具有给定名称的ACL。如果需要获取大多数ACL,您应该考虑使用[[aclist]]来获取所有ACL的表. | |||
== | ==语法== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
acl aclGet ( string aclName ) | acl aclGet ( string aclName ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{ | {{OOP_ZH-CN|This function is a static function underneath the ACL class.|[[ACL]].get||}} | ||
=== | ===必填参数=== | ||
*'''aclName:''' | *'''aclName:''' 获取ACL所属的名称 | ||
=== | ===返回值=== | ||
如果可以检索,则返回具有该名称的ACL;如果ACL不存在或由于其他原因失败,则返回“false”/“nil”. | |||
== | ==示例== | ||
此示例添加了命令“setaclright”,使用该命令可以轻松地向指定的访问控制列表添加新权限. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function setACLRight ( thePlayer, commandName, aclName, rightName, access ) | function setACLRight ( thePlayer, commandName, aclName, rightName, access ) | ||
local ourACL = aclGet ( aclName ) | local ourACL = aclGet ( aclName ) | ||
-- | -- 如果以前没有具有此名称的ACL,则需要创建一个 | ||
if not ourACL then | if not ourACL then | ||
ourACL = aclCreate ( aclName ) | ourACL = aclCreate ( aclName ) | ||
end | end | ||
-- | -- 将布尔字符串转换为小写 | ||
access = string.lower ( access ) | access = string.lower ( access ) | ||
-- | -- 访问必须是true或false(布尔值) | ||
if not (access == "true" or access == "false") then | if not (access == "true" or access == "false") then | ||
-- | -- 将错误消息打印到调试窗口 | ||
return outputDebugString ( "Invalid access; true and false are only accepted", 1 ) | return outputDebugString ( "Invalid access; true and false are only accepted", 1 ) | ||
end | end | ||
-- | -- 将访问权限更改为布尔值 | ||
if access == "true" then | if access == "true" then | ||
access = true | access = true | ||
Line 39: | Line 39: | ||
end | end | ||
-- | -- 最后让我们确定正确的方向 | ||
aclSetRight ( ourACL, rightName, access ) | aclSetRight ( ourACL, rightName, access ) | ||
-- | -- 不要忘记在修改ACL后保存它 | ||
aclSave () | aclSave () | ||
end | end |
Revision as of 03:27, 6 February 2021
获取具有给定名称的ACL。如果需要获取大多数ACL,您应该考虑使用aclist来获取所有ACL的表.
语法
acl aclGet ( string aclName )
OOP 语法 什么是OOP?
- 提示: This function is a static function underneath the ACL class.
- 方法: ACL.get(...)
必填参数
- aclName: 获取ACL所属的名称
返回值
如果可以检索,则返回具有该名称的ACL;如果ACL不存在或由于其他原因失败,则返回“false”/“nil”.
示例
此示例添加了命令“setaclright”,使用该命令可以轻松地向指定的访问控制列表添加新权限.
function setACLRight ( thePlayer, commandName, aclName, rightName, access ) local ourACL = aclGet ( aclName ) -- 如果以前没有具有此名称的ACL,则需要创建一个 if not ourACL then ourACL = aclCreate ( aclName ) end -- 将布尔字符串转换为小写 access = string.lower ( access ) -- 访问必须是true或false(布尔值) if not (access == "true" or access == "false") then -- 将错误消息打印到调试窗口 return outputDebugString ( "Invalid access; true and false are only accepted", 1 ) end -- 将访问权限更改为布尔值 if access == "true" then access = true else access = false end -- 最后让我们确定正确的方向 aclSetRight ( ourACL, rightName, access ) -- 不要忘记在修改ACL后保存它 aclSave () end addCommandHandler ( "setaclright", setACLRight )
See Also
- aclCreate
- aclCreateGroup
- aclDestroy
- aclDestroyGroup
- aclGet
- aclGetGroup
- aclGetName
- aclGetRight
- aclGroupAddACL
- aclGroupAddObject
- aclGroupGetName
- aclGroupList
- aclGroupListACL
- aclGroupListObjects
- aclGroupRemoveACL
- aclGroupRemoveObject
- aclList
- aclListRights
- aclReload
- aclRemoveRight
- aclSave
- aclSetRight
- hasObjectPermissionTo
- isObjectInACLGroup