PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: BoJlk on 02 November, 2004, 03:42:27

Title: HUB Activiy Report
Post by: BoJlk on 02 November, 2004, 03:42:27
Hello all...

I'm seeking for two script:

1st: Some litle script for reporting about  user activity
meaning the script will Collect information about
how many users were connected/disconnected from the hub, what kind activity been made by the users PM messages, Chat messages, searches...
i want to know the peak activity hours in my HUB's
and i want to know how many user's were kicked/warned/banned by what OP/VIP/Master
And i know there an option in the RC for that
[*edit]And maybe the script will Show the Activity information by percents, example "Users Activity on 10/10/04 17:00~22:00 was: 67% of peak activity"

2nd: is there a posibily for Redirect upon Disconnect
no redirecting user when disconnected from the hub
but for redirecting them when suddenly the Hub goes down...i don't think it's possible because if the ProtaX is Crashes it can't make any action to the connected user
but correct me if i'm wrong.
Title:
Post by: enema on 02 November, 2004, 18:17:10
whoa, thats one heck of a request :) I was starting to make my own script when I found this:

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

It doesnt show any PM or searching activities though
Title:
Post by: imby on 02 November, 2004, 19:06:18
You can use !stats in the hubsoft if you use 15.25, for that
Title:
Post by: BoJlk on 02 November, 2004, 19:07:04
10x enema never mind the Searches thou, does the script stores the info in a *.dat file or somethign else?

And nice command !stat
it's almost perfect, i want it to be more specific...
Title:
Post by: enema on 02 November, 2004, 19:47:55
that script supposed to store all data in txt\HubStats.txt

...I have never tested it thou..

hell, yeah! !stats is great, but it doesnt give any data about peak hours in hub.
Title:
Post by: enema on 02 November, 2004, 19:56:30
s*it, forgot this one - you should create another txt file in txt folder - UserHubTime.txt

it should contain this "code":
UserHubTime = {
["HubUpTime"] = 0,
}

Oh, and last thing - this txt folder should be inside scripts folder
Title:
Post by: BoJlk on 08 November, 2004, 17:07:39
okey 10x