ZH-CN/AclDestroyGroup: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server function}} <!-- Describe in plain english what this function does. Don't go into details, just give an overview --> This function destroys the given ACL g...")
 
mNo edit summary
 
(2 intermediate revisions 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 -->
This function destroys the given ACL group. The destroyed ACL group will no longer be valid.
此函数将销毁给定的ACL组.销毁的ACL组将不再有效.


==Syntax==  
==语法==  
<!-- 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||[[aclgroup]]:destroy||}}
{{OOP_ZH-CN||[[aclgroup]]:destroy||}}
===Required Arguments===  
===必填参数===  
<!-- 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:''' The [[aclgroup]] element to destroy
*'''aclGroup:''' 要销毁的ACL组元素


===Returns===
===返回值===
<!-- 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 -->
Returns ''true'' if the ACL group was successfully deleted, ''false'' if it could not be deleted for some reason (ie. invalid argument).
如果ACL组已成功删除,则返回“true”;如果由于某种原因(即无效参数)无法删除,则返回“false”.


==Example==  
==示例==  
<!-- Explain what the example is in a single sentance -->
<!-- Explain what the example is in a single sentance -->
This example allows admins to remove an ACL group they specify.
此示例允许管理员删除他们指定的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 )
-- Check if they're an admin...
-- 检查他们是不是管理员...
if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then
if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then
if ( groupName ) then -- Check if they specified the group name
if ( groupName ) then -- 检查他们是否指定了组名
local group = aclGetGroup ( groupName ) -- Return any groups matching the name
local group = aclGetGroup ( groupName ) -- 返回与名称匹配的任何组
if ( group ) then -- If any were returned then...
if ( group ) then -- If any were returned then...
aclDestroyGroup ( group ) -- Destroy that group
aclDestroyGroup ( group ) -- 删除这个组
else
else
-- Tell them if no groups with that name were found...
-- 告诉他们是否找不到具有该名称的组...
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 -- If they didn't specify the group
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 -- If they're not an admin....
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 ) -- Make it happen when somebody types "/removeACL"
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]]
[[zh-cn: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