PtokaX forum

Archive => Archived 5.1 boards => Finished Scripts => Topic started by: jiten on 21 March, 2006, 18:39:53

Title: Top Hubbers
Post by: jiten on 21 March, 2006, 18:39:53
--[[

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)

]]--
Title: Re: Top Hubbers
Post by: -SkA- on 21 March, 2006, 21:02:46
Thanks again  ;)
Posted on: 21 March 2006, 20:30:35
hemm jiten, it works fine but when I stop hub, it losts all data  :(
Title: Re: Top Hubbers
Post by: jiten on 21 March, 2006, 21:14:11
First post updated with the bugfix.
Title: Re: Top Hubbers
Post by: -SkA- on 22 March, 2006, 10:02:58
ok  :)
Posted on: 21 March 2006, 22:34:16
Again a problem eheh

When Ptokax run, !tophubbers said:

   =========================================================================================================
   Nr.  Total:               Session:   Entered Hub:   Left Hub:      Status:   Name:
   ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   1.    0 month(s), 0 day(s), 0 hour(s), 2 minutes(s)   2 min   03/22/06 09:56:53   03/22/06 09:55:26   *Online*   -SkA-
   -----------------------------------------------------------------------------------------------------------------------------------------------------------------

When I close the hub and re-open Ptokax, script losts data:

   =========================================================================================================
   Nr.  Total:               Session:   Entered Hub:   Left Hub:      Status:   Name:
   ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   1.    0 month(s), 0 day(s), 0 hour(s), 0 minutes(s)   0 min   03/22/06 09:59:31   03/22/06 09:55:26   *Online*   -SkA-
   ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Title: Re: Top Hubbers
Post by: jiten on 22 March, 2006, 17:48:03
Quote from: -SkA- on 22 March, 2006, 10:02:58
When I close the hub and re-open Ptokax, script losts data:
The file saving issue was solved in the previous update.
With this one, I've changed the way TotalTime is counted.

Cheers
Title: Re: Top Hubbers
Post by: -SkA- on 24 March, 2006, 08:03:29
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.
Title: Re: Top Hubbers
Post by: jiten on 24 March, 2006, 17:10:57
Quote from: -SkA- on 24 March, 2006, 08:03:29
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.

Day count worked. It's just that the function that converted it to a readable format wasn't well defined.
I've updated the code once again.

Cheers
Title: Re: Top Hubbers
Post by: jiten on 24 March, 2006, 17:57:37
Thank you for your words, mate :)
Title: Re: Top Hubbers
Post by: -SkA- on 26 March, 2006, 18:36:33
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
Title: Re: Top Hubbers
Post by: jiten on 26 March, 2006, 20:07:21
Quote from: -SkA- on 26 March, 2006, 18:36:33
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

First post updated once more.
Title: Top Hubbers 1.2 - LUA 5.0/5.1
Post by: jiten on 16 August, 2006, 21:02:43
First post has been updated with some changes in the code.
Title: Re: Top Hubbers
Post by: 6Marilyn6Manson6 on 16 August, 2006, 22:07:51
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 :)
Posted on: 16 August 2006, 23:02:36
I have copied your post jiten with success. I have made quote and I have copied script from it,

--[[

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
end
end

OnExit = function()
SaveToFile(fOnline, tOnline, "tOnline")
end

NewUserConnected = 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
end
end

OpConnected = NewUserConnected

UserDisconnected = function(user)
if user.bRegistered and tOnline[user.sName] then
tOnline[user.sName].iSessionTime = 0; tOnline[user.sName].sLeave = os.date()
end
end

OpDisconnected = UserDisconnected

ChatArrival = 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
end
end

tCmds = {
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 sTime
end

Serialize = 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

SaveToFile = function(file, table, tablename)
local hFile = io.open(file, "w+") Serialize(table, tablename, hFile); hFile:close()
end


This is correct form for post script :p
Title: Re: Top Hubbers
Post by: jiten on 16 August, 2006, 22:17:43
Quote from: 6Marilyn6Manson6 on 16 August, 2006, 22:02:36
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 :)

Thanks for speedX, yours and T?M??r?V?ll?R's report.

First post has been updated with the correct syntax.
Title: Re: Top Hubbers
Post by: 6Marilyn6Manson6 on 16 August, 2006, 22:43:28
 :D
Title: Re: Top Hubbers
Post by: speedX on 17 August, 2006, 05:36:12
Yo jiten, u rock dude. This is wat i wantd, it works fine....
well thx again......
Title: Re: Top Hubbers
Post by: -SkA- on 17 August, 2006, 08:06:53
What happen if I use old tOnline.tbl with this new version?
Title: Re: Top Hubbers
Post by: 6Marilyn6Manson6 on 17 August, 2006, 08:43:30
Possible error :D
Title: Re: Top Hubbers
Post by: jiten on 17 August, 2006, 11:17:23
Quote from: -SkA- on 17 August, 2006, 08:06:53
What happen if I use old tOnline.tbl with this new version?

You'll get some syntax errors [nil value].

I'll post a 1.1x - 1.2x DB converter later today to fix this issue.
Title: TopHubbers 1.21 - LUA 5.0/5.1
Post by: jiten on 17 August, 2006, 15:48:24
First post has been updated with some fixes to the code.
Title: Top Hubbers 1.1x to 1.21 DB Converter
Post by: jiten on 17 August, 2006, 15:56:26
This script will convert the database from versions 1.1x to 1.21.

However, for an accurate Daily average uptime, I'd recommend you to start from the beginning.

--[[

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 convert
fConvert = "tOnliners.tbl"
-- Output file
fConverted = "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()
end

Serialize = 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
Title: Re: Top Hubbers
Post by: speedX on 19 August, 2006, 19:33:17
hey actually i would like some addition in this script......

This script contains AHT (Average hub time). The addition would be like, if a users AHT is less than 1 hour then when that user logins in the hub, he will get this message in PM..

Quote
Your AHT is less then 1 hr....we are planning to impose restrictions to users with AHT less than 1 hr

......THANK YOU
Title: Re: Top Hubbers
Post by: TiMeTrAVelleR on 19 August, 2006, 21:44:03
great script jitten  i build  it into  leviathan 2.8     and  works  great :)


greets    TT
Title: Re: Top Hubbers
Post by: jiten on 20 August, 2006, 10:51:39
Quote from: speedX on 19 August, 2006, 19:33:17
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..

I'll be posting this extra feature later today.

Quote from: T?M?†r?V?ll?R on 19 August, 2006, 21:44:03
great script jitten  i build  it into  leviathan 2.8     and  works  great :)

I'm glad you like it :P
Title: Re: Top Hubbers
Post by: -SkA- on 20 August, 2006, 11:52:47
Great job Jiten (as usual)  ;D
Title: Re: Top Hubbers
Post by: speedX on 20 August, 2006, 12:24:12
yup u rock jiten dude...
Title: TopHubbers 1.22 - LUA 5.0/5.1
Post by: jiten on 20 August, 2006, 13:00:30
First post has been updated once more with some changes.
Title: Re: Top Hubbers
Post by: speedX on 21 August, 2006, 15:42:49
Man Jiten.....wat should i say....u have proved ur self dude...u r a cool scripter  8)
Posted on: 20 August 2006, 18:31:59
Hey jiten....jus have a look here

http://forum.ptokax.org/index.php?topic=6274#msg62067 (http://forum.ptokax.org/index.php?topic=6274#msg62067)
Title: Re: Top Hubbers
Post by: Naithif on 21 August, 2006, 20:20:30
Hi all

It would be nice if it would be toggleable if it registers reg's only or users too
Another nice option if the above can be done that - Can there be a selectable min time for the script, so that won't log user's under a that min. time?

Thanks for any reply, nice script
Title: Re: Top Hubbers
Post by: jiten on 22 August, 2006, 14:29:37
Quote from: Naithif on 21 August, 2006, 20:20:30
It would be nice if it would be toggleable if it registers reg's only or users too

It will be added in the next release.

Quote from: Naithif on 21 August, 2006, 20:20:30
Can there be a selectable min time for the script, so that won't log user's under a that min. time?

That's a nice feature for an upcoming version.
However, it won't be part of the next release, as I need to add the Rankings' request first.
Title: Re: Top Hubbers
Post by: Naithif on 22 August, 2006, 17:34:34
Hi

Thanks for the reply, i like this script  :)
Good work  ;D
Title: Re: Top Hubbers
Post by: jiten on 23 August, 2006, 18:19:52
I have a question for you guys:

Should the ranking system be based on Total uptime or Average uptime in days?
Title: Re: Top Hubbers
Post by: speedX on 24 August, 2006, 17:13:27
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....
Title: Re: Top Hubbers
Post by: jiten on 24 August, 2006, 17:27:25
Quote from: speedX on 24 August, 2006, 17:13:27
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....

Well, with AHT the rank limit can't be higher than 24 hours.

However, with THT it's easier to establish a fixed limit for every rank [just like it happens in both PX LUA boards].

More thoughts?
Title: Re: Top Hubbers
Post by: speedX on 24 August, 2006, 17:32:40
actually its not tht easy to attain an AHT of 24 hrs....coz in one of my hubs ....my hubtime is....

Quote
Nick: speedX   THT: 1 weeks, 2 days, 13 hours, 41 minutes   AHT: 1 hours, 12 minutes

I am reg here for more than an year..
Title: Re: Top Hubbers
Post by: jiten on 24 August, 2006, 21:16:46
Quote from: speedX on 24 August, 2006, 17:32:40
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..

Well, I'll release a version that supports both Average and Total uptime rank system then.
Title: TopHubbers 2.0 - LUA 5.0/5.1
Post by: jiten on 28 August, 2006, 20:40:37
First post has been updated with significant changes in the code.
Title: Re: Top Hubbers
Post by: speedX on 28 August, 2006, 21:28:47
I knew it it tht u would make it.....thank u jiten.....but i would like if the post of the user comes in tht particular users description......in brackets...

like this.

speedX    [Newbie]
Title: Re: Top Hubbers
Post by: jiten on 29 August, 2006, 10:18:33
Quote from: speedX on 28 August, 2006, 21:28:47
but i would like if the post of the user comes in tht particular users description......in brackets...

That won't be possible as we would need to modify every user's MyINFO and that is surely a bandwidth and resource hog.
Title: Re: Top Hubbers
Post by: speedX on 29 August, 2006, 15:16:53
k np dude....but really jiten u have made a gr8 script....i jus went on placing my ideas...and u went on adding thm....well thx dude...
Posted on: 29 August 2006, 15:34:14
ohh....facing prob....

Quote

   -- Send message to users with lower than specified Average uptime (AUT) [true = on; false = off]
   bWarning = true,
   -- Minimum Average uptime (hours) that triggers the warning
   iAUT = 1,

   -- Send hubtime stats on connect [true = on; false = off]
   bRankOnConnect = true,

   -- Profiles checked [0 = on; 1 = off]
   tProfiles = {
  • = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0 },
i made tht bwarning = true  .....thn also it is not showing tht warn message.....wat is the prob???
Title: Re: Top Hubbers
Post by: TiMeTrAVelleR on 29 August, 2006, 16:06:16
lol  i now for sure if i got in a hub warning that my average uptime wasent good    il eft hub forgood

:o
Title: Re: Top Hubbers
Post by: jiten on 29 August, 2006, 16:09:51
Quote from: speedX on 29 August, 2006, 15:16:53
i made tht bwarning = true  .....thn also it is not showing tht warn message.....wat is the prob???

Thanks for the report. There was a small problem with the 'formulas'.

In your NewUserConnected function, replace this line:

if tOnline[user.sName].TotalTime/iAverage < tSettings.iAUT then

with this one:

if tOnline[user.sName].TotalTime/iAverage < tSettings.iAUT*60 then

By the way, I'll update the whole package later today.
Title: Re: Top Hubbers
Post by: speedX on 29 August, 2006, 17:12:03
tel me when u finish updating it.....
Title: Re: Top Hubbers
Post by: Naithif on 29 August, 2006, 20:00:59
Hi all

LOL

Quote from: JueLz on 29 August, 2006, 19:21:06
Yes... i am also curious
Quote from: speedX on 29 August, 2006, 17:12:03
tel me when u finish updating it.....

You should be grateful it's still developed, unlike a lots of things in the Direct Connect world....

Anyway, i would like to ask another feature:
A limit in the listlength if it's possible (for example if someone only want to show the top 10 hubbers or something like that  ;D)

And i would like to thank jiten for his fine script. Nice work  ;)
Title: Re: Top Hubbers
Post by: jiten on 29 August, 2006, 20:46:20
Quote from: Naithif on 29 August, 2006, 20:00:59
A limit in the listlength if it's possible (for example if someone only want to show the top 10 hubbers or something like that  ;D)

Will be added in the next update, and don't mention it. You're welcome :)
Title: TopHubbers 2.01 - LUA 5.0/5.1
Post by: jiten on 30 August, 2006, 15:36:11
First post has been updated once more.
Title: Re: Top Hubbers
Post by: speedX on 30 August, 2006, 17:33:40
Done.....working fine......thank u
Title: Re: Top Hubbers
Post by: Naithif on 05 September, 2006, 22:17:32
Hi again

Quote from: Naithif on 21 August, 2006, 20:20:30
Another nice option if the above can be done that - Can there be a selectable min time for the script, so that won't log user's under a that min. time?

(beady little eyes) Please? ::)

Thanks for any help or advice  ;D
Title: Re: Top Hubbers
Post by: jiten on 08 September, 2006, 21:37:44
Quote from: Naithif on 05 September, 2006, 22:17:32
Another nice option if the above can be done that - Can there be a selectable min time for the script, so that won't log user's under a that min. time?

That could be done.

However, I don't think that it's recommended as we would always need to log every
user's info and then run a cleaner on timer to check if he's an 'unwanted' and if he has
reached that specified value or not.

Suppose that he doesn't login for a year and he hasn't reached that minimum value,
his info would remain in the database [though, not showed].

That's why I prefer not to add this request and I hope you understand. Sorry for that.
Title: Re: Top Hubbers
Post by: speedX on 13 September, 2006, 16:42:28
Quote from: speedX on 28 August, 2006, 21:28:47
but i would like if the post of the user comes in tht particular users description......in brackets...

hey jiten is it possible to combine the tag description script with this one(tophubbers) as u combined the Hubranks and tophubbers.......
Title: Re: Top Hubbers
Post by: Naithif on 13 September, 2006, 20:27:41
Quote from: speedX on 13 September, 2006, 16:42:28
hey jiten is it possible to combine the tag description script with this one(tophubbers) as u combined the Hubranks and tophubbers.......

An old quote came to my mind ;D
Something about "bandwidth" and "resources"  ;D ;D ;D
Title: Re: Top Hubbers
Post by: jiten on 13 September, 2006, 21:48:09
Quote from: Naithif on 13 September, 2006, 20:27:41
An old quote came to my mind ;D
Something about "bandwidth" and "resources"  ;D ;D ;D

Indeed :P

As I posted earlier:

QuoteThat won't be possible as we would need to modify every user's MyINFO and that is surely a bandwidth and resource hog.
Title: Re: Top Hubbers
Post by: Naithif on 15 September, 2006, 19:12:30
Hi

   -- Profiles checked [0 = on; 1 = off]
   tProfiles = {
Title: Re: Top Hubbers
Post by: JueLz on 15 September, 2006, 20:30:40
Should that be The other way around?
Title: Re: Top Hubbers
Post by: jiten on 15 September, 2006, 20:38:16
Quote from: Naithif on 15 September, 2006, 19:12:30
Hi

   -- Profiles checked [0 = on; 1 = off]
   tProfiles = {
Oops... where was my head at? :P
Title: Re: Top Hubbers
Post by: speedX on 16 September, 2006, 10:32:19
hey but the script works.....he just replaced the place of on & off bymistake.... :D
Title: Re: Top Hubbers
Post by: nEgativE on 22 September, 2006, 16:16:35
Hello all, excelente work jiten  :)
Is it possible to send info on connect ? like..
[Scripter]Jiten, Hello, your total uptime is blabla :)
[Scripter]Jiten, your rank is something :)
i see there is a bRankOnConnect but just for UserCommands i think.

Thx in advance.
Title: Re: Top Hubbers
Post by: jiten on 22 September, 2006, 18:24:49
Quote from: [PT]nEgativE on 22 September, 2006, 16:16:35
Is it possible to send info on connect ? like..
[Scripter]Jiten, Hello, your total uptime is blabla :)
[Scripter]Jiten, your rank is something :)
i see there is a bRankOnConnect but just for UserCommands i think.

Well, that option you mentioned does this: Send hubtime stats on connect [true = on; false = off]

This is an example of what you'll get on connect:

Quote[18:21:46] <PtokaX>

   ========================================
         Stats:
   --------------------------------------------------------------------------------
   - Nick: jiten
   - Total uptime: 7 minute(s)
   - Daily average uptime: 7 minute(s)
   - Current Rank: Newbie
Title: Re: Top Hubbers
Post by: ollobollo on 23 September, 2006, 16:55:35
well programmed script, respect, but there is a little problem since i want to change the imax= 20 into 40. the rightclick shows the 40 but in pm there are only 20 tophubbers shown. can you help me where i can solve this little problem?

regards

ollo

Quote-- Maximum hubbers to show when using !tophubbers
   iMax = 40,

   -- Send message to users with lower than specified Average uptime (AUT) [true = on; false = off]
   bWarning = true,
   -- Minimum Average uptime (hours) that triggers the warning
   iAUT = 1,


problem is found, thx
Title: Re: Top Hubbers
Post by: jiten on 30 September, 2006, 12:10:21
Quote from: ollobollo on 23 September, 2006, 16:55:35
there is a little problem since i want to change the imax= 20 into 40. the rightclick shows the 40 but in pm there are only 20 tophubbers shown. can you help me where i can solve this little problem?
problem is found, thx

Care to share with us how you solved this problem?
Title: Re: Top Hubbers
Post by: nEgativE on 30 September, 2006, 18:57:30
Quote from: jiten on 22 September, 2006, 18:24:49
Well, that option you mentioned does this: Send hubtime stats on connect [true = on; false = off]

This is an example of what you'll get on connect:


Yes jiten, it's working well.. my bad.
Excelente trabalho :)
Title: Re: Top Hubbers
Post by: ollobollo on 01 October, 2006, 14:54:08
jep, its very simple: i change the place in the scriptlist, before robo, now i see the right appearence of tophubbers-script, i think theres a conflict with the inbuilt tophubbers from robo.
Title: Re: Top Hubbers
Post by: speedX on 03 October, 2006, 18:23:25
hm..quiet possible.....
Posted on: 01 October 2006, 17:08:01
hey jiten...if ne user types !hubtime <nick> thn his hubtime comes above the command....i would like if it comes below it if possible.....
Title: Re: Top Hubbers
Post by: jiten on 03 October, 2006, 20:56:02
Quote from: speedX on 03 October, 2006, 18:23:25
hey jiten...if ne user types !hubtime <nick> thn his hubtime comes above the command....i would like if it comes below it if possible.....

Have a look at RegCleaner's thread and you'll see a similar change in the code that does this.
Title: Re: Top Hubbers
Post by: speedX on 03 October, 2006, 22:05:23
oh god.....y cant i do anythign rite.....srry but i messed the whole script....could u plzz edit and copy tht portion and paste it....plzzz
Title: Re: Top Hubbers
Post by: Herodes on 03 October, 2006, 22:22:04
Quote from: speedX on 03 October, 2006, 22:05:23
oh god.....y cant i do anythign rite.....srry but i messed the whole script....could u plzz edit and copy tht portion and paste it....plzzz
Get the script, a clean copy, and go through the thread again,...
Pasting and deleting at the points that were mentioned ;)
Title: Re: Top Hubbers
Post by: speedX on 03 October, 2006, 22:27:15
Quote
hubtime = {
      fFunction = function(user, data)
         -- Parse nick
         local _,_, nick = string.find(data, "^%S+%s+(%S+)$")
         -- Exists
         if nick then
            -- Return
            BuildStats(user, nick)
         else
            user:SendMessage(tSettings.sBot, "*** Syntax Error: Type !hubtime <nick>")
         end
      end,
      tLevels = {
         
  • = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 1,
          },
          tRC = { { "Show an user's stats", " %[line:Nick]" } }
       },
Where shud i paste SendToAll??? so tht i could get the result after the command.....
Title: Re: Top Hubbers
Post by: jiten on 04 October, 2006, 10:26:31
hubtime's function should be like this:

fFunction = function(user, data)
-- Parse nick
local _,_, nick = string.find(data, "^%S+%s+(%S+)$")
-- Exists
if nick then
-- Return
SendToAll(user.sName, data)
BuildStats(user, nick)
else
user:SendMessage(tSettings.sBot, "*** Syntax Error: Type !hubtime <nick>")
end
end,


You'll also need to replace your BuildStats function with this one:

BuildStats = function(user, nick)
-- In DB
if tOnline[nick] then
-- Average uptime in days
local iAverage = os.difftime(os.time(os.date("!*t")), tOnline[nick].Julian)/(60*60*24)
if iAverage < 1 then iAverage = 1 end
-- Generate message
local sMsg = "\r\n\r\n\t"..string.rep("=", 40).."\r\n\t\t\tStats:\r\n\t"..
string.rep("-", 80).."\r\n\t- Nick: "..nick.."\r\n\t- Total uptime: "..
MinutesToTime(tOnline[nick].TotalTime, true).."\r\n\t- Daily average uptime: "..
MinutesToTime((tOnline[nick].TotalTime/iAverage), true).."\r\n\t- Current Rank: "..GetRank(nick).."\r\n"
-- Send stats
SendToAll(tSettings.sBot, sMsg)
else
user:SendMessage(tSettings.sBot, "*** Error: No record found for '"..nick.."'!")
end
end


Notice that with these changes, if you've enabled the 'bRankOnConnect' option, every user's mainchat will be flooded with connecting users' stats. So, be careful.
Title: Re: Top Hubbers
Post by: speedX on 04 October, 2006, 14:40:46
nope....u again got it wrong......see all can see the command typed frm b4 only....i took tth setting made by u @ lua.uknet.com ........but the result comes above the command....i would like if it comes below the command......nothing else....
Title: Re: Top Hubbers
Post by: jiten on 04 October, 2006, 18:34:30
Quote from: speedX on 04 October, 2006, 14:40:46
nope....u again got it wrong......see all can see the command typed frm b4 only....i took tth setting made by u @ lua.uknet.com ........but the result comes above the command....i would like if it comes below the command......nothing else....

First of all, do read and test my previous reply to you post carefully with a clean copy of this script.

Then, you can say:

Quotenope....u again got it wrong......

However, at the moment, that won't be possible as those mods really do what you requested :P
Title: Re: Top Hubbers
Post by: speedX on 04 October, 2006, 23:35:42
Yup, done. Actually I had copied ur chat arrival table frm lua.uknnet.com. So, it was not showing the required result even after making the above changes. But when i used a new copy, it gave me a positive result. Thank you.
Posted on: 05 October 2006, 00:09:23
hey jiten, one more help dude
I dont kno wat to do if I want the command to come b4 the result.
here is the script:

Quote
--## Simple Time Bot
--## Requested by SteffJay
--## Made by nErBoS
--## Converted in LUA 5 by 6Marilyn6Manson6
--## Commands:
--##   !time - Gives the current time

sBot = "Time-Bot"

function ChatArrival(user, data)
   if (string.sub(data,1,1)=="<") or (string.sub(data,1,5+string.len(sBot))=="$To: "..sBot) then
      data = string.sub(data,1,string.len(data)-1)
      s,e,cmd = string.find(data,"%b<>%s+(%S+)")
      if (cmd == "!time") then
         user:SendData(sBot, GetTime())
      end
   end
end

function GetTime()
   s = os.date("%S")
   h = os.date("%H")
   m = os.date("%M")
   d = os.date("%d")
   mm = os.date("%m")
   y = os.date("%y")
   Date = "Date: "..d.."/"..mm.."/20"..y.."   Time: "..h..":"..m..":"..s
   return Date
end

and I would like if tht time comes in 12 hr clock format with AM and PM
I tried to put this code (%I:%M %p) but wat I found was errors, Could u help plzz
Title: Re: Top Hubbers
Post by: 6Marilyn6Manson6 on 05 October, 2006, 00:33:03
--## Simple Time Bot
--## Requested by SteffJay
--## Made by nErBoS
--## Converted in LUA 5 by 6Marilyn6Manson6
--## Commands:
--##   !time - Gives the current time

sBot = "Time-Bot"

function ChatArrival(user, data)
if (string.sub(data,1,1)=="<") or (string.sub(data,1,5+string.len(sBot))=="$To: "..sBot) then
data = string.sub(data,1,string.len(data)-1)
s,e,cmd = string.find(data,"%b<>%s+(%S+)")
if (cmd == "!time") then
user:SendData(sBot, GetTime())
end
end
end

function GetTime()
f = os.date("%p")
s = os.date("%S")
h = os.date("%l")
m = os.date("%M")
d = os.date("%d")
mm = os.date("%m")
y = os.date("%y")
Date = "Date: "..d.."/"..mm.."/20"..y.."   Time: "..h..":"..m..":"..s.."  "..f
return Date
end
Title: Re: Top Hubbers
Post by: speedX on 05 October, 2006, 06:26:34
hey 6M6M6 thx for the help, but ur script was showing me wrong time, for 9:52 AM it was showing 00:42 AM. I donno tht it is problem in script or frm side coz i was in a hurry, thn i tried Mutor's script, it is working well & btw wat is UTC mutor? and can u edit this script in such a way tht even if one user type's !time all shud be able to see command along with the result. Thank you
Title: Re: Top Hubbers
Post by: Thor on 05 October, 2006, 08:00:48
http://ro.4242.hu/cgi-bin/yabb2/YaBB.pl?num=1159443959 ;D
Quote from: speedX on 05 October, 2006, 06:26:34
hey 6M6M6 thx for the help.....but ur script was showing me wrong time.....for 9:52 AM it was showing 00:42 AM .......i donno tht it is problem in script or frm side coz i was in a hurry......
Maybe the server's clock didn't set up... Check it
Title: Re: Top Hubbers
Post by: speedX on 07 October, 2006, 23:15:48
Hey jiten, this tophubbers doesnt give result if the nick is given in small. Like for BLITZKRIEG, if i type !hubtime blitzkrieg, it shows nick not found.
And one user in my hub had first logged in with nick ShEvChEnKo7 and thn later SHEVCHENKO7 so there has been a double entry for this guy.

Quote
0 month(s), 9 day(s), 11 hour(s), 21 minute(s)   10460 min   09/06/06 20:50:24   09/06/06 21:35:56   Cool Member   *Online*   SHEVCHENKO7
and

0 month(s), 7 day(s), 5 hour(s), 34 minute(s)   5122 min   09/23/06 07:44:01   09/23/06 07:42:06   Cool Member   *Online*   ShEvChEnKo7



so now wat to do ??

Posted on: 05 October 2006, 19:42:07
hey guys, this is urgent for me. Could ne one fix it for lower case also? plz
Title: Re: Top Hubbers
Post by: Psycho_Chihuahua on 07 October, 2006, 23:47:08
could.......you please........stop posting.........like this?
Title: Re: Top Hubbers
Post by: jiten on 15 October, 2006, 21:27:10
Quote from: speedX on 05 October, 2006, 18:42:07
hey jiten.....this tophubbers doesnt give result if the nick is given in small......like for BLITZKRIEG if i type !hubtime blitzkrieg...it shows nick not found.....

and one user in my hub had first logged in with nick ShEvChEnKo7 and thn later SHEVCHENKO7 so there has been a double entry for this guy......

so now wat to do ??

I'd say that you'll have to use the exact nick when using the !hubtime command.

When a user changes his nick's case he must have a reason to do so, and in my point of view it should remain as a separate database entry.

Quote from: Mutor on 10 October, 2006, 23:56:11
You have to use the actual nick [case must match] else there are hub calls made and user objects used that might fail with improper case. Often it's fine to match in lower case. This is not one of those times.

Title: Re: Top Hubbers
Post by: Creative on 20 October, 2006, 16:49:35
Jiten, wen i type !tophubbers or !myhubtime, i get the foll error:
scripts\tophub.lua:86: attempt to compare number with nil

Wats the problem???
Title: Re: Top Hubbers
Post by: speedX on 27 October, 2006, 08:36:51
Hey jiten, sorry but bugging u for the last time :P
Is it possible to only show the command to all not the output??
Title: Re: Top Hubbers
Post by: achiever on 31 October, 2006, 11:47:50
hi,

sir this script is giving me error
[16:06] Syntax D:\ptokax\scripts\TopHubbers2.01.lua:328: attempt to perform arithmetic on local `iSeconds' (a nil value)
n its not showing me right click menu
also not showing my average hubtime
n the average hubtime of others also is the same as their session time
eg
========================================
         Stats:
   --------------------------------------------------------------------------------
   - Nick: leon
   - Total uptime: 7 minute(s)
   - Daily average uptime: 7 minute(s)
   - Current Rank: Newbie

but this persons total hub time is 0 months, 0 days, 2 hours, 55 minutes   leon

plzz can u help me sort this out , as i have no idea of srcipting

thks,

achiever.
Title: Re: Top Hubbers
Post by: speedX on 05 November, 2006, 08:42:30
Hey jiten,
this script is showing me the following error in Ptokax 0.3.5.2

Quote
[13:08] Syntax ...der\PtokaX DC Hub 0.3.5.2\scripts\TopHubbers2.01.lua:311: 'string.gfind' was renamed to 'string.gmatch'
Title: Re: Top Hubbers
Post by: -SkA- on 05 November, 2006, 09:33:01
Quote from: speedX on 05 November, 2006, 08:42:30
Hey jiten,
this script is showing me the following error in Ptokax 0.3.5.2


I'm using tophubbers (old version TopHubbers 1.21) with PX 0.3.5.2 and it's working fine, no errors.
Title: Re: Top Hubbers
Post by: speedX on 05 November, 2006, 10:12:49
Quote from: -SkA- on 05 November, 2006, 09:33:01
I'm using tophubbers (old version TopHubbers 1.21) with PX 0.3.5.2 and it's working fine, no errors.

But the version wich u r using, does it have all the commands of v2.01 ?? If yes thn plzz attach the script.
Title: Re: Top Hubbers
Post by: -SkA- on 05 November, 2006, 10:56:27
Quote from: speedX on 05 November, 2006, 10:12:49
But the version wich u r using, does it have all the commands of v2.01 ?? If yes thn plzz attach the script.

I really don't think so... I use that script only for !tophubbers command  ::)
Title: Re: Top Hubbers
Post by: Naithif on 05 November, 2006, 11:17:17
Quote from: speedX on 05 November, 2006, 08:42:30
Hey jiten,
this script is showing me the following error in Ptokax 0.3.5.2
Quote[13:08] Syntax ...der\PtokaX DC Hub 0.3.5.2\scripts\TopHubbers2.01.lua:311: 'string.gfind' was renamed to 'string.gmatch'

Just search for the word 'string.gfind' in the line 311 and rename it to 'string.gmatch' :)
Title: Re: Top Hubbers
Post by: speedX on 05 November, 2006, 14:46:42
Thank you dude, its working now.
Title: Re: Top Hubbers
Post by: jiten on 07 November, 2006, 19:11:21
Quote from: achiever on 31 October, 2006, 11:47:50
hi,

sir this script is giving me error
[16:06] Syntax D:\ptokax\scripts\TopHubbers2.01.lua:328: attempt to perform arithmetic on local `iSeconds' (a nil value)
n its not showing me right click menu
also not showing my average hubtime
n the average hubtime of others also is the same as their session time

Can you give me more details?

Are you using a previous Top Hubbers version's database?
If yes, you'll surely get several and different syntax errors.

Quote from: speedX on 05 November, 2006, 08:42:30
Hey jiten,
this script is showing me the following error in Ptokax 0.3.5.2

I'll update the whole code as soon as possible and make the script compatible with:

QuoteAdded: iLoginTime to userobject in lua.
Title: Re: Top Hubbers
Post by: Creative on 09 November, 2006, 06:38:47
hi jiten, wen i type !tophubbers the foll error comes:
TopHubbers2.01.lua:226: attempt to compare two nil values
Title: Re: Top Hubbers
Post by: jiten on 09 November, 2006, 10:08:35
Quote from: SwapY on 09 November, 2006, 06:38:47
hi jiten, wen i type !tophubbers the foll error comes:
TopHubbers2.01.lua:226: attempt to compare two nil values

Seems like your TopHubbers' database is corrupt [probably due to an older table structure].

Please stop your script, delete it [tOnliners.tbl] and restart it again.
Title: Re: Top Hubbers
Post by: Creative on 10 November, 2006, 05:55:21
Well no doubt this script is gr8............. but i wd like some changes to be made....like,

1] For !myhubtime and for !hubtime <nick> is it possible to keep same command?? i mean if i type !hubtime it will show my hubtime and if i type !hubtime <nick> it will show tht nick's hubtime.
Is it possible to do this???

2] And also keeping the nicks case sensitive.........
like if there r 2 nicks, Darth_Vader and DARTH.
So if i type !hubtime darth_vader thn it will show  "Darth_Vader's" hubtime and if i type !hubtime darth thn it will show "DARTH's" hubtime.
Well I mean to say tht, in 2nd point thr will be two changes...........
i.e if the nick is in capital and if v type in small thn too it will show the output and if v type half nick thn too it will show the output...

Plz try to make this changes........ :)
Title: TopHubbers 2.02 - LUA 5.0/5.1
Post by: jiten on 10 November, 2006, 17:47:47
First post has been updated with some changes in the package.

Best regards
Title: Re: Top Hubbers
Post by: speedX on 10 November, 2006, 19:25:56
Hey jiten,
I am using this script frm a quiet a long time when there was no option for lower case, due to this 2-3 users in my hub have more than one account, so now wht shud I do??

Can you make a convertor or something wich will delete users having more than one account??plzz if possible or shud I delete thm manually? :P
Title: Re: Top Hubbers
Post by: Creative on 11 November, 2006, 06:59:13
Jiten dude...... string.lower change is fine...... but it would be nice if u make 1 more change in it so that if a user types half the nick thn too it will show the output.
For example: I wanna c hubtime of a nick AdminsTrator........ and if i type +hubtime admins thn it will show the output........
I know u can make this change...... :D
Title: Re: Top Hubbers
Post by: jiten on 11 November, 2006, 15:48:05
Quote from: speedX on 10 November, 2006, 19:25:56
Can you make a convertor or something wich will delete users having more than one account??plzz if possible or shud I delete thm manually? :P

As requested...

Code (lua) Select
--[[

TopHubbers 2.01-2.02 DB Converter by jiten (11/11/2006)

Requested by: speedX

DESCRIPTION:

This converter will keep the oldest repeated entry in the DB and delete the others.

STEPS:

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: tOnliners.tbl
4. And that's it!

]]--

-- File to convert
fConvert = "tOnliners.tbl"
-- Output file
fConverted = "tOnliners(new).tbl"

Main = function()
if loadfile(fConvert) then dofile(fConvert) end; local tConvert, tRemove = tOnline, {}
for i, v in pairs(tConvert) do
tRemove[string.lower(i)] = (tRemove[string.lower(i)] or {})
table.insert(tRemove[string.lower(i)], v.Julian); table.sort(tRemove[string.lower(i)])
while #tRemove[string.lower(i)] > 1 do
table.remove(tRemove[string.lower(i)], #tRemove[string.lower(i)])
end
end
for i, v in pairs(tConvert) do
if tRemove[string.lower(i)] then
if tRemove[string.lower(i)][1] < v.Julian then tConvert[i] = nil end
end
end
local hFile = io.open(fConverted, "w+") Serialize(tConvert, "tOnline", hFile); hFile:close()
end

Serialize = 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

Posted on: 11 November 2006, 10:55:23
Quote from: SwapY on 11 November, 2006, 06:59:13
For example: I wanna c hubtime of a nick AdminsTrator........ and if i type +hubtime admins thn it will show the output........

As previously stated, you must type the actual nick [note that now they aren't case-sensitive].

If not, this could lead to some confusion. That's why I don't think it should be added. I hope you understand.
Title: Re: Top Hubbers
Post by: speedX on 11 November, 2006, 17:01:56
Thanx for the quick reply jiten ;)
But I'm facing one problem. After running the script a new .tbl is formed named "tOnliners(new).tbl" and after renaming it to "tOnliners.tbl" it doesnt work :(
Title: Re: Top Hubbers
Post by: jiten on 11 November, 2006, 19:01:05
Quote from: speedX on 11 November, 2006, 17:01:56
But I'm facing one problem. After running the script a new .tbl is formed named "tOnliners(new).tbl" and after renaming it to "tOnliners.tbl" it doesnt work :(

There was a small typo in the code. It should be ok now.

Best regards
Title: Re: Top Hubbers
Post by: speedX on 11 November, 2006, 20:01:37
Working, thx jiten for ur help ;)
Title: Re: Top Hubbers
Post by: Creative on 15 November, 2006, 18:07:08
jiten, script is working fine, but if any1 types nick in small letters, for example....... +hubtime darth_vader and if his nick is DartH_VadeR thn output comes but "*** Error: No record found for 'darth_vader'!"  comes.......

Output is correct but tht error also comes at same time......
Title: Re: Top Hubbers
Post by: achiever on 15 November, 2006, 19:42:11
hi,

stop ur older script. i.e tophubber_v2.01 i suppose then it will work.
both the scripts 2.01 and 2.02 r working so u get error from 1st script, n output from 2nd.
jiten ur script roxxx ;)

bye,

achiever
Title: Re: Top Hubbers
Post by: Creative on 12 January, 2007, 06:33:52
Happy New Year to all Users......... Well i was thinking if 1 more command be added in this script to check which user is online since when. I mean, if v use !uptime <nick> thn it will show just the total time since the user is online. and !hubtime <nick> will be the regular command........ is this poss??
Title: Re: Top Hubbers
Post by: ninad_laud on 24 January, 2007, 16:13:50
HI JITEN .... I AM NEW 2 THIS THING OF HUB.............CAN U PLZ POST ME THE COMPLETE HUBTIME SCRIPT WHICH CONTAINS ALL THE THING REQUESTED BY USERS IN ONE SINGLE SCRIPT...........AND IT SHULD BE ERROR FREE.....CAN U PLZZ POST IT IMM..... I AM W8ING FOR U REPLY
(http://forum.ptokax.org/Themes/dilbermc/images/warnpmod.gif) Don't type your posts ALL-CAPITAL!

Keep your sentences together. Think before you hit the "post" button!
--Herodes
Title: Re: Top Hubbers
Post by: ninad_laud on 09 February, 2007, 03:16:29
the hubtime script do not show hubtime of other users
[14:24:08] !hubtime potter
[14:24:09] <PtokaX> *** Error: You are not allowed to use this command!
can u plzz tell me how edit this
Title: Re: Top Hubbers
Post by: speedX on 19 February, 2007, 18:03:21
Quote from: jiten on 04 October, 2006, 10:26:31
hubtime's function should be like this:

fFunction = function(user, data)
-- Parse nick
local _,_, nick = string.find(data, "^%S+%s+(%S+)$")
-- Exists
if nick then
-- Return
SendToAll(user.sName, data)
BuildStats(user, nick)
else
user:SendMessage(tSettings.sBot, "*** Syntax Error: Type !hubtime <nick>")
end
end,


You'll also need to replace your BuildStats function with this one:

BuildStats = function(user, nick)
-- In DB
if tOnline[nick] then
-- Average uptime in days
local iAverage = os.difftime(os.time(os.date("!*t")), tOnline[nick].Julian)/(60*60*24)
if iAverage < 1 then iAverage = 1 end
-- Generate message
local sMsg = "\r\n\r\n\t"..string.rep("=", 40).."\r\n\t\t\tStats:\r\n\t"..
string.rep("-", 80).."\r\n\t- Nick: "..nick.."\r\n\t- Total uptime: "..
MinutesToTime(tOnline[nick].TotalTime, true).."\r\n\t- Daily average uptime: "..
MinutesToTime((tOnline[nick].TotalTime/iAverage), true).."\r\n\t- Current Rank: "..GetRank(nick).."\r\n"
-- Send stats
SendToAll(tSettings.sBot, sMsg)
else
user:SendMessage(tSettings.sBot, "*** Error: No record found for '"..nick.."'!")
end
end


Notice that with these changes, if you've enabled the 'bRankOnConnect' option, every user's mainchat will be flooded with connecting users' stats. So, be careful.

I had requested jiten edit the script such tht the command and output is seen by all, in the old version. So, he gave me the above the tables to replace.
But when I make the above changes in the latest tophubbers script(v2.02), thn the string.lower function does not work......
Could any of the scripters plzz help me to fix it.

Any help would appreciated
If you are confused abt my request thn plzz tel me....
Title: Re: Top Hubbers
Post by: Yahoo on 26 March, 2007, 16:13:09
is it possible to make a small change in the script when i type the command i get the message as follows
Nick: Yahoo -- THT: 8 day(s), 10 hour(s), 2 minute(s) -- AHT: 3 hour(s), 18 minute(s)    -- Current Rank: Amateur
can it be changed to something like this
Nick: potter -- THT: 1 week(s), 1 day(s), 10 hour(s), 2 minute(s) -- AHT: 3 hour(s), 18 minute(s)    -- Current Rank: Amateur
Title: Re: Top Hubbers
Post by: Troubadour on 27 March, 2007, 16:16:02
Which to download for the finished bugfree version?
Can there be a link with the good version?
Title: Re: Top Hubbers
Post by: Psycho_Chihuahua on 27 March, 2007, 16:28:17
I'm not sure which was the final one but i can attach the one i am using in my hub. Havent had any problems with it
Title: Re: Top Hubbers
Post by: speedX on 27 March, 2007, 17:28:43
The first post of this topic contains the latest Tophubbers version (v2.02)
Title: Re: Top Hubbers
Post by: Troubadour on 09 April, 2007, 19:15:29
Quote from: Psycho_Chihuahua on 27 March, 2007, 16:28:17
I'm not sure which was the final one but i can attach the one i am using in my hub. Havent had any problems with it

Thnx m8.
Title: Re: Top Hubbers
Post by: Creative on 04 June, 2007, 07:58:34
Hi Jiten,
           In this tophubbers, u have mentioned this addition
Added: Rankings and related commands [!myrank & !topranks] - requested by speedX;

But !myranks and !topranks isnt working.
Can u tell me just the function which i can add in this script??
Title: Re: Top Hubbers
Post by: speedX on 04 June, 2007, 18:54:57
Quote from: Creative on 04 June, 2007, 07:58:34
Hi Jiten,
           In this tophubbers, u have mentioned this addition
Added: Rankings and related commands [!myrank & !topranks] - requested by speedX;

But !myranks and !topranks isnt working.
Can u tell me just the function which i can add in this script??

I guess those were removed when ranks got merged with the main hubtime command.....
Title: Re: Top Hubbers
Post by: Creative on 12 June, 2007, 14:13:09
My friend edited this Script so that the output looks like:
[17:26:28] <Bot>  Nick: Creative   THT: 30 days, 23 hours, 22 minutes   AHT: 3 hours, 28 minutes  Rank: 26

In the script below, my friend added 1 function of GetRonk by which it shows users rank by number but the problem is that by using GetRonk function, the script uses lots of memory, it goes to 5mb. Can any1 solve this problem??

--[[

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)

]]--

tSettings = {
-- Bot Name
sBot = frmHub:GetHubBotName(),

-- Top Hubbers' DB
fOnline = "tOnliners.tbl",

-- RightClick Menu
sMenu = "Top Hubbers",

-- Maximum hubbers to show when using !tophubbers
iMax = 20,


iMaxLeecher = 12420,

-- Send message to users with lower than specified Average uptime (AUT) [true = on; false = off]
bWarning = false,
-- Minimum Average uptime (hours) that triggers the warning
iAUT = 1,

-- Send hubtime stats on connect [true = on; false = off]
bRankOnConnect = false,

-- Profiles checked [0 = off; 1 = on]
tProfiles = { [-1] = 0, [0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 1 },

-- Ranks criteria ["average" = Average total uptime; "total" = Total uptime]
sCriteria = "total",

-- Ranks
tRanks = {
--[[

The ranks must be added in ascending order [from the lowest to the highest]

{ "Rank", [time][string] }

[time] must be 1 or more digit(s)
[string] must be: s = second; m = minute; h = hour; D = day; W = week; M = month; Y = year

Example: { "God", "1M, 2D, 10s" }
Meaning: To become a God, your total uptime must be equal or higher than 1 month, 2 days and 10 seconds
]]--

-- Total uptime rank table
total = {
{ "LEECHER", "1m, 1s" }, { "Member", "3D" }, { "Cool Member", "5D" },
{ "Hub As", "10D" }, { "Smart As", "20D" }, { "Double As", "1M" },
{ "Triple As", "2M" }, { "Conqueror", "3M" }, { "Viking", "4M" },
{ "King", "6M" }, { "Emperor", "8M" }, { "Hub Legend", "10M" },
{ "Hub God", "11M" }, { "God", "1Y, 1h, 1m, 1s" }
},

-- Daily average uptime rank table
average = {
{ "LEECHER", "1h" }, { "Member", "6h" }, { "Cool Member", "12h" },
{ "Hub-As", "1D" }, { "Smart As", "5D" }, { "Double-As", "15D" },
{ "Triple-As", "1M" }, { "Conqueror", "2M" }, { "Viking", "3M" },
{ "King", "4M" }, { "Emperor", "6M" }, { "Hub Legend", "9M" },
{ "Hub God", "11M" }, { "God", "1Y" }
}
}
}

tOnline = {}

Main = function()
-- Register BotName if not registered
if tSettings.sBot ~= frmHub:GetHubBotName() then frmHub:RegBot(tSettings.sBot) end
-- Load DB content
if loadfile(tSettings.fOnline) then dofile(tSettings.fOnline) end
-- LUA 5.0/5.1 compatibility; Set and Start Timer
string.gmatch = (string.gmatch or string.gfind); SetTimer(60*1000); StartTimer()
end

OnTimer = function()
-- For each hubber
for i, v in pairs(tOnline) do
-- Online
if GetItemByName(i) then
-- Sum
v.SessionTime = v.SessionTime + 1; v.TotalTime = v.TotalTime + 1
end
end
end

OnExit = function()
-- Save
local hFile = io.open(tSettings.fOnline, "w+") Serialize(tOnline, "tOnline", hFile); hFile:close()
end

NewUserConnected = function(user)
-- If profile has permission to be logged
if tSettings.tProfiles[user.iProfile] and tSettings.tProfiles[user.iProfile] == 1 then
local tNick = GetOnliner(user.sName)
-- User already in DB
if tNick then
-- Warning on connect
if tSettings.bWarning then
-- Days since first login
local iAverage = os.difftime(os.time(os.date("!*t")), tNick.Julian)/(60*60*24)
if iAverage < 1 then iAverage = 1 end
-- Less than allowed
if tNick.TotalTime/iAverage < tSettings.iAUT*60 then
-- Warn
user:SendPM(tSettings.sBot, "*** Your Average uptime (AUT) is less than "..tSettings.iAUT..
" hour(s). We are planning to impose restrictions to users with and AUT lower than the allowed!")
end
end
-- Reset and save time
tNick.SessionTime = 0; tNick.Enter = os.date()
-- Send rank info on connect
if tSettings.bRankOnConnect then tCommands["myhubtime"].fFunction(user) end
else
-- Create new entry
tOnline[user.sName] = { Julian = os.time(os.date("!*t")), Enter = os.date(), SessionTime = 0, TotalTime = 0, Leave = os.date() }
end
end
-- Supports UserCommands
if user.bUserCommand then
-- For each entry in table
for i, v in pairs(tCommands) do
-- If member
if v.tLevels[user.iProfile] then
-- For each type
for n in ipairs(v.tRC) do
-- Send
user:SendData("$UserCommand 1 3 "..tSettings.sMenu.."\\"..v.tRC[n][1]..
"$<%[mynick]> !"..i..v.tRC[n][2].."&#124;")
end
end
end
end
end

OpConnected = NewUserConnected

UserDisconnected = function(user)
local tNick = GetOnliner(user.sName)
-- If profile must be logged and user is in DB
if tSettings.tProfiles[user.iProfile] and tSettings.tProfiles[user.iProfile] == 1 and tNick then
-- Log date
tNick.Leave = os.date()
end
end

OpDisconnected = UserDisconnected

ChatArrival = function(user, data)
local _,_, to = string.find(data, "^$To:%s(%S+)%s+From:")
local _,_, msg = string.find(data, "%b<>%s(.*)|$")
-- Message sent to Bot or in Main
if (to and to == tSettings.sBot) or not to then
-- Parse command
local _,_, cmd = string.find(msg, "^%p(%S+)")
-- Exists
if cmd and tCommands[string.lower(cmd)] then
cmd, user.SendMessage = string.lower(cmd), user.SendData
-- PM
if to == tSettings.sBot then user.SendMessage = user.SendPM end
-- If user has permission
if tCommands[cmd].tLevels[user.iProfile] then
return tCommands[cmd].fFunction(user, msg), 1
else
return user:SendMessage(tSettings.sBot, "*** Error: You are not allowed to use this command!"), 1
end
end
end
end

ToArrival = ChatArrival

tCommands = {
tophubbers = {
fFunction = function(user, data)
-- Table isn't empty
if next(tOnline) then
-- Parse limits
local _,_, iStart, iEnd = string.find(data, "^%S+%s+(%d+)%-(%d+)$")
-- Set if not set
iStart, iEnd = (iStart or 1), (iEnd or tSettings.iMax)
-- Header
local tCopy, msg = {}, "\r\n\t"..string.rep("=", 120).."\r\n\tNr.  Total:\t\t\t\t\tSession:\t"..
"Entered Hub:\tLeft Hub:\t\tRank:\t\tStatus:\tName:\r\n\t"..string.rep("-", 240).."\r\n"
-- Loop through hubbers
for i, v in pairs(tOnline) do
-- Insert stats to temp table
table.insert(tCopy, { sEnter = v.Enter, iSessionTime = tonumber(v.SessionTime),
iTotalTime = tonumber(v.TotalTime), sLeave = v.Leave, sNick = i, sRank = GetRank(i) } )
end
-- Sort by total time
table.sort(tCopy, function(a, b) return (a.iTotalTime > b.iTotalTime) end)
-- Loop through temp table
for i = iStart, iEnd, 1 do
-- i exists
if tCopy[i] then
-- Populate
local sStatus, v = "*Offline*", tCopy[i]; local sRank = v.sRank
if GetItemByName(v.sNick) then sStatus = "*Online*" end
if string.len(v.sRank) < 9 then sRank = sRank.."\t" end
msg = msg.."\t"..i..".    "..MinutesToTime(v.iTotalTime).."\t"..v.iSessionTime..
" min\t"..v.sEnter.."\t"..v.sLeave.."\t"..sRank.."\t"..sStatus.."\t"..v.sNick.."\r\n"
end
end
msg = msg.."\t"..string.rep("-", 240)
-- Send
user:SendPM(tSettings.sBot, "Current Top Hubbers:\r\n"..msg.."\r\n")
else
user:SendMessage(tSettings.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,
},
tRC = { { "Show Top "..tSettings.iMax.." hubbers", "" }, { "Show Top x-y Hubbers", " %[line:x-y]" } }
},





hubtime = {
fFunction = function(user, data)
-- Parse nick
local _,_, nick = string.find(data, "^%S+%s+(%S+)$")
-- Exists
if nick then
-- Return
                                SendToAll("<"..user.sName.."> +hubtime "..nick)
BuildStats(user, nick)
else
                                SendToAll("<"..user.sName.."> +hubtime")
BuildStats(user, user.sName)
end
end,
tLevels = {
[-1] = 0, [0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 1,
},
tRC = { { "Show an user's stats", " %[line:Nick]" } }
},
myhubtime = {
fFunction = function(user)
-- Return
BuildStats(user, user.sName)
end,
tLevels = {
[-1] = 0, [0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 1,
},
tRC = { { "Show my stats", "" } }
},
}

BuildStats = function(user, nick)
local tNick = GetOnliner(nick)
-- In DB
if tNick then
-- Average uptime in days
local iAverage = os.difftime(os.time(os.date("!*t")), tNick.Julian)/(60*60*24)
if iAverage < 1 then iAverage = 1 end
-- Generate message
local sRank = GetRank(nick)
if sRank~="LEECHER" then
local sMsg = " Nick: "..nick.."   THT: "..
MinutesToTime(tNick.TotalTime, true).."   AHT: "..
MinutesToTime((tNick.TotalTime/iAverage), true).."  Rank: "..GetRonk(nick)..""
                user:SendMessage(tSettings.sBot, sMsg)
                local sRank = GetRank(nick)
elseif sRank=="LEECHER" then
local sMsg = " Nick: "..nick.."   THT: "..
MinutesToTime(tNick.TotalTime, true).."   AHT: "..
MinutesToTime((tNick.TotalTime/iAverage), true).."  Rank: "..GetRink(nick).."  "..GetRonk(nick)..""
-- Send stats
user:SendMessage(tSettings.sBot, sMsg)
end

else
user:SendMessage(tSettings.sBot,nick.." is not a valid username!")
end
end





GetRonk = function(nick)

local tNick = GetOnliner(nick)

-- Table isn't empty
if next(tOnline) then
-- Parse limits

-- Set if not set
iStart, iEnd = (iStart or 1), (iEnd or tSettings.iMaxLeecher)
-- Header
local tCopy, msg = {}, ""
-- Loop through hubbers
for i, v in pairs(tOnline) do
-- Insert stats to temp table
table.insert(tCopy, { sEnter = v.Enter, iSessionTime = tonumber(v.SessionTime),
iTotalTime = tonumber(v.TotalTime), sLeave = v.Leave, sNick = i, sRank = GetRank(i) } )
end
-- Sort by total time
table.sort(tCopy, function(a, b) return (a.iTotalTime > b.iTotalTime) end)
-- Loop through temp table
for i = iStart, iEnd, 1 do
-- i exists
if tCopy[i] then
-- Populate
local sStatus, v = "*Offline*", tCopy[i]; local sRank = v.sRank
if GetItemByName(v.sNick) then sStatus = "*Online*" end
if tNick == GetOnliner(v.sNick) then

return i
end
end
end

end

end




GetRank = function(nick)
local tNick = GetOnliner(nick)
if tNick then
-- Custom time table
local tTime, sRank, iAverage = { s = 1/60, m = 1, h = 60, D = 60*24, W = 60*24*7, M = 60*24*30, Y = 60*24*30*12 }, tSettings.tRanks[string.lower(tSettings.sCriteria)][1][1]
-- Average enabled
if tSettings.bAverage then
-- Days since first login
iAverage = os.difftime(os.time(os.date("!*t")), tNick.Julian)/(60*60*24)
if iAverage < 1 then iAverage = 1 end
end
-- For each rank
for n in ipairs(tSettings.tRanks[string.lower(tSettings.sCriteria)]) do
local iTime = 0
-- For each digit and time string
for i, v in string.gmatch(tSettings.tRanks[string.lower(tSettings.sCriteria)][n][2], "(%d+)(%w)") do
-- Process
if i and tTime[v] then iTime = iTime + i*tTime[v] end
end
local iValue = tNick.TotalTime
-- Average
if tSettings.bAverage then iValue = iValue/iAverage end
-- Process rank if user hasn't logged in for the first time today
if os.date("%d%m%y", tNick.Julian) ~= os.date("%d%m%y") and iValue > iTime then
sRank = tSettings.tRanks[string.lower(tSettings.sCriteria)][n][1]
end
end
return sRank
end
end

MinutesToTime = function(iSeconds, bSmall)
-- Build table with time fields
local T = os.date("!*t", tonumber(iSeconds*60));
-- Format to string
local sTime = string.format("%i months, %i days, %i hours, %i minutes", T.month-1, T.day-1, T.hour, T.min)
-- Small stat?
if bSmall then
-- For each digit
for i in string.gmatch(sTime, "%d+") do
-- Reduce if is preceeded by 0
if tonumber(i) == 0 then sTime = string.gsub(sTime, "^"..i.."%s(%S+),%s", "") end
end
end
-- Return
return sTime
end

GetOnliner = function(user)
-- For each hubber
for i, v in pairs(tOnline) do
-- Compare
if string.lower(i) == string.lower(user) then
-- Return
return tOnline[i]
end
end
end

Serialize = 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
Title: Re: Top Hubbers
Post by: XTC on 09 August, 2008, 15:57:51
Where do I change the minimum "Total Uptime" ??
Does the OP,s and higher get a PM when a user get a warning ? If it disable, where do I change it ??

Does the user get anything more than a warning. It would be good if when the user dont been in the hub for XX hours, the user cant search or download tIll the user have reached the minimum "TotalUptime". ??