AclListRights: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Server function}}<!-- Change this to "Client function" or "Server function" appropriately--> <!-- Describe in plain english what this function does. Don't go into details, jus...)
 
No edit summary
 
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}<!-- Change this to "Client function" or "Server function" appropriately-->
{{Server function}}
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
This function returns a table of all the rights that a given ACL has.
This function returns a table over all the rights that exist in a given ACL.


==Syntax==  
==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 -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
table of string aclListRights ( acl theACL )
table aclListRights ( acl theACL, string allowedType )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[acl]]:listRights||}}
===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 -->
*'''theACL:''' The ACL to get the rights from
*'''theACL:''' The ACL to get the rights from
*'''allowedType:''' The allowed right type. Possible values are ''general'', ''function'', ''resource'' and ''command''


===Returns===
===Returns===
<!-- Make this descriptive. Explain what cases will return false. If you're unsure, add a tag to it so we can check -->
Returns a table over the rights as strings in the given ACL. This table might be empty. Returns ''false'' or ''nil'' if theACL is invalid or it fails for some other reason.
Returns a table over the rights as strings in the given ACL. This table might be empty. Returns ''false'' or ''nil'' if theACL is invalid or it fails for some other reason.


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example outputs the rights of the given acl. (TESTED!)
This example does...
<syntaxhighlight lang="lua">addCommandHandler("aclRights",function(player,command,theAcl)
<!-- 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 -->
if(theAcl~="")then
<syntaxhighlight lang="lua">
rights = aclListRights(aclGet(theAcl))
--TODO
count = 0
for acl,list in pairs(rights)do
outputChatBox("ACL List: "..theAcl.." #"..tostring(count).." Right: "..list..".",player)
count = count + 1
end
else
outputChatBox("Please type in a acl that you want to retrieve the rights from.",player)
outputChatBox("Please use this Syntax: /aclRights theACL ",player)
end
end)
</syntaxhighlight>
</syntaxhighlight>


Line 29: Line 35:
<!-- 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}}
[[Category:Needs_Example]] <!-- leave this until the example is completed. -->
[[zh-cn:aclListRights]]

Latest revision as of 08:36, 5 February 2021

This function returns a table of all the rights that a given ACL has.

Syntax

table aclListRights ( acl theACL, string allowedType )

OOP Syntax Help! I don't understand this!

Method: acl:listRights(...)


Required Arguments

  • theACL: The ACL to get the rights from
  • allowedType: The allowed right type. Possible values are general, function, resource and command

Returns

Returns a table over the rights as strings in the given ACL. This table might be empty. Returns false or nil if theACL is invalid or it fails for some other reason.

Example

This example outputs the rights of the given acl. (TESTED!)

addCommandHandler("aclRights",function(player,command,theAcl)
	if(theAcl~="")then
		rights = aclListRights(aclGet(theAcl))
		count = 0
		for acl,list in pairs(rights)do
			outputChatBox("ACL List: "..theAcl.." #"..tostring(count).." Right: "..list..".",player)
			count = count + 1
		end
	else
		outputChatBox("Please type in a acl that you want to retrieve the rights from.",player)
		outputChatBox("Please use this Syntax: /aclRights theACL ",player)
	end
end)

See Also