AclCreate: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
(10 intermediate revisions by 9 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server function}} | ||
This function creates an ACL entry in the Access Control List system with the specified name. | This function creates an ACL entry in the Access Control List system with the specified name. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
acl aclCreate ( string aclName ) | acl aclCreate ( string aclName ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[ACL]]||}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''aclName:''' The name of the ACL entry to add. | *'''aclName:''' The name of the ACL entry to add. | ||
===Returns=== | ===Returns=== | ||
Returns the created ACL object if successful. Returns false if an ACL of the given name could not be created. | Returns the created ACL object if successful. Returns false if an ACL of the given name could not be created. | ||
==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 ) | ||
-- 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 | |||
return outputDebugString ( "Invalid access; true and false are only accepted", 1 ) | |||
end | |||
-- change the access to boolean | |||
if access == "true" then | |||
access = true | |||
else | |||
access = false | |||
end | |||
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 | |||
-- 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}} | ||
[[ | |||
[[ar:aclCreate]] | |||
[[en:aclCreate]] | |||
[[zh-cn:AclCreate]] |
Latest revision as of 18:08, 21 February 2021
This function creates an ACL entry in the Access Control List system with the specified name.
Syntax
acl aclCreate ( string aclName )
OOP Syntax Help! I don't understand this!
- Method: ACL(...)
Required Arguments
- aclName: The name of the ACL entry to add.
Returns
Returns the created ACL object if successful. Returns false if an ACL of the given name could not be created.
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 ) -- 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 return outputDebugString ( "Invalid access; true and false are only accepted", 1 ) end -- change the access to boolean if access == "true" then access = true else access = false end 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 -- 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