AclGetRight: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ <!-- Describe in plain english what this function does. Don't go into details, just give an overview --> This fake function is for use with blah & blah and does blahblahblabhalb...)
 
mNo edit summary
 
(12 intermediate revisions by 9 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{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 fake function is for use with blah & blah and does blahblahblabhalbhl
This function returns whether the access for the given right is set to true or false in the 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 -->
<!-- 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||[[acl]]:getRight||aclSetRight}}
===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 -->
*'''argumentName:''' description
*'''theAcl:''' The ACL to get the right from
 
*'''rightName:''' The right name to return the access value of.
<!-- Only include this section below if there are optional arguments -->
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' description
*'''argumentName3:''' description


===Returns===
===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 blah, ''false'' otherwise.
Returns ''true'' or ''false'' if the ACL gives access or not to the given function. Returns ''nil'' if it failed for some reason, e.g. an invalid ACL was specified or the right specified does not exist in the ACL.


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example lets players check if an ACL group has access to something or not.
This example does...
<!-- 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">
--This line does...
--theACL examples: Admin, Default, Moderator
blabhalbalhb --abababa
--theRight examples: command.debugscript, function.banPlayer
--This line does this...
 
mooo
function aclRightCheck(player, command, theACL, theRight)
if (theACL and theRight) then -- Make sure atleast two arguments were entered.
local theACL = aclGet(theACL) -- If theACL exists then convert it into an ACL pointer from a string.
if (theACL) then -- If the ACL was found.
local theReturn = aclGetRight(theACL, theRight) -- Will return true if it was found in the ACL.
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) -- When the ACL was not found.
end
else
outputChatBox("You need to enter an ACL, and a right name.", player, 255, 0, 0) -- When 2 arguements weren't entered.
end
end
addCommandHandler("aclgetright", aclRightCheck) -- When a player does the aclgetright command it calls aclRightCheck function above.
-- Example of use: /aclgetright Admin command.debugscript (this should return true)
-- Example of use: /aclgetright Default command.debugscript (this should return false)
</syntaxhighlight>
</syntaxhighlight>


Line 37: Line 46:
<!-- 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:Incomplete]] -- leave this unless you complete the function
 
[[ar:aclGetRight]]
[[en:AclGetRight]]
[[zh-cn:aclGetRight]]

Latest revision as of 18:25, 21 February 2021

This function returns whether the access for the given right is set to true or false in the ACL.

Syntax

bool aclGetRight ( acl theAcl, string rightName )

OOP Syntax Help! I don't understand this!

Method: acl:getRight(...)
Counterpart: aclSetRight


Required Arguments

  • theAcl: The ACL to get the right from
  • rightName: The right name to return the access value of.

Returns

Returns true or false if the ACL gives access or not to the given function. Returns nil if it failed for some reason, e.g. an invalid ACL was specified or the right specified does not exist in the ACL.

Example

This example lets players check if an ACL group has access to something or not.

--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) -- If theACL exists then convert it into an ACL pointer from a string.
		if (theACL) then -- If the ACL was found.
			local theReturn = aclGetRight(theACL, theRight) -- Will return true if it was found in the ACL.
			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) -- When the ACL was not found.
		end
	else
		outputChatBox("You need to enter an ACL, and a right name.", player, 255, 0, 0) -- When 2 arguements weren't entered.
	end
end
addCommandHandler("aclgetright", aclRightCheck) -- When a player does the aclgetright command it calls aclRightCheck function above.
-- Example of use: /aclgetright Admin command.debugscript (this should return true)
-- Example of use: /aclgetright Default command.debugscript (this should return false)

See Also