OnHub Time Logger V.1.63 in PM
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

OnHub Time Logger V.1.63 in PM

Started by Not, 13 June, 2004, 22:12:02

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Not

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

Not

Thank you, Mutor  :-D

This board is gold! Where else can one find so much help and so much knowledge? I really appreciate that you take your spare time to help Newbies like me out!

SMF spam blocked by CleanTalk