ZH-CN/aclGetRight: Difference between revisions
Jump to navigation
Jump to search
Qwe7769611 (talk | contribs) No edit summary |
Qwe7769611 (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
{{Server function}} | {{Server function}} | ||
<!-- Describe in plain english what this function does. Don't go into details, just give an overview --> | <!-- Describe in plain english what this function does. Don't go into details, just give an overview --> | ||
此函数返回ACL中给定权限的访问权限设置为true还是false. | |||
== | ==语法== | ||
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --> | <!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool aclGetRight ( acl theAcl, string rightName ) | bool aclGetRight ( acl theAcl, string rightName ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{ | {{OOP_ZH-CN||[[acl]]:getRight||aclSetRight}} | ||
=== | ===必填参数=== | ||
<!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --> | <!-- List each argument one per line. This should be the argument's name as in the argument list above, NOT the argument's data type --> | ||
*'''theAcl:''' | *'''theAcl:''' 要从中获取权限的ACL | ||
*'''rightName:''' | *'''rightName:''' 返回的访问值的正确名称. | ||
=== | ===返回值=== | ||
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --> | <!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check --> | ||
如果ACL允许或不允许访问给定函数,则返回“true”或“false”。如果由于某种原因失败,例如指定了无效的ACL或ACL中不存在指定的权限,则返回“nil”. | |||
== | ==示例== | ||
这个例子允许玩家检查ACL组是否有权访问某些东西. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
--theACL examples: Admin, Default, Moderator | --theACL examples: Admin, Default, Moderator | ||
Line 27: | Line 27: | ||
function aclRightCheck(player, command, theACL, theRight) | function aclRightCheck(player, command, theACL, theRight) | ||
if (theACL and theRight) then -- Make sure atleast two arguments were entered. | if (theACL and theRight) then -- Make sure atleast two arguments were entered. | ||
local theACL = aclGet(theACL) -- | local theACL = aclGet(theACL) -- 如果ACL存在,则将其从字符串转换为ACL指针变量(pointer). | ||
if (theACL) then -- | if (theACL) then -- 如果找到ACL. | ||
local theReturn = aclGetRight(theACL, theRight) -- | local theReturn = aclGetRight(theACL, theRight) -- 如果在ACL中找到,则返回true. | ||
outputChatBox("The ACL right was found and returned: "..tostring(theReturn), player, 0, 255, 0) | outputChatBox("The ACL right was found and returned: "..tostring(theReturn), player, 0, 255, 0) | ||
else | else | ||
outputChatBox("The ACL you entered was not found to exist in the ACL file.", player, 255, 0, 0) -- | outputChatBox("The ACL you entered was not found to exist in the ACL file.", player, 255, 0, 0) -- 当未找到ACL时. | ||
end | end | ||
else | else | ||
outputChatBox("You need to enter an ACL, and a right name.", player, 255, 0, 0) -- | outputChatBox("You need to enter an ACL, and a right name.", player, 255, 0, 0) -- 当两个参数(argument)没有被输入时. | ||
end | end | ||
end | end | ||
addCommandHandler("aclgetright", aclRightCheck) -- | addCommandHandler("aclgetright", aclRightCheck) -- 当玩家执行aclgetright命令时,它会调用上面的aclRightCheck函数. | ||
-- Example of use: /aclgetright Admin command.debugscript (this should return true) | -- Example of use: /aclgetright Admin command.debugscript (this should return true) | ||
-- Example of use: /aclgetright Default command.debugscript (this should return false) | -- Example of use: /aclgetright Default command.debugscript (this should return false) |
Revision as of 03:49, 6 February 2021
此函数返回ACL中给定权限的访问权限设置为true还是false.
语法
bool aclGetRight ( acl theAcl, string rightName )
OOP 语法 什么是OOP?
- 方法: acl:getRight(...)
- 对称函数: aclSetRight
必填参数
- theAcl: 要从中获取权限的ACL
- rightName: 返回的访问值的正确名称.
返回值
如果ACL允许或不允许访问给定函数,则返回“true”或“false”。如果由于某种原因失败,例如指定了无效的ACL或ACL中不存在指定的权限,则返回“nil”.
示例
这个例子允许玩家检查ACL组是否有权访问某些东西.
--theACL examples: Admin, Default, Moderator --theRight examples: command.debugscript, function.banPlayer function aclRightCheck(player, command, theACL, theRight) if (theACL and theRight) then -- Make sure atleast two arguments were entered. local theACL = aclGet(theACL) -- 如果ACL存在,则将其从字符串转换为ACL指针变量(pointer). if (theACL) then -- 如果找到ACL. local theReturn = aclGetRight(theACL, theRight) -- 如果在ACL中找到,则返回true. outputChatBox("The ACL right was found and returned: "..tostring(theReturn), player, 0, 255, 0) else outputChatBox("The ACL you entered was not found to exist in the ACL file.", player, 255, 0, 0) -- 当未找到ACL时. end else outputChatBox("You need to enter an ACL, and a right name.", player, 255, 0, 0) -- 当两个参数(argument)没有被输入时. end end addCommandHandler("aclgetright", aclRightCheck) -- 当玩家执行aclgetright命令时,它会调用上面的aclRightCheck函数. -- Example of use: /aclgetright Admin command.debugscript (this should return true) -- Example of use: /aclgetright Default command.debugscript (this should return false)
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