AclGetName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(5 intermediate revisions by 5 users not shown)
Line 7: Line 7:
string aclGetName ( acl theAcl )
string aclGetName ( acl theAcl )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[acl]]:getName|name|}}
===Required Arguments===  
===Required Arguments===  
*'''theACL:''' The ACL to get the name of
*'''theACL:''' The ACL to get the name of
Line 23: Line 23:
     if #allACLs == 0 then
     if #allACLs == 0 then
         -- print out a message to console and exit function
         -- print out a message to console and exit function
         outputConsole ( "There are no ACLs!", thePlayer )
         return outputConsole ( "There are no ACLs!", thePlayer )
        return
     else
     else
         -- print out a list of the names
         -- print out a list of the names
Line 39: Line 38:
==See Also==
==See Also==
{{ACL_functions}}
{{ACL_functions}}
[[ar:aclGetName]]
[[en:AclGetName]]
[[zh-cn:AclGetName]]

Latest revision as of 18:23, 21 February 2021

Get the name of given ACL.

Syntax

string aclGetName ( acl theAcl )

OOP Syntax Help! I don't understand this!

Method: acl:getName(...)
Variable: .name


Required Arguments

  • theACL: The ACL to get the name of

Returns

Returns the name of the given ACL as a string if successful. Returns false/nil if unsuccessful, ie the ACL is invalid.

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