Hi, all :-D
I use this script in a private hub, the " +allhubtime " command works, but not the other 2 (don't know why).
Is it possible to edit it so that it will open in a PM instead of in main? I think that one needs to reg a bot:
(function Main()
frmHub:RegBot(BotName) and to insert:
curUser:SendPM somewhere, but as a lot of people use this script frequently (kind of a contest) i don't dare to mess around with it myself :-P
--OnHub Time Logger V.1.63
--27.9.03 by c h i l l e r
--thx to tezlo for the nice calculation from minutes to months, days, etc., and to Nagini, and to RabidWombat
--Create a "txt" Folder in the PtokaX scripts Folder, like this /scripts/txt/
--ChangeLog :
--27.9.03 Added Serialisation.
-- Name this bot to what you want
bot="-=
=-"
--Name the commands to what you like
cmd1 = "+myhubtime"
cmd2 = "+allhubtime"
cmd3 = "+hubtime"
--This number stands for the maximum of displayed users, set it to what U like
Max = 300
--This number is for the timespan between each data saving in minutes.
Max1 = 30
--This number stands for time in minutes, a user must be online till he is saved to the file.
Max2 = 10
---------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------
File1 = "UserHubTime.txt"
sec = 1000
min = 60 * sec
var1 = 0
assert(dofile("txt/"..File1), "txt/"..File1.." for HubTime-V.163.lua not found")
function Main()
SetTimer(1 * min)
StartTimer()
end
function OnTimer()
for i,v in UserHubTime do
if GetItemByName(i) or i=="HubUpTime" then
v=v+1
UserHubTime=v
end
end
var1 = var1 + 1
if var1 == Max1 then
WriteFile(UserHubTime, "UserHubTime", File1)
var1 = 0
end
end
function NewUserConnected(curUser)
if UserHubTime[curUser.sName]==nil then
UserHubTime[curUser.sName]=0
end
end
function OpConnected(curUser)
if UserHubTime[curUser.sName]==nil then
UserHubTime[curUser.sName]=0
end
end
function DataArrival(curUser,data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind( data, "%b<>%s+(%S+)" )
if (cmd and strlower(cmd) == strlower(cmd1) and UserHubTime[curUser.sName] ) then
local tmp = UserHubTime[curUser.sName]
local months, days, hours, minutes = floor(tmp/43200), floor(mod(tmp/1440, 30)), floor(mod(tmp/60, 24)), floor(mod(tmp/1, 60))
curUser:SendData(bot, "You have been online : "..months.." months, "..days.." days, "..hours.." hours, "..minutes.." minutes ( "..tmp.." min ). That is "..format("%.2f",tmp/UserHubTime["HubUpTime"]*100).." % of the total HubUpTime.")
return 1
elseif (cmd and strlower(cmd) == strlower(cmd2)) then
curUser:SendData(bot, " -=< The user's uptime since 04-05-06 >=-\r\n"..
GetUserMaxTime().."\r\n")
return 1
elseif (cmd and strlower(cmd) == strlower(cmd3)) then
local tmp = UserHubTime["HubUpTime"]
local months, days, hours, minutes = floor(tmp/43200), floor(mod(tmp/1440, 30)), floor(mod(tmp/60, 24)), floor(mod(tmp/1, 60))
curUser:SendData(bot, "The hub has now been online : "..months.." months, "..days.." days, "..hours.." hours, "..minutes.." minutes ( "..tmp.." min ).")
return 1
end
end
end
----------------------------------------------------------------------------------------------------------
function WriteFile(table, tablename, file)
local handle = openfile("txt/"..file, "w")
write(handle, tablename.." = {\n" )
for key, value in table do
if value >= Max2 then
write(handle, "\t"..format("[%q]",key).." = "..value..",\n")
end
end
write(handle, "}");
closefile(handle)
end
----------------------------------------------------------------------------------------------------------
function GetUserMaxTime()
local TCopy={}
for i,v in UserHubTime do
if i~="HubUpTime" then
tinsert( TCopy, { tonumber(v),i } )
end
end
sort( TCopy, function(a, b) return (a[1] > b[1]) end)
local msg ="\r\n"
for i = 1,Max do
if TCopy then
local months, days, hours, minutes = floor(TCopy[1]/43200), floor(mod(TCopy[1]/1440, 30)), floor(mod(TCopy[1]/60, 24)), floor(mod(TCopy[1]/1, 60))
msg = msg.."\t\t# "..i.." - "..TCopy[2].."\t::\t"..months.." Months, "..days.." Days, "..hours.." Hours, "..minutes.." Min ( "..TCopy[1].." min ).\r\n"
end
end
local TCopy={}
return msg
end
----------------------------------------------------------------------------------------------------------