По какой-то причине хоть я и запрашиваю 225 последних транзакций, в список выводится от 30 до 50, в чем может быть причина?
IGS.GetTransactions(function(data)
local summary = {}
local totalTransactions = 0
local notes = {}
local totalNotes = 0
for i, transaction in ipairs(data) do
if string.match(transaction.Note, "^P:") then
local cleanNote = string.match(transaction.Note, "P: (%S+)")
if cleanNote then
table.insert(notes, cleanNote)
summary[cleanNote] = (summary[cleanNote] or 0) + 1
totalTransactions = totalTransactions + 1
end
end
end
local sortedItems = {}
for k, v in pairs(summary) do
table.insert(sortedItems, {name=k, count=v})
end
table.sort(sortedItems, function(a, b) return a.count > b.count end)
local msg = "=== СТАТИСТИКА ПОКУПОК ===\n"
msg = msg .. "Общее количество транзакций: " .. totalTransactions .. "\n"
msg = msg .. "Самые популярные покупки:\n"
for i, item in ipairs(sortedItems) do
local percent = (item.count / totalTransactions) * 100
msg = msg .. item.name .. " - " .. string.format("%.2f", percent) .. "% (" .. item.count .. " раз)\n"
totalNotes = totalNotes + item.count
end
msg = msg .. "=========================="
print(msg)
--[[ for _, ply in ipairs(player.GetAll()) do
if ply:IsSuperAdmin() then
ply:PrintMessage(HUD_PRINTCONSOLE, msg)
end
end --не работает из за лимита в 225 на нет сообщение
]]
file.Write("data_transactions.txt", msg)
end, nil, true, 225)