AclCreate: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
 
(12 intermediate revisions by 9 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
<!-- Describe in plain english what this function does. Don't go into details, just give an overview -->
{{Server function}}
This fake function is for use with blah & blah and does blahblahblabhalbhl
This function creates an ACL entry in the Access Control List system with the specified name.


==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">
acl aclCreate ( string aclname )
acl aclCreate ( string aclName )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[ACL]]||}}
===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 -->
*'''aclName:''' The name of the ACL entry to add.
*'''argumentName:''' description
 
<!-- 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 -->
Returns the created ACL object if successful. Returns false if an ACL of the given name could not be created.
Returns ''true'' if blah, ''false'' otherwise.


==Example==  
==Example==
<!-- Explain what the example is in a single sentance -->
This example adds a command ''setaclright'' with which you can easily add new rights to specified access control lists.
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...
function setACLRight ( thePlayer, commandName, aclName, rightName, access )
blabhalbalhb --abababa
    -- turn the boolean string to lower case
--This line does this...
    access = string.lower ( access )
mooo
    -- 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==
<!-- 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]]
 
[[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