AclList: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (fix oop syntax)
(13 intermediate revisions by 8 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 returns a list of all the ACLs.


==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 acl aclList ()
table aclList ()
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP|This function is a static function underneath the ACL class.|[[ACL]].list||}}
===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 -->
*'''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 a table of all the ACLs. This table can be empty if no ACLs exist. It can also return ''false''/''nil'' if it failed for some reason.
Returns ''true'' if blah, ''false'' otherwise.


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example adds a command ''listacls'' which prints out a name list of all ACLs to the console.
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 printOutAllACLs ( thePlayer )
blabhalbalhb --abababa
    -- get a table over all the ACLs
--This line does this...
    local allACLs = aclList()
mooo
    -- if the table is empty (there are no ACLs)
    if #allACLs == 0 then
        -- print out a message to console and exit function
        return outputConsole ( "There are no ACLs!", thePlayer )
    else
        -- print out a list of the names
        outputConsole ( "List of all ACLs:", thePlayer )
        for key, singleACL in ipairs ( allACLs ) do
            local ACLName = aclGetName ( singleACL )
            outputConsole ( "- " .. tostring ( ACLName ), thePlayer )
        end
  end
end
addCommandHandler ( "listacls", printOutAllACLs )
</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]]

Revision as of 14:52, 1 January 2015

This function returns a list of all the ACLs.

Syntax

table aclList ()

OOP Syntax Help! I don't understand this!

Note: This function is a static function underneath the ACL class.
Method: ACL.list(...)


Returns

Returns a table of all the ACLs. This table can be empty if no ACLs exist. It can also return false/nil if it failed for some reason.

Example

This example adds a command listacls which prints out a name list of all ACLs to the console.

function printOutAllACLs ( thePlayer )
    -- get a table over all the ACLs
    local allACLs = aclList()
    -- if the table is empty (there are no ACLs)
    if #allACLs == 0 then
        -- print out a message to console and exit function
        return outputConsole ( "There are no ACLs!", thePlayer )
    else
        -- print out a list of the names
        outputConsole ( "List of all ACLs:", thePlayer )
        for key, singleACL in ipairs ( allACLs ) do
            local ACLName = aclGetName ( singleACL )
            outputConsole ( "- " .. tostring ( ACLName ), thePlayer )
        end
   end
end
addCommandHandler ( "listacls", printOutAllACLs )

See Also