--============================================================
--========= Network hub pinger redirector script =============
--============= By ??????Hawk?????? 25-05-04 =================
--=========Edited 21-17-04 It Now Works Properly==============
--=====This Script is designed to be run on its own hub ======
--======= Use another Ptokax hub on a different port =========
--============================================================
--========== +rdon = enable / +rdoff = disable ===============
--================== Editable settings =======================
function Main()
sBot = "Imperial-Array" --// Bot name
DefaultHub = "somearray:5415" --// Default redirect hub
RedirectsEnabled = "true" --// true/false Auto start
Pingmins = 30 --// Ping Next Hub after # mins
RedirectTime = 30 --// Change redirect addy after # mins
Hub_Adress = {
"somehub.no-ip.com",
"411",
}
Onlinehubs = {}
HubCounter = 1
curenthub = 1
curentport = 2
timer1 = 0
timer2 = 0
hubcount = getn(Hub_Adress)
SetTimer(1000)
if RedirectsEnabled == "true" then
StartTimer()
end
end
function NewUserConnected(curUser)
if (RedirectsEnabled == "false") then
frmHub:SetRedirectAddress(DefaultHub)
end
SendToOps(sBot,curUser.sName.." Was redirected to "..frmHub:GetRedirectAddress())
SendToNick(curUser.sName, "<" ..sBot .."> Redirecting... |$ForceMove "..frmHub:GetRedirectAddress().."|")
end
function DataArrival(user, data)
local data=strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if cmd=="+rdon" then
SendToOps(sBot," Redirects enabled ")
StartTimer()
RedirectsEnabled = "true"
elseif cmd=="+rdoff" then
SendToOps(sBot," redirects disabled ")
StopTimer()
RedirectsEnabled = "false"
end
end
function OnTimer()
Timers()
end
function Timers()
if timer1 == Pingmins then
if curentport >= hubcount + 2 then
curenthub = 1
curentport = 2
end
displayhub(curenthub,curentport)
curenthub = curenthub + 2
curentport = curenthub + 1
CurrentOnlineHubs()
timer1 = 0
end
if timer2 == RedirectTime then
frmHub:SetRedirectAddress(Onlinehubs[HubCounter])
if (getn(Onlinehubs) == 0) then
frmHub:SetRedirectAddress(DefaultHub)
end
if HubCounter >= getn(Onlinehubs) then
HubCounter = 1
else
HubCounter = HubCounter + 1
end
timer2 = 0
end
timer1 = timer1 + 1
timer2 = timer2 + 1
end
function displayhub(curenthub,curentport)
local a = connect(Hub_Adress[curenthub],Hub_Adress[curentport])
CurrentChecking = Hub_Adress[curenthub]..":"..Hub_Adress[curentport]
Active = "false"
ActiveHubCount = getn(Onlinehubs) + 1
for index, value in Onlinehubs do
if Onlinehubs[index] == CurrentChecking then
Active = "true"
Position = index
end
end
if a == nil then
if Active == "false" then
SendToOps(sBot,CurrentChecking.." Hub is still Offline")
elseif Active == "true" then
SendToOps(sBot,CurrentChecking.." Hub Has Gone Offline")
Onlinehubs[Position] = nil
end
else
if Active == "false" then
SendToOps(sBot,CurrentChecking.." Has Come Online")
Onlinehubs[ActiveHubCount] = CurrentChecking
elseif Active == "true" then
SendToOps(sBot,CurrentChecking.." Hub is still online")
end
a:close()
end
end
function CurrentOnlineHubs()
local names = "\r\n\r\n-------------Curent Online Hubs----------------\r\n\r\n\t"
for index, value in Onlinehubs do
local line = index
names = names.." "..Onlinehubs[line].."\r\n\t"
end
names = names.."\r\n\r\nCurently Redirecting to "..frmHub:GetRedirectAddress().."\r\n\r\n"
SendToOps(sBot,names)
end
--===================== End Of Script ========================
if anyone has some time over to convert this script i would be greatfull