Daddy?s Switching redirect address setter v1.0 lua 5.1
-------------------------------------------------------------------------------------------------------------
These lua works in principe the same as the Dynamic Redirect which is built in RoboCop.
-------------------------------------------------------------------------------------------------------------
But with the following differences:
1: For he set the redirect in Ptokax de lua will pings first the hubs and is watching if these are online.
2: You can set your interval between de pings of de hubs in the list (table).
3: If all the hubs in the table are offline he will set de redirect in Ptokax to a Default hub. Witch you have also put in the script.
For example: Is only one hub online the redict goes there if none then the Default hub.
4: Now he starts to ping the hubs whit a interval (also settable in the lua) to look of one of them is coming online.
5: If one is coming back online he will set the redirect back to this hub.
6: Ops getting status note in pm
I hope you can use this script. Greetings
Greetings [NL]Daddy-Bear?
dchub://good-evening-hub.no-ip.org:411 (http://dchub://good-evening-hub.no-ip.org:411)
-- >>>>>>>>>>>>>>>> NOTE from [NL]Daddy-Bear? For this one, I used a script see below <<<<<<<<<<<<<<<
-- ====================== Network hub pinger redirect Manager 2.1 ===============================
-- ============= Credits 1ste By ¨?s??t°?s???Hawk????s°??t?s¨ 25-05-04 ===================
-- ============= applied to the new PXWSA by bastya_elvtars ===================
-- ==================== Get PXWSA lib at http://thewildplace.dk/lua/wsa ================
-- ============= Create a folder named libs inside your scripts folder and put pxwsa_l51.dll into there =============
-- ==================== +rdon = enable / +rdoff = disable =========================================
-- NEW
-- ******************************************************************************
-- ================= Switching redirect address setter v1.0 lua 5.1 ====================
-- ******************************************************************************
-- _________________________________________________________________________________________________________
-- The Switching redirect address setter for Ptokax by [NL]Daddy-Bear? (good-evening-hub.no-ip.org:411) 22-11-2006
-- _________________________________________________________________________________________________________
-- ===================== Editable settings ================================
Bot = frmHub:GetHubBotName() --// Bot name
oflinePingmin = 2 --// Ping tyd between the hubs in minutes which are ofline
OnlinePingmin = 15 --// Ping tyd between the hubs in minutes which are online
DefaultHub = "Bla Bla no-ip.info:2006" --// Third and laaste hub if the others go ofline ! Address:Port
-- ===================== HUBS ESTABLISH OF THE REDICT ================================
-- >>>>>>>>>>>>>>>>>>>>>>>..... HUB 1 .....<<<<<<<<<<<<<<<<<<<<<
hub1 = "Bla Bla.no-ip.info" --// Address of the first hub where redicts go.
port1 = 411 --// Port of the first hub where redicts go.
-- >>>>>>>>>>>>>>>>>>>>>>>..... HUB 2 .....<<<<<<<<<<<<<<<<<<<<<
hub2 = "Bla Bla.no-ip.biz" --// Address of the second hub where redicts go.
port2 = 2255 --// Port of the second hub where redicts go.
-- ================= Change nothing below !!!!!! ===================
RedirectsEnabled = true --// Do not change
ba = 0 --// Do not change
br = 0 --// Do not change
bx = 0 --// Do not change
mins = 1 --// Do not change
Hub_Adress = {
{hub1,port1},
{hub2,port2},
}
status=0
libinit = package.loadlib(frmHub:GetPtokaXLocation().."/scripts/libs/pxwsa_l51.dll", "_libinit")
assert(libinit,"Cannot load the WSA library!")
libinit()
_M=0
_A=false
Onlinehubs = {}
HubCounter = 1
cnt = 1
function Main()
WSA.Init()
SetTimer(1000 * 60 * mins)
if RedirectsEnabled == true then
StartTimer()
end
end
function ChatArrival(user, data)
if user.bOperator then
local data=string.sub(data,1,string.len(data)-1)
local _,_,cmd = string.find(data,"%b<>%s+(%S+)")
if cmd=="+rdon" then
SendPmToOps(frmHub:GetHubBotName()," Redirects enabled ")
StartTimer()
RedirectsEnabled = true
return 1
elseif cmd=="+rdoff" then
SendPmToOps(frmHub:GetHubBotName()," redirects disabled ")
StopTimer()
RedirectsEnabled = false
return 1
end
end
end
function OnTimer()
if _A then ConnectToHost(Hub_Adress[cnt][1],Hub_Adress[cnt][2]) end
_M=_M+1
if _M== 1 * mins then
_M=0
if cnt > table.maxn(Hub_Adress) then
cnt=1
end
displayhub()
end
end
function ConnectToHost(addy,port)
local status
local err1,err2=WSA.Connect(sock,addy,port)
if err1 then
if err1~=10035 and err1~=10056 then
_A=false
status=1; WSA.Close(sock)
elseif err1==10056 then
_A=false
status=2; WSA.Close(sock)
elseif err1==10035 then
_A=true
return
end
else
_A=false
status=2; WSA.Close(sock)
end
Populate(status)
end
function Populate(status)
if status == 1 then
if Active == false then
elseif Active == true then
Onlinehubs[Position] = nil
end
elseif status==2 then
if Active == false then
Onlinehubs[ActiveHubCount] = CurrentChecking
elseif Active == true then
end
end
cnt = cnt + 1
if (table.maxn(Onlinehubs) == 0) then
if bx == 0 then mins = 1
end
bx = bx + 1
br = 1
ba = 0
else
br = 0
bx = 0
mins = 1
frmHub:SetRedirectAddress(Onlinehubs[HubCounter])
end
if HubCounter >= table.maxn(Onlinehubs) then
HubCounter = 1
else
HubCounter = HubCounter + 1
end
if ba < 2 and br == 0 then ba = ba + 1
end
if ba == 1 then
names = "\tThe Switching redirect address setter is now started and he is pinging the hubs during 1 minute."
SendPmToOps(Bot,names)
end
if ba > 1 and br == 0 then mins = OnlinePingmin
names = "\tThese "..mins.." minutes the redicts are going to\t"..frmHub:GetRedirectAddress().."\tbecause this hub is *online*."
SendPmToOps(Bot,names)
end
if br == 1 and bx > 1 then bx = 6
mins = oflinePingmin
names = "\tThe redicts are going to\t"..frmHub:GetRedirectAddress().."\tbecause the other hubs are *ofline*.\r\n\t\t\t\tTher will be a check each "..mins.." minutes to see if the are comming *online*."
SendPmToOps(Bot,names)
end
CurrentOnlineHubs()
end
function displayhub()
_,_,sock=WSA.NewSocket()
CurrentChecking = Hub_Adress[cnt][1]..":"..Hub_Adress[cnt][2]
Active = false
ActiveHubCount = table.maxn(Onlinehubs) + 1
for index, value in ipairs(Onlinehubs) do
if value == CurrentChecking then
Active = true
Position = index
break
end
end
ConnectToHost(Hub_Adress[cnt][1],Hub_Adress[cnt][2])
end
function CurrentOnlineHubs()
-- Here you can put a command eg. hub ..... is online
end
function OnExit() WSA.Dispose(); end
I hope you can use this script.
Greetings [NL]Daddy-Bear?
dchub://good-evening-hub.no-ip.org:411 (http://dchub://good-evening-hub.no-ip.org:411)