PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: AMediaMan on 03 February, 2004, 18:00:49

Title: Total Hub Stat Script ???
Post by: AMediaMan on 03 February, 2004, 18:00:49
Hey hey all you scripters out there i am looking for a script that tells me and the users the hubs total stats.

Say if the command was !total it would show you this.

total logins = xxxxx
total bans = xxxxx
total kicks = xxxxx
highest share level = xxxxx
highest user level = xxxxx
and whatever else that might be handy :)

I would like these to be an over all total and not a daily total if possible.
I know PtokaX has a joins and leaves stat on it but it clears on every reset. :(
And i use the latest record script for peak share and peak user total but it seems to reset itself for no reason :(

Any help would be great thnx,
                     AMediaMan

PS. I am useing PtokaX td4 and if such a script is already out please point me to it :) thnx again.
Title:
Post by: Cyberia on 03 February, 2004, 18:53:22
I know Robocop has such function in it.
with !hstat or with the Robocop Gui (Counters Screen).

I don't know if there are other scripts with this function in it.  :]
Title:
Post by: NightLitch on 03 February, 2004, 18:59:20
I Will have All sorts of counters in my script NXS-3 so keep your eyes open if now
my script is intressting.
Title:
Post by: c h i l l a on 03 February, 2004, 19:12:00
my little version
--Hub Stats V.01 by chill
--Serialisation by RabidWombat

statFile = "HubStats.txt" -- The Filename
statFolder = "txt" -- The Foldername set it to nil if not wanted
Max1 = 30 -- Time between each stats saving
cmd1 = "+hubstats" -- Shows the Hub Stats

--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
-- MAIN SCRIPT
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------

if statFolder then
statFile = statFolder.."/"..statFile
end

HubStats = {
Logins = 0,
MaxShareAmount = frmHub:GetCurrentShareAmount(),
MaxUsers = frmHub:GetUsersCount(),
StatsSince = date("%d/%m/%y"),
}
dofile(statFile)
--------------------------------------------------------
function Main()
SetTimer(60*1000*Max1)
StartTimer()
end
function OnExit()
WriteTable(HubStats,"HubStats",statFile)
end
--------------------------------------------------------
function OnTimer()
WriteTable(HubStats,"HubStats",statFile)
end
--------------------------------------------------------
function NewUserConnected(curUser)
if (frmHub:GetCurrentShareAmount() > HubStats.MaxShareAmount) then
HubStats.MaxShareAmount = frmHub:GetCurrentShareAmount()
end
if (frmHub:GetUsersCount() > HubStats.MaxUsers) then
HubStats.MaxUsers = frmHub:GetUsersCount()
end
HubStats.Logins = HubStats.Logins + 1
end
OpConnected = NewUserConnected
--------------------------------------------------------
function DataArrival(curUser,data)
if strsub(data,1,1) == "<" then
data = strsub(data,strlen(curUser.sName)+4,strlen(data)-1)
local _,_,word1 = strfind(data,"^(%S+)")
if word1 and hubStatFunc[word1] then
curUser:SendData(hubStatFunc[word1]())
return 1
end
end
end
---------------------------------------------------------------------------------------

-- Hub Stats Functions
---------------------------------------------------------------------------------------
hubStatFunc = {
[cmd1] = function()
local msg = "---  Hub Stats Since "..HubStats.StatsSince.."  ---\r\n\r\n"
msg = msg.."\tLogins: "..HubStats.Logins.."\r\n"..
"\tPeak Users: "..HubStats.MaxUsers.."   -   Current Users: "..frmHub:GetUsersCount().."   -   Max Users Allowed: "..frmHub:GetMaxUsers().."\r\n"..
"\tPeak Share: "..format("%.2f",(HubStats.MaxShareAmount/(1024*1024*1024*1024))).." TB"..
"   -   Current Share: "..format("%.2f",(frmHub:GetCurrentShareAmount()/(1024*1024*1024*1024))).." TB"..
"   -   Share/User: "..format("%.2f",(frmHub:GetCurrentShareAmount()/(1024*1024*1024)/frmHub:GetUsersCount())).." GB/User\r\n\r\n"..
GetReggedUsers()
return(msg)
end,
}

function GetReggedUsers()
local tcount,pcount = 0,0,0
local msg = ""
for _,profile in GetProfiles() do
pcount = pcount + 1
local ucount = 0
for _,_ in GetUsersByProfile(profile) do
ucount = ucount + 1
tcount = tcount + 1
end
msg = msg.."\t    - "..profile..": "..ucount.."\r\n"
end
msg = "\tTotal Regged User: "..tcount.." in "..pcount.." Profiles\r\n\r\n"..msg
return(msg)
end
---------------------------------------------------------------------------------------

-- Write Tables

---------------------------------------------------------------------------------------
function WriteTable(table,tablename,file)
local handle = openfile(file,"w")
Serialize(table,tablename,handle)
  closefile(handle)
end
--------------------------------------------
function Serialize(tTable,sTableName,hFile,sTab)
sTab = sTab or "";
write(hFile,sTab..sTableName.." = {\n");
for key,value in tTable do
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
if(type(value) == "table") then
Serialize(value,sKey,hFile,sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
write(hFile,sTab.."\t"..sKey.." = "..sValue);
end
write(hFile,",\n");
end
write(hFile,sTab.."}");
end
Title:
Post by: AMediaMan on 04 February, 2004, 00:34:21
Very nice Chilla thnx :) any way of adding total kicks and total bans ??? if so i would be all set.

NightLitch i will also check yours out soon :)

Thnx for the quick response you guys,

                  AMediaMan

PS. thnx Cyberia but I already use a multi bot, but I have checked out Robo cop and it is a very nice script as well :o) thnx again.
Title:
Post by: c h i l l a on 04 February, 2004, 12:12:24
sure if you want to add it :).
But there are many ways of kicking banning etc. you would need to check all commands, so I left it.
Title:
Post by: AMediaMan on 04 February, 2004, 17:06:31
Well haha me adding it would be major mistake :(
it seems that every script i try to edit goes kaput heh
but anyhow i was just meaning maybe the PtokaX commands was all not every kick and ban, for that could be difficult.

Just the !kick and the !ban if its possible to add just those 2 from the actual PtokaX hub :)


thnx,
AMediaMan


PS. The other does work great :) thnx again
Title:
Post by: [NL]trucker on 05 February, 2004, 10:01:56
chill could you add a few things more?

like owner  [name]
      master    ,,
      admin      ,,
     
total  vips
total regs

hubname+hubaddy

hubuptime
 
min share
max share
min hubs
max hubs
total share in hub now
highest share
peak users

total time hub is alive and running so some kind of founding date.

could you please ???

this would be a total info script and i think it would look good :-)))
Title:
Post by: [NL]trucker on 05 February, 2004, 12:21:19
i have now this for hubstat

[12:09:50] ?==============???? [NL] ????? ]-[?? [NL]=================
[12:09:50]  ?
[12:09:50] ::HubOwner:[NL]trucker
[12:09:50] ::Hub Masters: TeQuilla-hollandse.ko
[12:09:50] ::Hub Address: funnyhub.no-ip.info
[12:09:50] ::HubNetwork: = ?????? Magmar ?????? Network Dutch Division !!
[12:09:50] ::Dutch Located : Dus NLers Welkom !!
[12:09:50] ::WebSite=www.magmar.tk
[12:09:50] ::Hub-eMail:magmarnetworks@tiscali.nl
[12:09:50] ::Max Users=200
[12:09:50] ::Min Share=1GB
[12:09:50] ::Uptime = 0 days, 23 hrs. 30 min. and 3 sec. = ?
[12:09:50] ?======47 of  200 Users Connected======

guess it would be complete with the addons i requested in the above post.
Title:
Post by: AMediaMan on 05 February, 2004, 15:43:27
Hey hey [NL]trucker wouldnt that be more of a hub info script than a hub stat script >:o).
haha just a thought :)



PtokaX RULZ                L8er,AMediaMan

PS. the above script does show the number of vip's, op's
and so on :)
Title:
Post by: c h i l l a on 05 February, 2004, 19:50:05
but calculate the hubs online time is a good one I think :)
will check it out.
Title:
Post by: AMediaMan on 05 February, 2004, 20:08:09
Well you know that would ba a cool thing to have :)
 
: total time hub is alive and running so some kind of founding date:

The date included in the script is kind of a up time date but it would be great to have a total hours and mins. of actual running time :)

AMediaMan
Title:
Post by: [NL]trucker on 06 February, 2004, 15:35:46
Amediaman


QuotePS. the above script does show the number of vip's, op's

nope it doesnt it is static i edited the script to show this two [it is a messagebot]

but i have more and also i have admins

QuoteHey hey [NL]trucker wouldnt that be more of a hub info script than a hub stat script >:o).

yup your right it would be a total script stat and info together.

think it would be great to have a  all in one .
Title:
Post by: [NL]trucker on 08 February, 2004, 22:58:02
is there anyone who is looking into this request yet?

i think it will be a great addition in my hub.
Title:
Post by: plop on 10 February, 2004, 13:38:53
QuoteOriginally posted by [NL]trucker
is there anyone who is looking into this request yet?

i think it will be a great addition in my hub.
i posted a script here somewhere which can show all from online/offline users/regs/vips/ops/masters.
it's a mod of the script your using now.

plop
Title:
Post by: AMediaMan on 11 February, 2004, 22:09:49
hey Plop you think you could do me fav. and
add maybe a total kick and maybe a total ban
for me? I just want the PtokaX commands for
kicks and bans if possible. I thank you or any1
who can make this possible >:o)



Thnx again, AMediaMan
Title:
Post by: AMediaMan on 19 February, 2004, 01:11:32
Hmmm is this a hard thing to do maybe :( well i will use what i have now thnx for the script :)




AMediaMan
Title:
Post by: plop on 19 February, 2004, 04:15:44
QuoteOriginally posted by AMediaMan
Hmmm is this a hard thing to do maybe :( well i will use what i have now thnx for the script :)
it's not that hard 2 do and you can find info/scripts here on the forum how 2 do it.
personaly i don't have the time right now, sorry for this but allready working on a big thing which is far from finished.

plop
Title:
Post by: AMediaMan on 19 February, 2004, 15:10:19
Ok thnx Plop :) i understand and i will look some
more :) and yes i know there are much more important things to work on :) my hub was also hacked just as the others :( so ............ i will leave the great minds alone to work on the bigger and better issues :)


AMediaMan
Title:
Post by: AMediaMan on 10 March, 2004, 03:40:31
Ok I just thought of something that might be a nice add on to this script if any1 can do it :)

First the script :

code:--------------------------------------------------------------------------------
--Hub Stats V.01 by chill
--Serialisation by RabidWombat

statFile = "HubStats.txt"   -- The Filename
statFolder = "txt"      -- The Foldername set it to nil if not wanted
Max1 = 30         -- Time between each stats saving
cmd1 = "+hubstats"      -- Shows the Hub Stats

--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
--   MAIN SCRIPT
--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------

if statFolder then
   statFile = statFolder.."/"..statFile
end

HubStats = {
   Logins = 0,
   MaxShareAmount = frmHub:GetCurrentShareAmount(),
   MaxUsers = frmHub:GetUsersCount(),
   StatsSince = date("%d/%m/%y"),
}
dofile(statFile)
--------------------------------------------------------
function Main()
   SetTimer(60*1000*Max1)
   StartTimer()
end
function OnExit()
   WriteTable(HubStats,"HubStats",statFile)
end
--------------------------------------------------------
function OnTimer()
   WriteTable(HubStats,"HubStats",statFile)
end
--------------------------------------------------------
function NewUserConnected(curUser)
   if (frmHub:GetCurrentShareAmount() > HubStats.MaxShareAmount) then
      HubStats.MaxShareAmount = frmHub:GetCurrentShareAmount()
   end
   if (frmHub:GetUsersCount() > HubStats.MaxUsers) then
      HubStats.MaxUsers = frmHub:GetUsersCount()
   end
   HubStats.Logins = HubStats.Logins + 1
end
OpConnected = NewUserConnected
--------------------------------------------------------
function DataArrival(curUser,data)
   if strsub(data,1,1) == "<" then
      data = strsub(data,strlen(curUser.sName)+4,strlen(data)-1)
      local _,_,word1 = strfind(data,"^(%S+)")
      if word1 and hubStatFunc[word1] then
         curUser:SendData(hubStatFunc[word1]())
         return 1
      end
   end
end
---------------------------------------------------------------------------------------

--   Hub Stats Functions
---------------------------------------------------------------------------------------
hubStatFunc = {
   [cmd1] = function()
      local msg = "---  Hub Stats Since "..HubStats.StatsSince.."  ---\r\n\r\n"
      msg = msg.."\tLogins: "..HubStats.Logins.."\r\n"..
      "\tPeak Users: "..HubStats.MaxUsers.."   -   Current Users: "..frmHub:GetUsersCount().."   -   Max Users Allowed: "..frmHub:GetMaxUsers().."\r\n"..
      "\tPeak Share: "..format("%.2f",(HubStats.MaxShareAmount/(1024*1024*1024*1024))).." TB"..
      "   -   Current Share: "..format("%.2f",(frmHub:GetCurrentShareAmount()/(1024*1024*1024*1024))).." TB"..
      "   -   Share/User: "..format("%.2f",(frmHub:GetCurrentShareAmount()/(1024*1024*1024)/frmHub:GetUsersCount())).." GB/User\r\n\r\n"..
      GetReggedUsers()
      return(msg)
   end,
}

function GetReggedUsers()
   local tcount,pcount = 0,0,0
   local msg = ""
   for _,profile in GetProfiles() do
      pcount = pcount + 1
      local ucount = 0
      for _,_ in GetUsersByProfile(profile) do
         ucount = ucount + 1
         tcount = tcount + 1
      end
      msg = msg.."\t    - "..profile..": "..ucount.."\r\n"
   end
   msg = "\tTotal Regged User: "..tcount.." in "..pcount.." Profiles\r\n\r\n"..msg
   return(msg)
end
---------------------------------------------------------------------------------------

--   Write Tables

---------------------------------------------------------------------------------------
function WriteTable(table,tablename,file)
   local handle = openfile(file,"w")
   Serialize(table,tablename,handle)
     closefile(handle)
end
--------------------------------------------
function Serialize(tTable,sTableName,hFile,sTab)
   sTab = sTab or "";
   write(hFile,sTab..sTableName.." = {\n");
   for key,value in tTable do
      local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
      if(type(value) == "table") then
         Serialize(value,sKey,hFile,sTab.."\t");
      else
         local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
         write(hFile,sTab.."\t"..sKey.." = "..sValue);
      end
      write(hFile,",\n");
   end
   write(hFile,sTab.."}");
end

How about adding a Peak uptime to this ? I think that would be cool >:o)

Any takers ???  Thnx ahead of time, AMediaMan

PS. Say like Max uptime = this many days, hours, and mins
Title:
Post by: [NL]trucker on 10 March, 2004, 08:20:17
Amediaman

look here perhaps you like this one

http://board.univ-angers.fr/thread.php?threadid=1435&boardid=13&sid=579bd8b13817711a69f077accfb1883c&page=5
Title:
Post by: AMediaMan on 14 August, 2004, 23:59:19
hey hey thnx [NL]trucker i like it.

been awhile but im back >:o)


not that i can script now lol but im back to browse all that has changed.

thnx again, AMediaMan
Title:
Post by: Skyhawk on 03 September, 2004, 01:49:58
Got another idea.

How about the following:

1. Show those stats at login (on/off)
2. Show those stats in main in intervals (on/off and interval)
3. Show those stats in PM in intervals (on/off and interval)

How about this?