From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This function returns a table over all the objects that exist in a given ACL group. These are objects like players and resources.


table aclGroupListObjects ( aclgroup theGroup )

OOP Syntax Help! I don't understand this!

Method: aclgroup:listObjects(...)
Variable: .objects

Required Arguments

  • theGroup: The ACL group to get the objects from


Returns a table of strings in the given ACL group. This table might be empty. Returns false or nil if theGroup is invalid or it fails for some other reason.


This example outputs a list of Objects if the ACL Group is given

Click to collapse [-]
Example 1: Server
	if aclGroup == '' then
		outputChatBox("Please add the aclGroup you want the list of.", player)
		outputChatBox("Syntax: /aclObjectList aclGroup", player)
	local objects = aclGroupListObjects(aclGetGroup(aclGroup))
	for k,v in ipairs(objects) do
		outputChatBox("ACL LIST: "..aclGroup.." #"..k.." Object: "..v,player)

This example outputs through the command "getAdminAccounts" all accounts added to the "Admin" group.

Click to collapse [-]
Example 2: Server
function outputAdminGroupAccounts(player)
	local admins = {} -- creates the table in which will be added the accounts of "Admin" group
	local group = aclGetGroup("Admin")
	-- should return the "aclgroup" if the "Admin" group be found in ACL
	if not group then return end
	for _, object in ipairs(aclGroupListObjects(group) or {}) do
		local objType = gettok( object, 1, string.byte('.') )
		-- objType: gets the object type only, which can be either "user" or "resource"
		if objType == "user" then -- checks if it's a player account
			local _name = gettok( object, 2, string.byte('.') ) -- ignores "user." by separating that from the account name
			table.insert( admins, _name ) -- adds the account name to the "admins" table
    for i, name in ipairs(admins) do -- loop through the table "admins"
        outputChatBox(tostring(i).." : "..tostring(name), player, 140, 220, 140)
        -- output will look like this: "1 : John"
addCommandHandler("getAdminAccounts", outputAdminGroupAccounts)
-- adds the command "getAdminAccounts" and attaches it to the function "outputAdminGroupAccounts"

See Also