AclDestroyGroup: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Removed "Needs example" category.)
(Fixed incorrectly documented parameter type (http://code.google.com/p/mtasa-blue/source/browse/trunk/MTA10_Server/mods/deathmatch/logic/luadefs/CLuaACLDefs.cpp#515))
Line 7: Line 7:
<!-- 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 ( string aclGroupName )
bool aclDestroyGroup ( aclgroup aclGroup )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===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 -->
*'''aclGroupName:''' The name of ACL group to destroy
*'''aclGroup:''' The [[aclgroup]] element to destroy


===Returns===
===Returns===

Revision as of 12:39, 2 April 2013

This function destroys the given ACL group. The destroyed ACL group will no longer be valid.

Syntax

bool aclDestroyGroup ( aclgroup aclGroup )

Required Arguments

  • aclGroup: The aclgroup element to destroy

Returns

Returns true if the ACL group was successfully deleted, false if it could not be deleted for some reason (ie. invalid argument).

Example

This example allows admins to remove an ACL group they specify.

function removeACLGroup ( source, command, groupName )
-- Check if they're an admin...
	if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( "Admin" ) ) ) then
		if ( groupName ) then -- Check if they specified the group name
			local group = aclGetGroup ( groupName ) -- Return any groups matching the name
				if ( group ) then -- If any were returned then...
					aclDestroyGroup ( group ) -- Destroy that group
				else
					-- Tell them if no groups with that name were found...
					outputChatBox ( "No group with that name was found.", source, 255, 0, 0 )
				end
	
		else -- If they didn't specify the group
			outputChatBox ( "Please specify the group name.", source, 255, 0, 0 ) -- Tell them that they must
		end
	else -- If they're not an admin....
		outputChatBox ( "You must be an admin to use this command", source, 255, 0, 0 ) -- Tell them it's restricted
	end
end
addCommandHandler ( "removeACL", removeACLGroup ) -- Make it happen when somebody types "/removeACL"

See Also