AclGet: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server function}} | ||
Get the ACL with the given name. If need to get most of the ACL's, you should consider using [[aclList]] to get a table of them all. | Get the ACL with the given name. If need to get most of the ACL's, you should consider using [[aclList]] to get a table of them all. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
acl aclGet ( string aclName ) | acl aclGet ( string aclName ) | ||
Line 11: | Line 9: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''aclName:''' The name to get the ACL belonging to | *'''aclName:''' The name to get the ACL belonging to | ||
===Returns=== | ===Returns=== | ||
Returns the ACL with that name if it could be retrieved, ''false''/''nil'' if the ACL does not exist or it fails for some other reason. | Returns the ACL with that name if it could be retrieved, ''false''/''nil'' if the ACL does not exist or it fails for some other reason. | ||
==Example== | ==Example== | ||
This example adds a command ''setaclright'' with which you can easily add new rights to specified access control lists. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function setACLRight ( thePlayer, commandName, aclName, rightName, access ) | ||
local ourACL = aclGet ( aclName ) | |||
-- if there is no previous ACL with this name, we need to create one | |||
if not ourACL then | |||
ourACL = aclCreate ( aclName ) | |||
end | |||
-- turn the boolean string to lower case | |||
access = string.lower ( access ) | |||
-- access has to be either true or false (booleans) | |||
if not (access == "true" or access == "false") then | |||
-- print out error message to debug window | |||
outputDebugString ( "Invalid access; true and false are only accepted", 1 ) | |||
-- exit function | |||
return | |||
end | |||
-- change the access to boolean | |||
if access == "true" then | |||
access = true | |||
else | |||
access = false | |||
-- and finally let's set the right | |||
aclSetRight ( ourACL, rightName, access ) | |||
-- don't forget to save the ACL after it has been modified | |||
aclSave () | |||
end | |||
addCommandHandler ( "setaclright", setACLRight ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{ACL_functions}} | {{ACL_functions}} | ||
Revision as of 18:33, 22 June 2009
Get the ACL with the given name. If need to get most of the ACL's, you should consider using aclList to get a table of them all.
Syntax
acl aclGet ( string aclName )
Required Arguments
- aclName: The name to get the ACL belonging to
Returns
Returns the ACL with that name if it could be retrieved, false/nil if the ACL does not exist or it fails for some other reason.
Example
This example adds a command setaclright with which you can easily add new rights to specified access control lists.
function setACLRight ( thePlayer, commandName, aclName, rightName, access ) local ourACL = aclGet ( aclName ) -- if there is no previous ACL with this name, we need to create one if not ourACL then ourACL = aclCreate ( aclName ) end -- turn the boolean string to lower case access = string.lower ( access ) -- access has to be either true or false (booleans) if not (access == "true" or access == "false") then -- print out error message to debug window outputDebugString ( "Invalid access; true and false are only accepted", 1 ) -- exit function return end -- change the access to boolean if access == "true" then access = true else access = false -- and finally let's set the right aclSetRight ( ourACL, rightName, access ) -- don't forget to save the ACL after it has been modified aclSave () end addCommandHandler ( "setaclright", setACLRight )
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