PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: gizmo on 12 November, 2003, 11:05:59

Title: timer
Post by: gizmo on 12 November, 2003, 11:05:59
hi

ihave a low aand hi share script who redirect users to the right hub i only wonder is it possible to put in a timer
funktion so the users stay in hub 1 min before its redirect because i have a script who checks the users for bad files.

Title:
Post by: klownietklowniet on 12 November, 2003, 11:28:31
Depends on what the script looks like. There might be need to do some changes. I think it redirects them in NewUserConnected. If so then you need to change the script to add the usernames to a list instead of redirect them, and add the timer so it checks that every minute. That is not 100% accurate though, since a user might login and then the timer might get executed just after, so less that 1 minute. Depends on how accurate you wanna be, you can set the timer to hit every 10 secs, and add the nicks to an assosiative array, with nickname as key and the time they logged in in as value, and on timer go through that one. Just be ready for some heavy resources...

So it should be done, just show us the script...
Title:
Post by: gizmo on 12 November, 2003, 20:48:11
-- Share Checker with High & Low Redirect
-- By NightLitch 2003
-- Users between 15 & 40 Gb stays in the hub, otherwise under
-- 15Gb redirected to hub1 alt. hub2 with 40Gb

BotName = "-Checker-"

kb = 1024
mb = kb*kb
gb = kb*kb*kb

LOWminShare = 20 * gb --// Users under 15Gb is being redirected to Address 2
BIGmaxShare = 20 * gb --// Users Over 40Gb is being redirected to Address 1
Redirect1 = "xxx.myftp.org" --// Redirect Address for HIGH Share Here
Redirect2 = "xxx.myftp.org" --// Redirect Address for LOW Share Here

function Main()
--   frmHub:RegBot(Bot)
end

function NewUserConnected(curUser)
i,j,temp = strfind(curUser.sMyInfoString, "$(%d+)%$")
   if temp == nil then
   curUser:Disconnect()
   return
   end

   Share = format("%0.2f", tonumber(temp)/gb)
   if tonumber(temp) < LOWminShare then
      curUser:SendPM("ShareCheck", "You Share "..Share..". You are being Redirected to a Low Share Hub....")
      curUser:SendData("$ForceMove "..Redirect2);

   else
   if tonumber(temp) > BIGmaxShare then
         curUser:SendPM("ShareCheck", "You Share "..Share..". You are being Redirectedto a High Share Hub....")
         curUser:SendData("$ForceMove "..Redirect1);


      end
   end
end
Title:
Post by: gizmo on 15 November, 2003, 00:13:19
can i put i timer in that script ??
Title:
Post by: klownietklowniet on 16 November, 2003, 00:01:02
I just wrote this and haven't tested it at all...

-- Share Checker with High & Low Redirect
-- By NightLitch 2003
-- Users between 15 & 40 Gb stays in the hub, otherwise under
-- 15Gb redirected to hub1 alt. hub2 with 40Gb
-- Added timer ( klownietklowniet ) 16-11-2003

BotName = "-Checker-"

kb = 1024
mb = kb*kb
gb = kb*kb*kb

LOWminShare = 15 * gb --// Users under 15Gb is being redirected to Address 2
BIGmaxShare = 40 * gb --// Users Over 40Gb is being redirected to Address 1
Redirect1 = "xxx.myftp.org" --// Redirect Address for HIGH Share Here
Redirect2 = "xxx.myftp.org" --// Redirect Address for LOW Share Here

rusers = {}

function Main()
-- frmHub:RegBot(Bot)
   SetTimer(60000)
   StartTimer()
end

function NewUserConnected(curUser)
   i,j,temp = strfind(curUser.sMyInfoString, "$(%d+)%$")
   if temp == nil then
      curUser:Disconnect()
      return
   end

   Share = format("%0.2f", tonumber(temp)/gb)
   if tonumber(temp) < LOWminShare then
      rusers[curUser.sName] = "2"
   elseif tonumber(temp) > BIGmaxShare then
      rusers[curUser.sName] = "1"
   end
end


function UserDisconnected(curUser)
      rusers[curUser] = nil
end


function OnTimer()

   for n, i in rusers do
      local tempuser = GetItemByName(n)
      if tmpuser ~= nil then
         if i == 1 then
            tempUser:SendPM("ShareCheck", "You Share "..Share..". You are being Redirectedto a High Share Hub....")
            tempUser:SendData("$ForceMove "..Redirect1);
         else
            tempUser:SendPM("ShareCheck", "You Share "..Share..". You are being Redirectedto a High Share Hub....")
            tempUser:SendData("$ForceMove "..Redirect2);
         end
      end
   end

   rusers = {}

end