GetAccounts: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(OOP syntax added)
m (→‎Syntax: OOP)
Line 6: Line 6:
table getAccounts ()
table getAccounts ()
</syntaxhighlight>
</syntaxhighlight>
{{OOP||Account.getAll||}}
{{OOP|This function is also a static function underneath the Account class.|[[account]]:getAll||}}
===Returns===
===Returns===
A [[table]] over the accounts that exist in the server internal.db file. This table might be empty.
A [[table]] over the accounts that exist in the server internal.db file. This table might be empty.

Revision as of 16:00, 22 August 2014

This function returns a table over all the accounts that exist in the server internal.db file. (Note: accounts.xml is no longer used after version 1.0.4)

Syntax

table getAccounts ()

OOP Syntax Help! I don't understand this!

Note: This function is also a static function underneath the Account class.
Method: account:getAll(...)


Returns

A table over the accounts that exist in the server internal.db file. This table might be empty.

Example

function printAmountOfAccounts ( thePlayer )
    local accountTable = getAccounts () -- return the table over accounts
    if #accountTable == 0 then -- if the table is empty
        outputChatBox( "There are no accounts. :(", thePlayer )
    else -- table isn't empty
        outputChatBox( "There are " .. #accountTable .. " accounts in this server!", thePlayer )
    end
end
addCommandHandler( "accountcount", printAmountOfAccounts ) -- add a command handler for command 'accountcount'

See Also