ZH-CN/GetAllAccountData: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 11: Line 11:


===返回值===
===返回值===
包含所有用户数据的[[表]]。这张桌子可能是空的.
包含所有用户数据的[[表]]。这张表可能是空的.


==示例==
==示例==

Revision as of 08:02, 5 February 2021

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

语法

table getAllAccountData ( account theAccount )

OOP 语法 什么是OOP?

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

必填参数

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

返回值

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

示例

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

This template will be deleted.

See Also