determinate determinate

Author Topic: TopTen 1.0 LUA 5.1x [Strict][API 2]  (Read 5173 times)

0 Members and 1 Guest are viewing this topic.

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
TopTen 1.0 LUA 5.1x [Strict][API 2]
« on: March 08, 2008, 10:14:55 pm »
A few small updates for the latest API changes. 07/06/08

Code: [Select]
--[[

TopTen 1.0 LUA 5.1x [Strict][API 2]

By Mutor 03/07/08

Display top ten stats for your hub with
a 'bargraph' type display.

- Provides permission by profile
- Provides context menu [right click]
- Provides option to change bargraph character

- Currently provides the following:
•HubShare -- Total Hub Share
•Users -- Total Users
•UpTimes -- User session times [time logged in]
•UserShare -- User Shares
•Logins -- User connections
•Chat -- Number of chat messages by user
•ChatChars -- Number of chat characters by user
•Pms -- Number of private messages [pm's] by user
•PmChars -- Number of pm characters by user
•Cmds -- Number of commands [Chat received in command format with Hub prefixes]
•Smilies -- Number of 'smiley' codes. ie.':)' Settable in table below
•Lols -- Number of chat acronyms ie lol, rofl. Settable in table below
•CTMs -- Number of CTM, RCTM requests, indicates transfer activity
•Searches -- Number of user searches
•Kicks -- Number of kick commands [$Kick protocol command only]
•Redirs -- Number of redirections [$OpForceMove]
•Pingers -- Number of BotINFOArrival requests
•Unknowns -- Number of unknown commands sent to the hub and by whom

]]

--//-- Start User Settings --//--
-- Subfolder of scripts to store table data [will be created if non-existant]
local Folder = "TopTen"
-- File to store table data [within Folder path, as set above]
local File = "Tops.txt"
-- Name for the bot [SetMan.GetString(21) = pulled from the hub or use "Custom-Name"]
local Bot = "[TopTen]"
-- Admins nick for status / error messages
local OpNick = "Mutor"
-- Report all stats to OpNick in pm at script start? true/false
local Report = true
-- Bargraph character table, add/edit/delete as you wish. Set specific char below
local Chars = {
[1]="|", -- |
[2]=string.char(149), -- •
[3]=string.char(155), -- ›
[4]=string.char(164), -- ¤
[5]=string.char(166), -- ¦
[7]=string.char(167), -- §
[8]=string.char(181), -- µ
[9]=string.char(182), -- ¶
[10]=string.char(254), -- þ
[11]="¦|", -- ¦|
}
-- Set Bargraph character: Chars[x] Where 'x' is the index number from Chars table above
local GraphChar = Chars[1]
-- Table of ASCII characters to be considered 'smilies'
local Asc = {":-)",":)",":o)","=)",":-(",":(",";-)",";)",":-o",":o",":-O",":O",":-/",":/",":-p",":p",
":Þ",":->",":>","B-)",":@)",":-~)","(-:",":-|",":|","<:-)","<):-)","*<):-)","[:]",":-x",":x",":-&",
":-{)",":-B",":B",":-C",":C","':-)","8-)",":-9","3:-o",":O)",":-[",":-E",":-*",":'-(",":((",":'-)",
":-@","I-)","|-O","0:-)","[:-)",":@)","**==","=:-)"}
-- Table of Acronyms to be considered 'lols'
local Acr = {"lol","lmao","lmfao","rofl","rotfl","pmsl","cya","wb","l8r","omg","rtfm","afaik","imho","ty","yw"}
-- User Profiles
-- [#] = true/false, (true = Commands enabled, false = Commands disabled)
local Profiles  = {
[-1] = false, --Unregistered User
[0] = true, --Master
[1] = true, --Operator
[2] = true, --Vip
[3] = true, --Registered User
}

--//-- End User Settings --//--

local Path = Core.GetPtokaXPath().."scripts/"
local Scp,UserCmds,Cnt,Save,Pause = "TopTen 1.0","",0,0,0
OnStartup = function()
Save = TmrMan.AddTimer(5*60000)
if not Folder:find("^"..Path) then Folder = Path.."/"..Folder end
local ren,err = os.rename(Folder,Folder)
if err and not err:lower():find("permission denied") then
os.execute("md "..Folder)
end
File = Folder.."/"..File
if loadfile(File) then
dofile(File)
Top.HubShare = HubRefresh(Core.GetCurrentSharedSize(),Top.HubShare,os.time())
Top.Users = HubRefresh(Core.GetMaxUsersPeak(),Top.Users,os.time())
Top.UserShare = GetValue(16,1024)
Top.UpTimes = GetValue(25,60)
else
local t,tb = {},Core.GetOnlineUsers()
Top = {
HubShare = {{os.time(),Core.GetCurrentSharedSize()},},
Users = {{os.time(),Core.GetUsersCount()},},
UserShare = GetValue(16,1024),
UpTimes = GetValue(25,60),
Logins = GetLogins(),
Chat = {},
ChatChars = {},
Pms = {},
PmChars = {},
Cmds = {},
Smilies = {},
Lols = {},
CTMs = {},
Searches = {},
Kicks = {},
Redirs = {},
Pingers = {},
Unknowns = {},
}
end
local Order = {"HubShare","Users","UpTimes","UserShare","Logins","Chat","ChatChars","Pms","PmChars","Cmds",
"Smilies","Lols","CTMs","Searches","Kicks","Redirs","Pingers","Unknowns"}
local Pfx,Hub = SetMan.GetString(29):sub(1,1),SetMan.GetString(0)
assert(Pfx) assert(Hub)
Cnt = #Order
local om = ""
for _,s in ipairs(Order) do
if Report then om = om..GetTen(Top[s],s) end
if not Top[s] then Top[s] = {} end
UserCmds = UserCmds.."$UserCommand 1 3 "..Hub.."\\"..Scp.."\\"..s.."$<%[mynick]> "..Pfx..s.."&#124;|"
end
SaveFile(File,Top,"Top")
if Report and om:len() > 0 then OnError(om,true) end
end

OnExit = function() SaveFile(File,Top,"Top") end

OnError = function(msg,pm)
local user = Core.GetUser(OpNick)
if user then
if pm then
Core.SendPmToUser(user,Bot,msg.."|")
else
Core.SendToUser(user,"<"..Bot.."> "..msg.."|")
end
end
end

OnTimer = function(Id)
if Id == Save then SaveFile(File,Top,"Top") end
if Id == Pause then
Top.Users = HubRefresh(Core.GetMaxUsersPeak(),Top.Users,os.time())
Top.UserShare,Top.UpTimes = GetValue(16,1024),GetValue(25,60)
TmrMan.RemoveTimer(Pause)
Pause = 0
end
end

UserConnected = function(user)
Pause = TmrMan.AddTimer(2000)
Refresh(user,Top.Logins,1)
if Profiles[user.iProfile] then
local Prof,Plural = "Unregistered User",""
if user.iProfile ~= -1 then Prof = ProfMan.GetProfile(user.iProfile).sProfileName end
if Cnt > 1 then Plural = "s" end
local msg = "<"..Bot.."> "..Prof.."'s "..Scp.." commands enabled. Right click "..
"hub tab or user list for menu. "..tostring(Cnt).." listing"..Plural.." available.|"
Core.SendToUser(user,UserCmds..msg)
end
end
OpConnected,RegConnected = UserConnected,UserConnected

ChatArrival = function(user,data)
local _,_,cmd = data:find("%b<> ["..SetMan.GetString(29).."](%w+)")
local _,_,to = data:find("^$To: (%S+) From:")
local _,_,msg = data:find("%b<> ([^|]+)|")
local x = msg:len()
if cmd then
Refresh(user,Top.Cmds,1)
if Profiles[user.iProfile] and Top[cmd] then
return Core.SendToUser(user,"<"..Bot.."> "..GetTen(Top[cmd],cmd).."|"),true
end
end
if to then
Refresh(user,Top.Pms,1)
if x > 0 then Refresh(user,Top.PmChars,x) end
else
Refresh(user,Top.Chat,1)
if x > 0 then Refresh(user,Top.ChatChars,x) end
end
Update(user,data,Asc,Top.Smilies)
Update(user,data,Acr,Top.Lols)
end
ToArrival = ChatArrival

KickArrival = function(user,data)
Refresh(user,Top.Kicks,1)
end

UnknownArrival = function(user,data)
Refresh(user,Top.Unknowns,1)
end

OpForceMoveArrival = function(user,data)
Refresh(user,Top.Redirs,1)
end

ConnectToMeArrival = function(user,data)
Refresh(user,Top.CTMs,1)
end
RevConnectToMeArrival,MultiConnectToMeArrival = ConnectToMeArrival,ConnectToMeArrival

SearchArrival = function(user,data)
Refresh(user,Top.Searches,1)
end
MultiSearchArrival = SearchArrival

BotINFOArrival = function(user,data)
Refresh(user,Top.Pingers,1)
end

GetLogins = function()
local t,tb = {},Core.GetOnlineUsers()
if next(tb) then for _,u in ipairs(tb) do table.insert(t,{u.sNick,1}) end end
return t
end

HubRefresh = function(count,tab,date)
if tab then
local chg,min,tot = false,0,0
if next(tab) then for i,v in ipairs(tab) do min = math.max(min,v[2]) tot = tot + v[2] end end
if not date then return math.max(count,min),tot  end
if count > min then
table.insert(tab,{os.time(),count})
table.sort(tab,function(a,b) return a[2] > b[2] end)
while #tab > 10 do table.remove(tab,#tab) table.sort(tab,function(a,b) return a[2] > b[2] end) end
end
end
return tab
end

Refresh = function(user,tab,x)
if tab then
local chg = false
if next(tab) then
for i,v in ipairs(tab) do
if v[1]:lower() == user.sNick:lower() then
v[2] = v[2] + x
chg = true
break
end
end
end
if not chg then table.insert(tab,{user.sNick,x}) end
table.sort(tab,function(a,b) return a[2] > b[2] end)
while #tab > 10 do
table.remove(tab,#tab)
table.sort(tab,function(a,b) return a[2] > b[2] end)
end
end
end

Update = function(user,data,arr,tab)
local bool,x = false,0
data = data:sub(1,-2):lower()
for _,code in ipairs(arr) do
code = code:gsub("[%p]","%%%1")
local chr,count = data:gsub(code,"%1")
if count and count > 0 then x = x + count end
end
if x > 0 then Refresh(user,tab,x) bool = true end
return bool
end

GetValue = function(val,min)
local t = {}
for _,user in ipairs(Core.GetOnlineUsers()) do
local x = Core.GetUserValue(user,val)
if x > min then table.insert(t,{user.sNick,tonumber(x)}) end
end
if next(t) then
table.sort(t,function(a,b) return a[2] > b[2] end)
while #t > 10 do table.remove(t,#t) end
end
return t
end

GetTen = function(t,h)
local s,x,y,c,m,f,hdr,bar,art,col = "",0,0,0,"","40.50","",GraphChar,"¯","User Nick"
if t and next(t) then
if h:lower():find("^uptimes$") then
table.sort(t, function(a,b) return a[2] < b[2] end)
else
table.sort(t, function(a,b) return a[2] > b[2] end)
end
for i,v in ipairs(t) do x = x + v[2] end
y = x
for i,v in ipairs(t) do
if i < 11 and v[2] > 0 then
local n,z,k,sp = v[1],v[2],v[2],""
if h:lower():find("^hubshare$") or h:lower():find("^users$") then
if h:lower():find("^hubshare$") then
x,c = HubRefresh(Core.GetCurrentSharedSize(),Top.HubShare)
m,y,z = FmtSz(c/#t,3),FmtSz(x,3),FmtSz(v[2],3)
else
_,c = HubRefresh(Core.GetMaxUsersPeak(),Top.Users)
x,m,y,z = Core.GetMaxUsersPeak(),tostring(math.ceil(c/#t)),tostring(x),tostring(v[2])
end
f,n,col = "20.15",os.date("%m/%d/%Y",v[1]),"Date"
elseif h:lower():find("^uptimes$") then
x,m,y,z,f,k = Core.GetUpTime(),Convert(os.time() - (x/10),6),Convert(os.time() - x,6),Convert(v[2],6),"40.50",os.time()-k
if z and z:len() < 10 then sp = sp.."\t" end
elseif h:lower():find("^usershare$") then
m,y,z,f = FmtSz(x/#t),FmtSz(x),FmtSz(v[2]),"20.15"
else
m = tostring(math.ceil(x/#t))
end
local pct,mod = (k/x) * 100,""
if pct > 100 then mod = "+" end
pct = math.min(pct,100)
s = s.."\t"..i..")\t"..string.format("%-"..f.."s ",z)..sp.."\t"..mod..
string.format("%-15.7s ",string.format("%.2f%%",pct)).."\t"..n.."\n\t"..
bar..bar:rep(pct).."\n"
end
end
hdr = "\n\n\tTop Ten "..h.." Total: `\t\tMean: "..m.."\n\t"..bar:rep(101).."\n\t"..art:rep(65).."\n"..
"\t#)\t"..string.format("%-"..f.."s ",h).."\tPercent Total\t"..col.."\n\n\t"..art:rep(65).."\n"
return hdr:gsub("`",y)..s
else
return "Sorry, there isn't any "..string.format("%q",h).." data available at this time.\n"
end

end

FmtSz = function(int,dec)
dec = dec or 2
local i,u,x= int or 0,{"","K","M","G","T","P"},1
while i > 1024 do i,x = i/1024,x+1 end return string.format("%."..dec.."f %sB.",i,u[x])
end

Convert = function(time,inc)
local s,x,n = "",0,os.time()
local tab = {{31556926,"year"},{2592000,"month"},{604800,"week"},
{86400,"day"},{3600,"hour"},{60,"minute"},{1,"second"}}
inc = inc or #tab
if time > 0 and time < n then
time = n - time
for i,v in ipairs(tab) do
if i <= inc and time > v[1] then
x = math.floor(time/v[1])
if x > 1 then v[2] = v[2].."s" end
if x > 0 then
s = s..x.." "..v[2]..", "
time = time-x*v[1]
end
end
end
return s:sub(1,-3)
else
local a,b = os.date("%m/%d/%Y",86400),os.date("%m/%d/%Y",2145876658)
return "Invalid time supplied. [must be > "..a.." and < "..b.."]"
end
end

SaveFile = function(file,table, tablename )
local hFile = io.open (file , "wb")
Serialize(table, tablename, hFile)
hFile:close()
collectgarbage("collect")
end

Serialize = function(tTable, sTableName, hFile, sTab)
local x = pairs
sTab = sTab or "";
if type(sTab) == "table" and next(sTab) then x = ipairs end
hFile:write(sTab..sTableName.." = {\n" )
for key, value in x(tTable) do
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
hFile:write( sTab.."}")
end
« Last Edit: July 07, 2008, 12:16:46 am by Mutor »
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline ]-[€LL§L톆L€ÅnG€L

  • Member
  • ***
  • Posts: 33
  • Karma: +8/-0
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #1 on: March 09, 2008, 11:03:07 am »
Kool :P This is a really fun and interesting script for those of us who love this stuff like (me ;D) has all that you need to keep a check on all your topten stuff and to make sure you keep your name in at least one  ;D ;D
Luvin IT good work Mutor  :P

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #2 on: March 09, 2008, 01:48:02 pm »
Good, I'm glad you like it.
I've just updated the script to avoid the possibility
of a nil error with commands from other scripts.
I've also added a multi-timer, mean stats and some
other code optimizations.
« Last Edit: March 09, 2008, 09:30:17 pm by Mutor »
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline ]-[€LL§L톆L€ÅnG€L

  • Member
  • ***
  • Posts: 33
  • Karma: +8/-0
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #3 on: March 09, 2008, 10:55:34 pm »
Great! oh i did get 1 error in the earlier script but i couldnt catch it (damn) i was too quick to put the upgraded one in. Not to worry this one is working just fine ;D ;D ;D

Foffa

  • Guest
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #4 on: March 10, 2008, 04:20:35 pm »
[18:17:48] <[TopTen]> top10.lua:101: attempt to call global 'GetShares' (a nil value)
[18:17:48] *** DiXBoT v2.0_RC2 Build 2657 for PtokaX 0.4.0.0 has been Loaded in 0.344 Second(s)
[18:17:52] <[TopTen]> top10.lua:216: attempt to index global 'Top' (a nil value)
[18:18:02] <[TopTen]> top10.lua:211: attempt to index global 'Top' (a nil value)
[18:18:02] <[TopTen]> top10.lua:211: attempt to index global 'Top' (a nil value)
[18:18:03] <[TopTen]> top10.lua:216: attempt to index global 'Top' (a nil value)
[18:18:03] <[TopTen]> top10.lua:216: attempt to index global 'Top' (a nil value)
[18:18:09] <[TopTen]> top10.lua:371: bad argument #1 to 'x' (table expected, got nil)


I changed nothing!

Offline Psycho_Chihuahua

  • Systemspecialist IT
  • Administrator
  • Emperor
  • *****
  • Posts: 1 125
  • Karma: +112/-2
  • I am wherever i want to be
    • PtokaX Luaboard
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #5 on: March 10, 2008, 05:27:37 pm »
[18:17:48] <[TopTen]> top10.lua:101: attempt to call global 'GetShares' (a nil value)
[18:17:48] *** DiXBoT v2.0_RC2 Build 2657 for PtokaX 0.4.0.0 has been Loaded in 0.344 Second(s)
[18:17:52] <[TopTen]> top10.lua:216: attempt to index global 'Top' (a nil value)
[18:18:02] <[TopTen]> top10.lua:211: attempt to index global 'Top' (a nil value)
[18:18:02] <[TopTen]> top10.lua:211: attempt to index global 'Top' (a nil value)
[18:18:03] <[TopTen]> top10.lua:216: attempt to index global 'Top' (a nil value)
[18:18:03] <[TopTen]> top10.lua:216: attempt to index global 'Top' (a nil value)
[18:18:09] <[TopTen]> top10.lua:371: bad argument #1 to 'x' (table expected, got nil)


I changed nothing!

try putting topten above dixbot in the script manager, and a dixbot update wouldnt be a bad idea either ;)

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #6 on: March 10, 2008, 09:44:22 pm »
No Foffa's right, I had merged two functions at last revision
and forgot to correct those two calls. The script above has
been updated. Please update your local copy. It is best to
load this script first if possible for best results. Shake well.  :P
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Foffa

  • Guest
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #7 on: March 11, 2008, 08:43:43 am »
let's check

Foffa

  • Guest
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #8 on: March 11, 2008, 09:42:06 am »
It works but hard to translate...
And my ops don't have top10 menu anyway

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #9 on: March 11, 2008, 11:06:58 am »
Are you using standard profiles?
Is the operator profile set to true
in the profiles table?

My operators have the menu.
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Foffa

  • Guest
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #10 on: March 11, 2008, 01:58:59 pm »
yep, all is right, but they don't have it

I think that 'cause i've got one menu called Galaktix (that's hub name) for ops and your script makes the same one.

Offline TwîsTèd-dèvîl

  • Viking
  • ****
  • Posts: 510
  • Karma: +79/-2
    • EURO-OP
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #11 on: March 11, 2008, 05:51:59 pm »
try moving the script up or down in the script manager ..

Foffa

  • Guest
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #12 on: March 11, 2008, 06:00:39 pm »
It runs first of all now

Offline TwîsTèd-dèvîl

  • Viking
  • ****
  • Posts: 510
  • Karma: +79/-2
    • EURO-OP
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #13 on: March 11, 2008, 06:31:06 pm »
Are you by any chance using pxcommands too ...
If i have topten at top   i dont get cmds , but moving it lower it works

Foffa

  • Guest
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #14 on: March 11, 2008, 07:17:23 pm »
It hates me I think... Top, middle, bottom... Don't work 4 op's anyway...

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #15 on: March 11, 2008, 09:58:38 pm »
PxCommands has an option to clear the menus which I feel is best.
This is of course optional but if enabled PxCommands should be
your first script. In this way menus are still cleared and then
rebuilt by PxCommands [fir hub commands] and by all other sub-
sequent script that follow. With this method, you will never get
a double menu. Foffa, if you fell it conflicts with other script, you
can diable other scripts momentarily to find the culprit or you may
change the name for the menu as well as the submenu. I find it odd
that only the operator profile doesn't get the menu/submenu.
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #16 on: March 12, 2008, 12:31:18 am »
Another bug fix, script updated.
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Foffa

  • Guest
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #17 on: March 12, 2008, 10:29:19 am »
After update they have it

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #18 on: March 12, 2008, 11:06:23 am »
That's odd. The update had nothing to do with commands.
But we won't argue with success, I'm glad it's sorted.
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline Gnuff™

  • Double Ace
  • *
  • Posts: 136
  • Karma: +21/-1
    • ¨˜”°ºGnuff´s Hideout•º°”˜¨
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #19 on: April 03, 2008, 03:54:48 am »
Not sure if this is what we call a bug  ;D

   Top Ten UpTimes Total: 1 day, 23 hours, 53 minutes      Mean: 4 hours, 47 minutes
   |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
   #)   UpTimes                                     Percent Total   User Nick

   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
   1)   3 weeks, 3 days, 18 hours, 24 minutes       1241.29            [P@Z]Sindholt
   ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   2)   3 weeks, 3 days, 18 hours, 22 minutes       1241.23            [RO][RDS]shanti-spirit
   ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   3)   3 weeks, 3 days, 18 hours, 19 minutes       1241.11            [DK]LV
   ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   4)   3 weeks, 3 days, 18 hours, 13 minutes       1240.91            korny
   ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   5)   3 weeks, 3 days, 18 hours, 8 minutes        1240.74            aurbo
   ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   6)   3 weeks, 3 days, 18 hours, 6 minutes        1240.66            Drive_Eto_ya
   ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   7)   3 weeks, 3 days, 18 hours, 4 minutes        1240.60            speednoise2
   ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   8)   3 weeks, 3 days, 17 hours, 56 minutes       1240.33            [P@Z]sprocket
   |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   9)   3 weeks, 3 days, 17 hours, 55 minutes       1240.27            Tobbe
   |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   10)   3 weeks, 3 days, 17 hours, 53 minutes       1240.21            [CS]netcom
   |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||


A little too much percent maybe
Gnuff

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #20 on: April 03, 2008, 03:57:58 am »
No that is accurate, the percentage is relative to the hub uptime.
I had made a change some time ago...
Code: [Select]
[21:56:15] <[TopTen]>

Top Ten UpTimes Total: 23 hours, 9 minutes Mean: 2 hours, 18 minutes
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
#) UpTimes                                  Percent Total User Nick

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
1) 3 weeks, 1 day, 3 hours, 48 minutes      +100.00%          Unregistered
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2) 3 weeks, 1 day, 3 hours, 47 minutes      +100.00%          SolRosenberg
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3) 3 weeks, 1 day, 3 hours, 47 minutes      +100.00%          [OP]Cheat_Assassin
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
4) 3 weeks, 1 day, 3 hours, 47 minutes      +100.00%          Mutor
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline ]-[€LL§L톆L€ÅnG€L

  • Member
  • ***
  • Posts: 33
  • Karma: +8/-0
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #21 on: April 03, 2008, 10:53:00 am »
Just to let you know Hun I updated the script too and everything is working as it should :P :P :P

Offline Back4mHell

  • Newbie
  • *
  • Posts: 2
  • Karma: +1/-0
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #22 on: August 23, 2008, 06:36:36 pm »
dude its. not working  :'(

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #23 on: August 23, 2008, 09:02:18 pm »
dude, could you be more vague?
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline WhiteKnuckles

  • Member
  • ***
  • Posts: 25
  • Karma: +3/-3
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #24 on: September 30, 2008, 05:14:17 pm »
It seems that the Total Hubshare is not updating when a record is broken (or if the 10th best is beaten).  Currently I only have two entries for Total Hubshare and have been running this script for about a month.  Also with Top Users it appears that an entry is only made when the record is beaten and nothing is done if say the number of users ranks 3rd on the list.
Am I misunderstanding something about the way this script works or is there something wrong?

Thanks for your efforts on many fine scripts Mutor.

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
TopTen 1.0b LUA 5.1x [Strict][API 2]
« Reply #25 on: September 30, 2008, 11:23:11 pm »
Perhaps the title is a bit misleading. Although it is Top Ten
with hub share and users the number must be greater that
the greatest number existing in the respective table.
This means there will not always be ten entries for some tables.
It will however, cache up to the ten greatest values.
I could change this if it's not what you want. Here is an aged,
yet unreleased version. Perhaps you'll fair better with it. :P

Code: [Select]
--[[

TopTen 1.0b LUA 5.1x [Strict][API 2]

By Mutor 03/07/08

Display top ten stats for your hub with
a 'bargraph' type display.

- Provides permission by profile
- Provides context menu [right click]
- Provides option to change bargraph character

- Currently provides the following:
•HubShare -- Total Hub Share
•Users -- Total Users
•UpTimes -- User session times [time logged in]
•UserShare -- User Shares
•Logins -- User connections
•ReConnections -- User reconnections
•Chat -- Number of chat messages by user
•ChatChars -- Number of chat characters by user
•Pms -- Number of private messages [pm's] by user
•PmChars -- Number of pm characters by user
•Cmds -- Number of commands [Chat received in command format with Hub prefixes]
•Smilies -- Number of 'smiley' codes. ie.':)' Settable in table below
•Lols -- Number of chat acronyms ie lol, rofl. Settable in table below
•CTMs -- Number of CTM, RCTM requests, indicates transfer activity
•Searches -- Number of user searches
•Kicks -- Number of kick commands [$Kick protocol command only]
•Redirs -- Number of redirections [$OpForceMove]
•Pingers -- Number of BotINFOArrival requests
•Unknowns -- Number of unknown commands sent to the hub and by whom

+Changes from 1.0 07/06/08
+Added clear command for all tables
+Added Allstats command
]]

--//-- Start User Settings --//--
-- Subfolder of scripts to store table data [will be created if non-existant]
local Folder = "TopTen"
-- File to store table data [within Folder path, as set above]
local File = "Tops.txt"
-- Name for the bot [SetMan.GetString(21) = pulled from the hub or use "Custom-Name"]
local Bot = "[TopTen]"
-- Admins nick for status / error messages
local OpNick = "Mutor"
-- Report all stats to OpNick in pm at script start? true/false
local Report = false
-- Bargraph character table, add/edit/delete as you wish. Set specific char below
local Chars = {
[1]="&#124;", -- |
[2]=string.char(149), -- •
[3]=string.char(155), -- ›
[4]=string.char(164), -- ¤
[5]=string.char(166), -- ¦
[7]=string.char(167), -- §
[8]=string.char(181), -- µ
[9]=string.char(182), -- ¶
[10]=string.char(254), -- þ
[11]="¦&#124;", -- ¦|
}
-- Set Bargraph character: Chars[x] Where 'x' is the index number from Chars table above
local GraphChar = Chars[1]
-- Table of ASCII characters to be considered 'smilies'
local Asc = {":-)",":)",":o)","=)",":-(",":(",";-)",";)",":-o",":o",":-O",":O",":-/",":/",":-p",":p",
":Þ",":->",":>","B-)",":@)",":-~)","(-:",":-|",":|","<:-)","<):-)","*<):-)","[:]",":-x",":x",":-&",
":-{)",":-B",":B",":-C",":C","':-)","8-)",":-9","3:-o",":O)",":-[",":-E",":-*",":'-(",":((",":'-)",
":-@","I-)","|-O","0:-)","[:-)",":@)","**==","=:-)"}
-- Table of Acronyms to be considered 'lols'
local Acr = {"lol","lmao","lmfao","rofl","rotfl","pmsl","cya","wb","l8r","omg","rtfm","afaik","imho","ty","yw"}
-- User Profiles
-- [#] = true/false, (true = Commands enabled, false = Commands disabled)
local Profiles  = {
[-1] = false, --Unregistered User
[0] = true, --Master
[1] = true, --Operator
[2] = true, --Vip
[3] = true, --Registered User
}
--//-- End User Settings --//--


local Path = Core.GetPtokaXPath().."scripts/"
local Scp,ReConn,UserCmds,Cnt,Save,Pause = "TopTen 1.0b",{},"",0,0,0
local Order = {"HubShare","Users","UpTimes","UserShare","Logins","ReConnections","Chat","ChatChars","Pms","PmChars","Cmds",
"Smilies","Lols","CTMs","Searches","Kicks","Redirs","Pingers","Unknowns","AllStats"}
OnStartup = function()
Save = TmrMan.AddTimer(5*60000)
if not Folder:find("^"..Path,1,true) then Folder = Path..Folder end
local ren,err = os.rename(Folder,Folder)
if err and not err:lower():find("permission denied") then
os.execute("md "..Folder:gsub("/","\\"))
end
if not File:find("^"..Folder,1,true) then File = Folder.."/"..File end
if loadfile(File) then
dofile(File)
Top.HubShare = HubRefresh(Core.GetCurrentSharedSize(),Top.HubShare,os.time())
Top.Users = HubRefresh(Core.GetMaxUsersPeak(),Top.Users,os.time())
Top.UserShare = GetValue(16,1024)
Top.UpTimes = GetValue(25,60)
else
local t,tb = {},Core.GetOnlineUsers()
Top = {
HubShare = {{os.time(),Core.GetCurrentSharedSize()},},
Users = {{os.time(),Core.GetUsersCount()},},
UserShare = GetValue(16,1024),
UpTimes = GetValue(25,60),
Logins = GetLogins(),
ReConnections ={},
Chat = {},
ChatChars = {},
Pms = {},
PmChars = {},
Cmds = {},
Smilies = {},
Lols = {},
CTMs = {},
Searches = {},
Kicks = {},
Redirs = {},
Pingers = {},
Unknowns = {},
}
end
local Pfx,Hub = SetMan.GetString(29):sub(1,1),SetMan.GetString(0)
assert(Pfx) assert(Hub)
Cnt = #Order
local om = ""
for _,s in ipairs(Order) do
if Report then om = om..GetTen(Top[s],s) end
if not Top[s] then Top[s] = {} end
UserCmds = UserCmds.."$UserCommand 1 3 "..Hub.."\\"..Scp.."\\Clear\\"..s.."$<%[mynick]> "..Pfx..s.."-&#124;|"..
"$UserCommand 0 3 &#124;|$UserCommand 1 3 "..Hub.."\\"..Scp.."\\"..s.."$<%[mynick]> "..Pfx..s.."&#124;|"
end
SaveFile(File,Top,"Top")
if Report and om:len() > 0 then OnError(om,true) end
end

OnExit = function() SaveFile(File,Top,"Top") end

OnError = function(msg,pm)
local user = Core.GetUser(OpNick)
if user then
if pm then
Core.SendPmToUser(user,Bot,msg.."|")
else
Core.SendToUser(user,"<"..Bot.."> "..msg.."|")
end
end
end

OnTimer = function(Id)
Top.HubShare = HubRefresh(Core.GetCurrentSharedSize(),Top.HubShare,os.time())
Top.Users = HubRefresh(Core.GetMaxUsersPeak(),Top.Users,os.time())
if Id == Save then SaveFile(File,Top,"Top") end
if Id == Pause then
TmrMan.RemoveTimer(Pause)
Pause = 0
end
end

UserConnected = function(user)
Pause = TmrMan.AddTimer(2000)
Refresh(user,Top.Logins,1)
Top.UserShare = GetValue(16,1024,Top.UserShare)
Top.HubShare = HubRefresh(Core.GetCurrentSharedSize(),Top.HubShare,os.time())
if Profiles[user.iProfile] then
local Prof,Plural = "Unregistered User",""
if user.iProfile ~= -1 then Prof = ProfMan.GetProfile(user.iProfile).sProfileName end
if Cnt > 1 then Plural = "s" end
local msg = "<"..Bot.."> "..Prof.."'s "..Scp.." commands enabled. Right click "..
"hub tab or user list for menu. "..tostring(Cnt).." listing"..Plural.." available.|"
Core.SendToUser(user,UserCmds..msg)
end
end
OpConnected,RegConnected = UserConnected,UserConnected

UserDisconnected = function(user)
local x,n = TmrMan.AddTimer(10000,"ChkReConn"),user.sNick
if x and n and x ~= -1 then
table.insert(ReConn,{n,x})
end
if next(Top["UpTimes"]) then
for i,v in ipairs(Top["UpTimes"]) do
if v[1] == user.sNick then
if v[3] then
v[3] = v[3] + os.time() - v[2]
else
v[3] = os.time() - v[2]
end
SaveFile(File,Top,"Top")
end
end
end
end
RegDisconnected,OpDisconnected = UserDisconnected,UserDisconnected

ChatArrival = function(user,data)
local _,_,cmd,clr = data:find("%b<> ["..SetMan.GetString(29).."](%a+)([-]*)")
local _,_,to = data:find("^$To: (%S+) From:")
local _,_,msg = data:find("%b<> ([^|]+)|")
local x = msg:len()
if cmd then
Refresh(user,Top.Cmds,1)
if cmd:lower() == "allstats" then
local Reply = ""
for _,s in ipairs(Order) do
if s:lower() ~= "allstats" then Reply = Reply..GetTen(Top[s],s) end
end
return Core.SendPmToUser(user,Bot,Reply.."|"),true
end
if Profiles[user.iProfile] and Top[cmd] then
if clr and clr == "-" then
if next(Top[cmd]) then
Top[cmd] = {}
if not next(Top[cmd]) then
SaveFile(File,Top,"Top")
return Core.SendToUser(user,"<"..Bot.."> "..
cmd.." has been cleared|"),true
end
else
return Core.SendToUser(user,"<"..Bot.."> Error! The "..
cmd.." table is already empty.|"),true
end
else
return Core.SendToUser(user,"<"..Bot.."> "..GetTen(Top[cmd],cmd).."|"),true
end
end
end
if to then
Refresh(user,Top.Pms,1)
if x > 0 then Refresh(user,Top.PmChars,x) end
else
Refresh(user,Top.Chat,1)
if x > 0 then Refresh(user,Top.ChatChars,x) end
end
Update(user,data,Asc,Top.Smilies)
Update(user,data,Acr,Top.Lols)
end
ToArrival = ChatArrival

KickArrival = function(user,data)
Refresh(user,Top.Kicks,1)
end

UnknownArrival = function(user,data)
Refresh(user,Top.Unknowns,1)
end

OpForceMoveArrival = function(user,data)
Refresh(user,Top.Redirs,1)
end

ConnectToMeArrival = function(user,data)
Refresh(user,Top.CTMs,1)
end
RevConnectToMeArrival,MultiConnectToMeArrival = ConnectToMeArrival,ConnectToMeArrival

SearchArrival = function(user,data)
Refresh(user,Top.Searches,1)
end
MultiSearchArrival = SearchArrival

BotINFOArrival = function(user,data)
Refresh(user,Top.Pingers,1)
end

ChkReConn = function(Id)
if ReConn then
if next(ReConn) then
for i = 1, #ReConn do
if type(ReConn[i]) == "table" and #ReConn[i] == 2 then
if ReConn[i][2] == Id then
local user = Core.GetUser(ReConn[i][1])
if user then
Refresh(user,Top.ReConnections,1)
SaveFile(File,Top,"Top")
end
ReConn[i] = nil
end
else
ReConn[i] = nil
TmrMan.RemoveTimer(Id)
end
end
end
else
ReConn = {}
end
end

GetLogins = function()
local t,tb = {},Core.GetOnlineUsers()
if next(tb) then for _,u in ipairs(tb) do table.insert(t,{u.sNick,1}) end end
return t
end

HubRefresh = function(count,tab,date)
if tab then
local chg,min,tot = false,0,0
if next(tab) then for i,v in ipairs(tab) do min = math.max(min,v[2]) tot = tot + v[2] end end
if not date then return math.max(count,min),tot  end
if count > min then
local chk = function(t,i)
for i,v in ipairs(t) do if i == v[2] then return false end return true end
end
if chk(tab,count) then table.insert(tab,{os.time(),count}) end
table.sort(tab,function(a,b) return a[2] > b[2] end)
while #tab > 10 do
table.remove(tab,#tab) table.sort(tab,function(a,b) return a[2] > b[2] end)
end
end
end
return tab
end

Refresh = function(user,tab,x)
if tab then
local chg = false
if next(tab) then
for i,v in ipairs(tab) do
if v[1]:lower() == user.sNick:lower() then
v[2] = v[2] + x
chg = true
break
end
end
end
if not chg then table.insert(tab,{user.sNick,x}) end
table.sort(tab,function(a,b) return a[2] > b[2] end)
while #tab > 10 do
table.remove(tab,#tab)
table.sort(tab,function(a,b) return a[2] > b[2] end)
end
end
end

Update = function(user,data,arr,tab)
local bool,x = false,0
data = data:sub(1,-2):lower()
for _,code in ipairs(arr) do
code = code:gsub("[%p]","%%%1")
local chr,count = data:gsub(code,"%1")
if count and count > 0 then x = x + count end
end
if x > 0 then Refresh(user,tab,x) bool = true end
return bool
end

GetValue = function(val,min,tab)
local t = {}
for _,user in ipairs(Core.GetOnlineUsers()) do
local x = Core.GetUserValue(user,val)
if x > min then
local chk = function(t,i)
for i,v in ipairs(t) do if i == v[2] then return false end return true end
end
if not tab or chk(tab,x) then
table.insert(t,{user.sNick,tonumber(x)})
end
end
end
if next(t) then
table.sort(t,function(a,b) return a[2] > b[2] end)
while #t > 10 do table.remove(t,#t) end
end
return t
end

GetTen = function(t,h)
local s,x,y,c,m,f,hdr,bar,art,col = "",0,0,0,"","40.50","",GraphChar,"¯","User Nick"
if t and next(t) then
if h:lower():find("^uptimes$") then
table.sort(t, function(a,b) return a[2] < b[2] end)
else
table.sort(t, function(a,b) return a[2] > b[2] end)
end
for i,v in ipairs(t) do x = x + v[2] end
y = x
for i,v in ipairs(t) do
if i < 11 and v[2] > 0 then
local n,z,k,sp = v[1],v[2],v[2],""
if h:lower():find("^hubshare$") or h:lower():find("^users$") then
if h:lower():find("^hubshare$") then
x,c = HubRefresh(Core.GetCurrentSharedSize(),Top.HubShare)
m,y,z = FmtSz(c/#t,3),FmtSz(x,3),FmtSz(v[2],3)
else
_,c = HubRefresh(Core.GetMaxUsersPeak(),Top.Users)
x,m,y,z = Core.GetMaxUsersPeak(),tostring(math.ceil(c/#t)),tostring(x),tostring(v[2])
end
f,n,col = "20.15",os.date("%m/%d/%Y",v[1]),"Date"
elseif h:lower():find("^uptimes$") then
x,m,y,z,f,k = Core.GetUpTime(),Convert(os.time() - (x/10),6),Convert(os.time() - x,6),Convert(v[2],6),"40.50",os.time()-k
if z and z:len() < 10 then sp = sp.."\t" end
elseif h:lower():find("^usershare$") then
m,y,z,f = FmtSz(x/#t),FmtSz(x),FmtSz(v[2]),"20.15"
else
m = tostring(math.ceil(x/#t))
end
local pct,mod = (k/x) * 100,""
if pct > 100 then mod = "+" end
pct = math.min(pct,100)
s = s.."\t"..i..")\t"..string.format("%-"..f.."s ",z)..sp.."\t"..mod..
string.format("%-15.7s ",string.format("%.2f%%",pct)).."\t"..n.."\n\t"..
bar..bar:rep(pct).."\n"
end
end
hdr = "\n\n\tTop Ten "..h.." Total: `\t\tMean: "..m.."\n\t"..bar:rep(101).."\n\t"..art:rep(65).."\n"..
"\t#)\t"..string.format("%-"..f.."s ",h).."\tPercent Total\t"..col.."\n\n\t"..art:rep(65).."\n"
return hdr:gsub("`",y)..s
else
return "Sorry, there isn't any "..string.format("%q",h).." data available at this time.\n"
end

end

FmtSz = function(int,dec)
dec = dec or 2
local i,u,x= int or 0,{"","K","M","G","T","P"},1
while i > 1024 do i,x = i/1024,x+1 end return string.format("%."..dec.."f %sB.",i,u[x])
end

Convert = function(time,inc)
local s,x,n = "",0,os.time()
local tab = {{31556926,"year"},{2592000,"month"},{604800,"week"},
{86400,"day"},{3600,"hour"},{60,"minute"},{1,"second"}}
inc = inc or #tab
if time > 0 and time < n then
time = n - time
for i,v in ipairs(tab) do
if i <= inc and time > v[1] then
x = math.floor(time/v[1])
if x > 1 then v[2] = v[2].."s" end
if x > 0 then
s = s..x.." "..v[2]..", "
time = time-x*v[1]
end
end
end
return s:sub(1,-3)
else
local a,b = os.date("%m/%d/%Y",86400),os.date("%m/%d/%Y",2145876658)
return "Invalid time supplied. [must be > "..a.." and < "..b.."]"
end
end

SaveFile = function(file,table, tablename )
local hFile = io.open (file , "wb")
Serialize(table, tablename, hFile)
hFile:close()
collectgarbage("collect")
end

Serialize = function(tTable, sTableName, hFile, sTab)
local x = pairs
sTab = sTab or "";
if type(sTab) == "table" and next(sTab) then x = ipairs end
hFile:write(sTab..sTableName.." = {\n" )
for key, value in x(tTable) do
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
hFile:write( sTab.."}")
end
« Last Edit: December 06, 2009, 04:58:49 pm by Mutor »
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline WhiteKnuckles

  • Member
  • ***
  • Posts: 25
  • Karma: +3/-3
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #26 on: October 06, 2008, 02:34:37 pm »
Thanks Mutor, I will give that a try.
I did also find recently (since my last post) that it did not update the Top Hub Share when the No 1 record was broken briefly a few times.  How often does it check whether a record is broken? (or does it check upon arrival of a new user).  In both cases the record would have been broken after someone finished hashing files.

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #27 on: October 06, 2008, 10:55:42 pm »
User and Hub share should update at script
start and then at each connection thereafter.
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline quicky2g

  • Fulll Member
  • ****
  • Posts: 71
  • Karma: +2/-0
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #28 on: October 10, 2008, 06:08:55 am »
Nice update! I really like the AllStats command that shows up in a personal message

Offline Crillle

  • Junior Member
  • **
  • Posts: 19
  • Karma: +1/-0
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #29 on: October 20, 2008, 07:27:11 am »
Hi!

I get this after running it for some time:

Syntax TopTen 1.0 LUA 5.1x.lua:375: attempt to index local 'hFile' (a nil value)

I tried to move the script up and down, but it´s no differens


Regards

Crille

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #30 on: October 20, 2008, 12:08:53 pm »
Does the scripts/TopTen folder exist? Does Tops.txt exist within it?
« Last Edit: December 06, 2009, 04:57:14 pm by Mutor »
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline Crillle

  • Junior Member
  • **
  • Posts: 19
  • Karma: +1/-0
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #31 on: October 21, 2008, 07:14:10 am »
No there did not exist a TopTen folder, but I created the folder, so now it works fine.

Thx Mutor   :)


Regards

Crille

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #32 on: October 21, 2008, 01:00:20 pm »
Well the script should have created it for you.
So I'm a bit curious why it didn't.
What OS are you running?
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline Crillle

  • Junior Member
  • **
  • Posts: 19
  • Karma: +1/-0
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #33 on: October 22, 2008, 08:01:03 am »
XP Pro  Sp3


Regards

Crille

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: TopTen 1.0 LUA 5.1x [Strict][API 2]
« Reply #34 on: October 22, 2008, 12:54:41 pm »
That even makes me more curious. As I'm on XP SP3.
I stopped the script and removed the TopTen folder.
Then restarted the script, both the folder and file
were created as they should be. I noticed that I do
have and extra slash in the folder path, which had no
bearing on the function. Still I've corrected that in
the script above [v1.0b].
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

 

determinate determinate
guestbook