READ THE RULES
0 Members and 1 Guest are viewing this topic.
--[[ TopHubbers 2.02 - LUA 5.0/5.1 by jiten ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ Based on: OnHub Time Logger 1.65 by chill and Robocop's layout Usage: !tophubbers; !tophubbers x-y; !hubtime <nick>; !myhubtime CHANGELOG: ¯¯¯¯¯¯¯¯¯¯ Fixed: Typo in table.sort function; Added: OnExit (3/21/2006) Fixed: Missing pairs() in SaveToFile Changed: Removed iGlobalTime and added TotalTime count to OnTimer Changed: SecondsToTime function values (3/24/2006) Changed: math.floor/mod in TopHubbers' function; (3/5/2006) Changed: SecondsToTime month value (4/17/2006); Added: !hubtime <nick> - requested by speedX; Changed: SecondsToTime function and small code bits (8/16/2006) Changed: Table indexes; Changed: SecondsToTime function to MinutesToTime; Fixed: Inaccurate average uptime stuff (8/17/2006) Changed: Average uptime function; Changed: Session time for offline users doesn't get reset; Added: Average uptime warning on connect - requested by speedX (8/20/2006) Added: Customized profiles - requested by Naithif (8/20/2006) Added: User Commands - requested by TT; Added: Rankings and related commands [!myrank & !topranks] - requested by speedX; Added: Toggle rank info on connect - requested by TT; Fixed: !tophubbers x-y; Added: Comments to the code; Changed: Some code bits; Added: Toggle between total and average uptime (8/24/2006) Fixed: Minimum average uptime warning - reported by speedX; Added: Maximum shown hubbers - requested by Naithif (8/29/2006) Fixed: LUA 5.0/5.1 compatibility - reported by speedX (11/8/2006) Added: string.lower check - requested by SwapY and speedX (11/10/2006)]]--
When I close the hub and re-open Ptokax, script losts data:
There is again a problem:Day(s) count doesn't works: when a user stay online for more than 24 hours then "day(s)" is still "0" and "minutes(s)" and "hour(s)" restart from 0.
Just a little detail:Session time stop at 59 mins: when a user stay in the hub for more than 1 hours, session time count restart from 0 min (I can suppose "session time hours count" don't works)Thanks,bye
--[[ TopHubbers 1.2 - LUA 5.0/5.1 by jiten Based on OnHub Time Logger 1.65 by chill and Robocop's layout Usage: !tophubbers; !tophubbers x-y Fixed: Typo in table.sort function; Added: OnExit (3/21/2006) Fixed: Missing pairs() in SaveToFile Changed: Removed iGlobalTime and added TotalTime count to OnTimer Changed: SecondsToTime function values (3/24/2006) Changed: math.floor/mod in TopHubbers' function; (3/5/2006) Changed: SecondsToTime month value (4/17/2006); Added: !hubtime <nick> - requested by speedX; Changed: SecondsToTime function and small code bits (8/16/2006)]]--sBot = frmHub:GetHubBotName()fOnline = "tOnliners.tbl"tOnline = {}Main = function() if loadfile(fOnline) then dofile(fOnline) end SetTimer(60*1000) StartTimer()end OnTimer = function() for i, v in pairs(tOnline) do if GetItemByName(i) then v.iSessionTime = v.iSessionTime + 1; v.iTotalTime = v.iTotalTime + 1 end endendOnExit = function() SaveToFile(fOnline, tOnline, "tOnline")endNewUserConnected = function(user) if user.bRegistered then if tOnline[user.sName] then tOnline[user.sName].iSessionTime = 0; tOnline[user.sName].sEnter = os.date() else tOnline[user.sName] = { sEnter = os.date(), iSessionTime = 0, iTotalTime = 0, sLeave = os.date() } end endendOpConnected = NewUserConnectedUserDisconnected = function(user) if user.bRegistered and tOnline[user.sName] then tOnline[user.sName].iSessionTime = 0; tOnline[user.sName].sLeave = os.date() endendOpDisconnected = UserDisconnectedChatArrival = function(user,data) local _,_, cmd = string.find(data,"^%b<>%s+%!(%S+).*|$") if cmd and tCmds[string.lower(cmd)] then cmd = string.lower(cmd) if tCmds[cmd].tLevels[user.iProfile] then return tCmds[cmd].fFunction(user, data),1 else return user:SendData(sBot, "*** Error: You are not allowed to use this command!"),1 end endendtCmds = { tophubbers = { fFunction = function(user, data) if next(tOnline) then local _,_, iStart, iEnd = string.find(data, "^%b<>%s+%S+%s+(%d+)%-(%d+)|$") iStart, iEnd = (iStart or 1), (iEnd or 20) local tCopy, msg = {}, "\r\n\t"..string.rep("=", 105).."\r\n\tNr. Total:\t\t\t\t\tSession:\t".. "Entered Hub:\tLeft Hub:\t\tStatus:\tName:\r\n\t"..string.rep("-", 210).."\r\n" for i, v in pairs(tOnline) do table.insert(tCopy, { sEnter = v.sEnter, iSessionTime = tonumber(v.iSessionTime), iTotalTime = tonumber(v.iTotalTime), sLeave = v.sLeave, sNick = i } ) end table.sort(tCopy, function(a, b) return (a.iTotalTime > b.iTotalTime) end) for i, v in pairs(tCopy) do local sStatus = "*Offline*"; if GetItemByName(v.sNick) then sStatus = "*Online*" end msg = msg.."\t"..i..". "..SecondsToTime(v.iTotalTime*60).."\t".. v.iSessionTime.." min\t"..v.sEnter.."\t"..v.sLeave.."\t"..sStatus.."\t"..v.sNick.."\r\n" end msg = msg.."\t"..string.rep("-", 210) user:SendPM(sBot, "Current Top Hubbers:\r\n"..msg.."\r\n") else user:SendData(sBot, "*** Error: Top Hubbers' table is currently empty!") end end, tLevels = { [-1] = 0, [0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 1, }, }, hubtime = { fFunction = function(user, data) local _,_, nick = string.find(data, "^%b<>%s+%S+%s+(%S+)|$") if nick then if tOnline[nick] then user:SendData(sBot, "*** "..nick.."'s Total uptime: ".. SecondsToTime(tOnline[nick].iTotalTime*60, true).."; Daily average uptime: ".. SecondsToTime(tOnline[nick].iTotalTime/(24*60), true)) else user:SendData(sBot, "*** Error: No record found for '"..nick.."'!") end else user:SendData(sBot, "*** Syntax Error: Type !hubtime <nick>") end end, tLevels = { [0] = 1, [1] = 1, [4] = 1, [5] = 1, }, },}SecondsToTime = function(iSeconds, bSmall) local T = os.date("!*t", tonumber(iSeconds)); string.gfind = (string.gfind or string.gmatch) local sTime = string.format("%i month(s), %i day(s), %i hour(s), %i minute(s)", T.month-1, T.day-1, T.hour, T.min) if bSmall then for i in string.gfind(sTime, "%d+") do if tonumber(i) == 0 then sTime = string.gsub(sTime, "^"..i.."%s(%S+),%s", "") end end end return sTimeendSerialize = 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
jiten use [ CODE] and [ /CODE], because actually is it impossible copy your first post with new script, you can copy but when you paste it you see all script in one line, edit your post with correct form
What happen if I use old tOnline.tbl with this new version?
--[[ Top Hubbers 1.1x to 1.21 DB Converter by jiten (8/17/2006) Requested by: -SkA- Changelog: 1. Place your old tOnliners.tbl under your scripts' folder; 2. Run this script and the new file "tOnliners(new).tbl" will appear in the same folder; 3. Backup your old DB (just in case) and rename the new one to the default format. 4. And that's it!]]---- File to convertfConvert = "tOnliners.tbl"-- Output filefConverted = "tOnliners(new).tbl"tConvert = {}Main = function() if loadfile(fConvert) then dofile(fConvert) end; tConvert = tOnline for i, v in pairs(tOnline) do tConvert[i].Julian = os.time(os.date("!*t")) end local hFile = io.open(fConverted, "w+") Serialize(tConvert, "tOnline", hFile); hFile:close() 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.."}");end
Your AHT is less then 1 hr....we are planning to impose restrictions to users with AHT less than 1 hr
The addition would be like......if a users AHT is less than 1 hour.... then when tht user logins in the hub......he will get this message in PM..
great script jitten i build it into leviathan 2.8 and works great
It would be nice if it would be toggleable if it registers reg's only or users too
Can there be a selectable min time for the script, so that won't log user's under a that min. time?
according to AHT...coz it is daily uptime....and it is easy to select the time also...as AHT is less......but in THT u will get promoted faster.....tht's y....
Nick: speedX THT: 1 weeks, 2 days, 13 hours, 41 minutes AHT: 1 hours, 12 minutes
actually its not tht easy to attain an AHT of 24 hrs....coz in one of my hubs ....my hubtime is....I am reg here for more than an year..