ZH-CN/GetAllAccountData: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server function}} This function returns a table containing all the user data for the account provided ==Syntax== <syntaxhighlight lang="lua"> table getAllAccou...")
 
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server function}}
{{Server function}}
This function returns a table containing all the user data for the [[account]] provided
此函数返回一个表,其中包含所提供帐户[[account]]的所有用户数据
==Syntax==
==语法==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
table getAllAccountData ( account theAccount )
table getAllAccountData ( account theAccount )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[account]]:getAllData|data|}}
{{OOP_ZH-CN||[[account]]:getAllData|data|}}
===Required Arguments===  
===Required Arguments===  
*'''theAccount:''' The account you wish to retrieve all data from.
*'''theAccount:''' 要从中调取所有数据的帐户


===Returns===
===Returns===
A [[table]] containing all the user data. This table might be empty.
包含所有用户数据的[[]]。这张桌子可能是空的.


==Example==
==Example==

Revision as of 06:54, 4 February 2021

此函数返回一个表,其中包含所提供帐户account的所有用户数据

语法

table getAllAccountData ( account theAccount )

OOP 语法 什么是OOP?

方法: account:getAllData(...)
变量: .data

Required Arguments

  • theAccount: 要从中调取所有数据的帐户

Returns

包含所有用户数据的。这张桌子可能是空的.

Example

function printAllData ( thePlayer )
    local playerAccount = getPlayerAccount( thePlayer ) -- get his account
    if ( playerAccount ) then -- if we got the account then
        local data = getAllAccountData( playerAccount ) -- get data
        count = 0
        for _ in pairs(data) do count = count + 1 end -- get the count
        outputChatBox ( "table holds " .. count .. " entries" ) -- output number of rows
        if ( data ) then
            for k,v in pairs ( data ) do
                outputChatBox(k..": "..v) -- print the key and value of each entry of data
            end
        end
    end
end
addCommandHandler( "getall", printAllData ) -- add a command handler for command 'getall'

Requirements

Minimum server version 1.3.0-9.03804
Minimum client version n/a

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.3.0-9.03804" />

See Also