ZH-CN/AclDestroyGroup: Difference between revisions
Jump to navigation
Jump to search
Qwe7769611 (talk | contribs) No edit summary |
mNo edit summary |
||
(One intermediate revision by one other user not shown) | |||
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组.销毁的ACL组将不再有效. | |||
== | ==语法== | ||
<!-- 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 aclDestroyGroup ( aclgroup aclGroup ) | bool aclDestroyGroup ( aclgroup aclGroup ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{ | {{OOP_ZH-CN||[[aclgroup]]:destroy||}} | ||
=== | ===必填参数=== | ||
<!-- 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 --> | ||
*'''aclGroup:''' | *'''aclGroup:''' 要销毁的ACL组元素 | ||
=== | ===返回值=== | ||
<!-- 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”. | |||
== | ==示例== | ||
<!-- Explain what the example is in a single sentance --> | <!-- Explain what the example is in a single sentance --> | ||
此示例允许管理员删除他们指定的ACL组. | |||
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --> | <!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function removeACLGroup ( source, command, groupName ) | function removeACLGroup ( source, command, groupName ) | ||
-- | -- 检查他们是不是管理员... | ||
if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then | if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then | ||
if ( groupName ) then -- | if ( groupName ) then -- 检查他们是否指定了组名 | ||
local group = aclGetGroup ( groupName ) -- | local group = aclGetGroup ( groupName ) -- 返回与名称匹配的任何组 | ||
if ( group ) then -- If any were returned then... | if ( group ) then -- If any were returned then... | ||
aclDestroyGroup ( group ) -- | aclDestroyGroup ( group ) -- 删除这个组 | ||
else | else | ||
-- | -- 告诉他们是否找不到具有该名称的组... | ||
outputChatBox ( "No group with that name was found.", source, 255, 0, 0 ) | outputChatBox ( "No group with that name was found.", source, 255, 0, 0 ) | ||
end | end | ||
else -- | else -- 如果他们没有指定组 | ||
outputChatBox ( "Please specify the group name.", source, 255, 0, 0 ) -- Tell them that they must | outputChatBox ( "Please specify the group name.", source, 255, 0, 0 ) -- Tell them that they must | ||
end | end | ||
else -- | else -- 如果他们不是管理员.... | ||
outputChatBox ( "You must be an admin to use this command", source, 255, 0, 0 ) -- Tell them it's restricted | outputChatBox ( "You must be an admin to use this command", source, 255, 0, 0 ) -- Tell them it's restricted | ||
end | end | ||
end | end | ||
addCommandHandler ( "removeACL", removeACLGroup ) -- | addCommandHandler ( "removeACL", removeACLGroup ) -- 当玩家输入 "/removeACL"时触发的事件 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 48: | Line 48: | ||
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --> | <!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --> | ||
{{ACL_functions}} | {{ACL_functions}} | ||
[[ar:aclDestroyGroup]] | |||
[[en:AclDestroyGroup]] | [[en:AclDestroyGroup]] | ||
[[zh-cn:AclDestroyGroup]] |
Latest revision as of 18:17, 21 February 2021
此函数将销毁给定的ACL组.销毁的ACL组将不再有效.
语法
bool aclDestroyGroup ( aclgroup aclGroup )
OOP 语法 什么是OOP?
- 方法: aclgroup:destroy(...)
必填参数
- aclGroup: 要销毁的ACL组元素
返回值
如果ACL组已成功删除,则返回“true”;如果由于某种原因(即无效参数)无法删除,则返回“false”.
示例
此示例允许管理员删除他们指定的ACL组.
function removeACLGroup ( source, command, groupName ) -- 检查他们是不是管理员... if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then if ( groupName ) then -- 检查他们是否指定了组名 local group = aclGetGroup ( groupName ) -- 返回与名称匹配的任何组 if ( group ) then -- If any were returned then... aclDestroyGroup ( group ) -- 删除这个组 else -- 告诉他们是否找不到具有该名称的组... outputChatBox ( "No group with that name was found.", source, 255, 0, 0 ) end else -- 如果他们没有指定组 outputChatBox ( "Please specify the group name.", source, 255, 0, 0 ) -- Tell them that they must end else -- 如果他们不是管理员.... outputChatBox ( "You must be an admin to use this command", source, 255, 0, 0 ) -- Tell them it's restricted end end addCommandHandler ( "removeACL", removeACLGroup ) -- 当玩家输入 "/removeACL"时触发的事件
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