READ THE RULES
0 Members and 1 Guest are viewing this topic.
--[[]]--Records = {}local f,e = io.open("Record.tbl", "a+" )if f then f:write("" ) f:close()enddofile("Record.tbl")Main =function() SetTimer(10*1000) StartTimer()endOnTimer = function() if Records.share then -- if table found if tonumber(Records.share or 0) < frmHub:GetCurrentShareAmount() then -- is current total share bigger than in table Records["share"] = frmHub:GetCurrentShareAmount() -- if it was we write it SaveToFile("Record.tbl",Records, "Records") -- and save it end if tonumber(Records.users or 0) < frmHub:GetUsersCount() then -- is current usercount bigger than in table Records["users"] = frmHub:GetUsersCount() -- if it was we write it SaveToFile("Record.tbl",Records, "Records") -- and save it end if tonumber(Records.uptime or 0) < frmHub:GetUpTime() then -- is current uptime bigger than in table Records["uptime"] = frmHub:GetUpTime() -- if it was we write it SaveToFile("Record.tbl",Records, "Records") -- and save it end else -- if table was not found Records = {uptime = frmHub:GetUpTime(),share = frmHub:GetCurrentShareAmount(),users = frmHub:GetUsersCount()} -- we do table SaveToFile("Record.tbl",Records, "Records") -- and save it end collectgarbage("collect")endSerialize = function(tTable,sTableName,hFile,sTab) sTab = sTab or "" hFile:write(sTab..sTableName.." = {\n") for key,value in pairs(tTable) do if (type(value) ~= "function") then local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key) if(type(value) == "table") then Serialize(value,sKey,hFile,sTab.."\t") else local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value) hFile:write(sTab.."\t"..sKey.." = "..sValue) end hFile:write(",\n") end end hFile:write(sTab.."}")endSaveToFile = function(file,table,tablename) local hFile = io.open(file,"w+") Serialize(table,tablename,hFile) hFile:close() end