PtokaX forum

Archive => Archived 5.1 boards => Finished Scripts => Topic started by: Daywalker? on 22 September, 2006, 19:43:44

Title: redirect-array with some more options
Post by: Daywalker? on 22 September, 2006, 19:43:44
--[[

Redirect Array by nErBoS

LUA 5.0/5.1 version by jiten

CHANGELOG:

- Corrected by NightLitch
- Added: Endless amount of hubs by plop
- Changed: For setting user levels to be redirected by bastya_elvtars (nice crew in here)
- Changed: CheckUserLevel originally by Nathanos
- Changed: CheckUserLevel eliminated by plop

*********** Daywalker *********************************************************************************
- Added commands for help, show, add and delete
- Added table for adding arrays
- Added RC Commands for easy use and lazy op's and send some to ops cause main is quite full^^
- Corrected and mixed 2 scripts by Daywalker with help from CrazyGuy (made a <= for equal to handle 0 share)

!! helpfile !!

NOTE: make a textfile called Array.dat in the script folder for table :)
  known Commands are !addred !delred !showred and !redhelp
 
  make sure that you add share,domain and name prolly in RC commands !!
 
  !! Respectfully !!
  !!tnx to Dutchman CrazyGuy Mutor and everyone i forgot for the big help :)!!
********************************************************************************************************
]]--

-- Which profile do you want to give a redirect  1=yes 0=no ---------------------------

ArrayProfiles = {
[0] = 0, -- Master
[1] = 0, -- Operator
[2] = 0, -- VIP
[3] = 0, -- Registered
[-1] = 1, -- Unregistered
}

-- Your command prefixes here
CmdPrefix = { ["!"] = 1, ["?"] = 1, ["+"] = 1}

tCommands = {}
tFunctions = {}
tHubs = {}
file = "Array.dat"
MaxArray = 1000

--//Settings-----------------------------------------------------------------------------
--Bot = frmHub:GetHubBotName()
Bot = "Array"
UserComMenu = "Redirect-Array"

--//Do not change anything below if so then it's on your own risk ^^---------------------
Main = function()
frmHub:RegBot(Bot)
if loadfile(file) then
dofile(file)
else
SaveToFile(file, tHubs, "tHubs")
end
end

ChatArrival = function(user, data)
user.SendMessage = user.SendData return tFunctions.GetCommands(user, data)
end

function OnExit()
saveTableToFile(file, tHubs, "tHubs")
end

ToArrival = function(user, data)
local s,e,to = string.find(data, "$To: (%S+%s?%S*)%sFrom:")
if to == Bot then
user.SendMessage = user.SendPM return tFunctions.GetCommands(user, data)
end
end

NewUserConnected = function(user)
tFunctions.SendCommands(user)
end

OpConnected = NewUserConnected

MyINFOArrival = function(user, data)
if ArrayProfiles[user.iProfile] and ArrayProfiles[user.iProfile] == 1 then
local iShareSize = (user.iShareSize/(1024^3)) or 0
for c,d in pairs(tHubs) do
if iShareSize >= tonumber(d[1]) then
SendToAll(Bot, "Redirected:\r\n Nick: "..user.sName..
"\r\n Total hubs: "..user.iHubs.." == Total Slots: "..user.iSlots.." == User Tag: "..user.sTag..
"\r\n IP: "..user.sIP.."\r\n sharesize: "..user.iShareSize..
"\r\n To: "..d[2].." \r\n Name: "..d[3]..
"\r\n Hub Maxshare: "..d[1].." Gib")
user:Redirect(d[2], d[3])
break
end
end
end
end

--//Commands-----------------------------------------------------------------------------
tCommands["redhelp"] = function(user, data)
if user.bOperator then
user:SendPM(Bot, "\n\n                      ******Redirect Help******\n\n*** !addred <hubminshare> <hubadress> <hubname> \n\n*** !delred [index] - delete an array by indexnumber\n\n*** !showred - shows which hubs are added to arraytable")
end return 1
end

tCommands["showred"] = function(user, data)
startpos = 1
endpos = table.getn(tHubs)
user:SendMessage("The Array contains "..endpos.." hub(s)")
data = ""
for a,b in pairs(tHubs) do
data = data .."\n\n*****Hub "..startpos.."***** - indexnr: "..a.."\n Name: "..b[3].."\n Minimum Share: "..b[1].." GB\n Adress: "..b[2]
startpos = startpos + 1
end
user:SendPM(Bot, data)
end

tCommands["addred"] = function(user, data)
if user.bOperator then
local s,_,iShare,sDomain,sName = string.find(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)%s+(.+)")
if iShare and sDomain and sName then
local tab = { iShare, sDomain, sName}
        for i,v in ipairs(tHubs) do
if v[2] == sDomain or v[3] == sName then
        return SendPmToOps(Bot, user.sName.." attempted to add a redirect "..
"that already exists. Let's all laugh at that fool."),1
end
end
if table.maxn(tHubs) < MaxArray then
table.insert(tHubs,tab)
saveTableToFile(file, tHubs, "tHubs")
SendPmToOps(Bot, user.sName.. "  Added A New Array To DataBase ** "..
iShare.." - "..sDomain.." - "..sName.."")
end
else
        return user:SendPM(Bot, "*** Error! Usage: "..CmdPrefix[prefix].."addred "..
"<hubminshare> <hubadress> <hubname>"),1
end
return 1
end

end

tCommands["delred"] = function(user, data)
if user.bOperator then
local s,_,nr = string.find(data, "%b<>%s+%S+%s+(%d+)")
if s and _ then
if tHubs[tonumber(nr)] then
table.remove(tHubs,nr)
SendPmToOps(Bot, user.sName.. " deleted Array nr."..nr.." from the Arraylist! **")
else
user:SendPM(Bot, "*** Array nr."..nr.." is not in Arraylist! use !showred to get Arraylist")
end
else
user:SendPM(Bot, "*** Error! Usage: !delred <index> to delete an Array from list ")
end
end return 1
end

--//Functions-----------------------------------------------------------------------------
tFunctions.GetCommands = function(user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,prefix,cmd=string.find(data, "%b<>%s*(%S)(%S+)")
if prefix and CmdPrefix[prefix] and tCommands[cmd] then return tCommands[cmd](user, data) end
end

tFunctions.SendCommands = function(user)
if user.bUserCommand then
user:SendData("$UserCommand 0 3")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\Help$<%[mynick]> !redhelp&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\Add new Array$<%[mynick]> !addred %[line:HubMinShare] %[line:HubAdress] %[line:HubName] &#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\Delete an Array$<%[mynick]> !delred %[line:Indexnr] &#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\Show Arraylist$<%[mynick]> !showred&#124;")
end
end

-----------------------------------------------------------------------
-- function Serialize(tTable, sTableName, sTab) handles table format --
-----------------------------------------------------------------------
Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in pairs(tTable) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Serialize(value, sKey, hFile, sTab.."\t")
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
hFile:write( sTab.."\t"..sKey.." = "..sValue)
end
hFile:write( ",\n")
end
hFile:write( sTab.."}")
end

saveTableToFile = function(file,table , tablename)
local hFile = io.open (file , "w")
Serialize(table, tablename, hFile)
hFile:flush()
hFile:close()
collectgarbage("collect")
end


hopefully now it's easier to use by more ppl then only the owner of tha hub  :)

--Just learning ^^
Title: Re: redirect-array with some more options
Post by: dannyger74 on 30 September, 2006, 15:01:06
is it so, that the users that are redirected go random to the hub in the array or do they go to the hub in wich they can enter if u look at the minshare?

What i mean: when i got a few hubs in it and they all have 10gb minshare and a user comes in, does he go to the same hub everytime or random to one of the hubs?
Title: Re: redirect-array with some more options
Post by: Spete on 30 November, 2006, 19:54:41
Hi, I have a little problem with this script and wonder if someone would have a solution..

The script works just fine except when I delete hubs from the array.. It keeps changing the order of the hubs in the Array.dat.. It should keep the hub with the highest minshare on first position, right?

But for example I add 3 hubs to the array (hub1 minshare 25GB, hub2 minshare 10GB, hub3 minshare 5GB), and delete hub2, it moves the hub3 above hub1 in the Array.dat, so now all users with over 25GB share are redirected to hub3 instead of hub1..

Would appreciate it if someone would have a solution to this, thanks :)
Title: Re: redirect-array with some more options
Post by: sphinx_spb on 11 November, 2007, 16:02:52
--[[

Redirect Array by nErBoS

LUA 5.0/5.1 version by jiten

Expanded to Ё˜??є?TriBlade?є??˜Ё by Daywalker?

CHANGELOG:
*********** Daywalker? ********************************************************************
-------------- v A.01 / v A.02 ---------------------------------
- Added Toggle maininfo on/of also in RC
- Changed from share to random redirect
- Added commands for help, show, add and delete
- Added table for adding arrays
- Added RC Commands for easy use and lazy op's and send some to ops cause main is quite full^^
- Added pxwsa_l51.dll from blue_bear for pinging online hubs in table
-------------- v A.03 ---------------------------------
- fixed some ugly things init so it looks more charmed :))
- Removed some unused code
-------------- v A.04 ---------------------------------
- Removed some more useless stuff in script
- added multiple timerfunctions
- updated RC commands
- added webtemplate for webserver (create a folder in PX Root called html)
- added code for writing status to html (tnx to Mutor) :)
- changed table set up for writing to only one table
- added online, offline and immune(for ping problems at some routers)
- offline hubs gets temp taken out of redi till next ping
- and more stuff done that i don't remember right now ^^
- added seperated add for zero share hub or as they well say...garbage^^
-------------- v A.05 ----------------------------------
- Some bugs fixed by Madman :D

NOTE: put the pxwsa_l51.dll, cc3270.dll and the pxwsa_l51.tds in the Ptokax root folder

  known Commands are: see !redhelp for available commands ^^
 
  !!tnx to Dutchman CrazyGuy Mutor Madman Hungarista and everyone i forgot for the big help :)!!
********************************************************************************************************
- Corrected by NightLitch
- Added: Endless amount of hubs by plop
- Changed: For setting user levels to be redirected by bastya_elvtars (nice crew in here)
- Changed: CheckUserLevel originally by Nathanos
- Changed: CheckUserLevel eliminated by plop

]]--

-- Settings ---------------------------------------------------
Bot = "Ё˜??є?TriBlade?є??˜Ё"
UserComMenu = "Ё˜??є?>> ? Redirect-Array"
webservaddy = "http://triblade.redirectme.net:9541"
ShowMainInfo = "on"
PingHubs = "on"
webstat = "on"
UseDumpHub = "on"
webservaddy = "http://triblade.redirectme.net:9541"
--PingTime = 30*Min -- possible options are: Min = 60*Sec, Hour = 60*Min, Day = 24*Hour

-- Which profile do you want to give a redirect  1=yes 0=no --

ArrayProfiles = {
[0] = 0, -- Master
[1] = 0, -- Operator
[2] = 0, -- VIP
[3] = 0, -- Registered
[-1] = 1, -- Unregistered
}

MasterProfiles = {
[0] = 1, -- Master
[1] = 0, -- Operator
[2] = 0, -- VIP
[3] = 0, -- Registered
[-1] = 0, -- Unregistered
}
----------------------------- changing things below this line on own risk^^---------------
-- Your command prefixes here
CmdPrefix = { ["!"] = 1, ["?"] = 1, ["+"] = 1}
tCommands = {}
tFunctions = {}
tHubs = { ["Online"] = {}, ["Offline"] = {}, ["Immune"] = {}, ["ZeroShare"] = {}, ["Offlinez"] = {} }
arrayfile = "Triblade/Array.dat"
html = "../html/webstats/redirect.html"
MaxArray = 1000
number = 0
sCript = "Ё˜??є?TriBlade?є??˜Ё"
sVersion = " v A.05 Beta"

curSocket = nil
bConnected = false
TableRebuild = "on"

Sec = 1000
Min = 60*Sec
Hour = 60*Min
Day = 24*Hour
TmrFreq = 1*Sec
tabTimers = {n=0}
----------------------pxwsa for creating sockets ------------------------------------------
libinit = package.loadlib("pxwsa_l51.dll", "_libinit")
libinit()
------------------------------------- main commands -----------------------------------------
Main = function()
RegTimer(TimerCon,30*Min) -- set pingtime here
SetTimer(TmrFreq) StartTimer()

frmHub:RegBot(Bot, 1, "Array Bot made by Daywalker?", "TriBlade@Ptokax.net")
if loadfile(arrayfile) then dofile(arrayfile) else saveTableToFile(arrayfile, tHubs, "tHubs") end
-- if loadfile(html) then dofile(html) end
local res,err = loadfile(html)
if err then SendPmToOps(frmHub:GetOpChatName(), err) else dofile(html) end
SendToAll(Bot,"\r\n\r\n\t\t\t\t...Hub Array script "..sCript..sVersion.." started on " ..os.date("%B %d, %Y at %X").. "\n")--%Y-%m-%d
end

ChatArrival = function(user, data)
user.SendMessage = user.SendData return tFunctions.GetCommands(user, data)
end

OnExit = function()
saveTableToFile(arrayfile, tHubs, "tHubs")
SendToAll(Bot, "\r\n\r\n\t\t\t\t...Hub Array script "..sCript..sVersion.." disabled on " ..os.date("%B %d, %Y at %X").. "")
end

ToArrival = function(user, data)
local s,e,to = string.find(data, "$To: (%S+%s?%S*)%sFrom:")
if to == Bot then
user.SendMessage = user.SendPM return tFunctions.GetCommands(user, data)
end
end

NewUserConnected = function(user, data)
tFunctions.SendCommands(user)
OnIntro(user)
end

OpConnected = NewUserConnected

MyINFOArrival = function(user, data)
if ArrayProfiles[user.iProfile] and ArrayProfiles[user.iProfile] == 1 then
arrive = string.lower(user.sName)
local v,w,count = string.find(arrive, data)
if count == nil then
number = number +1
end 
shares = string.format( "%.2f",user.iShareSize/(1024*1024*1024))
lastcount = table.maxn(tHubs["Online"])
local iRD = math.random(1,lastcount)
lastcountz = table.maxn(tHubs["ZeroShare"])
if not lastcountz == 0 then
local iRDz = math.random(1,lastcountz)
end
host = tHubs["Online"][iRD][1]..":"..tHubs["Online"][iRD][2]
if not lastcountz == 0 then
zeroshare = tHubs["ZeroShare"][iRDz][1]..":"..tHubs["ZeroShare"][iRDz][2]
end
num = tHubs["Online"][iRD][4] +1
if not lastcountz == 0 then
numz = tHubs["ZeroShare"][iRDz][4] +1  
end
if user.iShareSize == 0 and UseDumpHub == "on" and (not lastcountz == 0) then
if tHubs["ZeroShare"][iRDz][4] then 
tHubs["ZeroShare"][iRDz][4] = numz
saveTableToFile(arrayfile, tHubs, "tHubs")
end
user:Redirect(zeroshare, tHubs["ZeroShare"][iRDz][3])
if ShowMainInfo == "on" then
SendToAll(Bot, "\n ["..number.."] \t redicount = "..tHubs["ZeroShare"][iRDz][4].." \tNick: "..user.sName.."\tTo: "..tHubs["ZeroShare"][iRDz][1]..":"..tHubs["ZeroShare"][iRDz][2].."\tIP: "..user.sIP.."\tUsershare: "..shares.." Gib\n")
end
else
if tHubs["Online"][iRD][4] then
tHubs["Online"][iRD][4] = num   
saveTableToFile(arrayfile, tHubs, "tHubs")
end
user:Redirect(host, tHubs["Online"][iRD][3])
if ShowMainInfo == "on" then
SendToAll(Bot, "\n ["..number.."] \t redicount = "..tHubs["Online"][iRD][4].." \tNick: "..user.sName.."\tTo: "..tHubs["Online"][iRD][1]..":"..tHubs["Online"][iRD][2].."\tIP: "..user.sIP.."\tUsershare: "..shares.." Gib\n")
end
end
end
end

--//Commands-----------------------------------------------------------------------------------------

tCommands = {
["redhelp"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
user:SendPM(Bot, "\n\n\t\t\t******Redirect Help******\n\n"..
"\t\t*** !redhelp - shows this text \n\n"..
"\t\t*** !doping - pings the hubs manual \n\n"..
"\t\t*** !addred <hubadress> <hubPort> <hubname> \n\n"..
"\t\t*** !addzero <hubadress> <hubPort> <hubname> \n\n"..
"\t\t*** !addimm <hubadress> <hubPort> <hubname> \n\n"..
"\t\t*** !delred [index] - delete an array by indexnumber\n\n"..
"\t\t*** !delzero [index] - delete an ZeroArray by indexnumber\n\n"..
"\t\t*** !delimm [index] - delete an Immune hub by indexnumber\n\n"..
"\t\t*** !deloff [index] - delete an Offline hub by indexnumber\n\n"..
"\t\t*** !showred - shows which hubs are added to arraytable\n\n"..
"\t\t*** !showzero - shows which hubs are added to ZeroArray table\n\n"..
"\t\t*** !showimm - shows which hubs are added to Immune table\n\n"..
"\t\t*** !showoff - shows which hubs are added to Offline table\n\n"..
"\t\t*** !on - Toggles Mainchat in fo on\n\n"..
"\t\t*** !off - Toggles Mainchat info off\n\n"..
"\t\t*** !webon - Toggles Webstats on\n\n"..
"\t\t*** !weboff - Toggles Webstats off\n\n"..
"\t\t*** !pingon - Toggles Ping on\n\n"..
"\t\t*** !pingoff - Toggles Ping off\n\n"..
"\t\t*** !rebuild - rebuilds the Online list when a hub's back online\n\n")
end
return 1
end,
["showred"] = function(user, data)
startpos = 1
endpos = table.getn(tHubs["Online"])
user:SendPM(Bot, "The Online list contains "..endpos.." hub(s)")
data = ""
for a,b in pairs(tHubs["Online"]) do
data = data .."\n\n*****Hub "..startpos.."***** - indexnr: "..a.."\n Name: "..b[3].."\n Adress: "..b[1].."\n Port: "..b[2].."\n Total Redirects: "..b[4]..""
startpos = startpos + 1
end
user:SendPM(Bot, data)
return 1
end,
["showoff"] = function(user, data)
startpos = 1
endpos = table.getn(tHubs["Offline"])
user:SendPM(Bot, "The Offline list contains "..endpos.." hub(s)")
data = ""
for a,b in pairs(tHubs["Offline"]) do
data = data .."\n\n*****Hub "..startpos.."***** - indexnr: "..a.."\n Name: "..b[3].."\n Adress: "..b[1].."\n Port: "..b[2]..""
startpos = startpos + 1
end
user:SendPM(Bot, data)
return 1
end,
["showzero"] = function(user, data)
startpos = 1
endpos = table.getn(tHubs["ZeroShare"])
user:SendPM(Bot, "The ZeroArray list contains "..endpos.." hub(s)")
data = ""
for a,b in pairs(tHubs["ZeroShare"]) do
data = data .."\n\n*****Hub "..startpos.."***** - indexnr: "..a.."\n Name: "..b[3].."\n Adress: "..b[1].."\n Port: "..b[2].."\n Total Redirects: "..b[4]..""
startpos = startpos + 1
end
user:SendPM(Bot, data)
return 1
end,
["showoffzero"] = function(user, data)
startpos = 1
endpos = table.getn(tHubs["Offlinez"])
user:SendPM(Bot, "The OfflineZero list contains "..endpos.." hub(s)")
data = ""
for a,b in pairs(tHubs["Offlinez"]) do
data = data .."\n\n*****Hub "..startpos.."***** - indexnr: "..a.."\n Name: "..b[3].."\n Adress: "..b[1].."\n Port: "..b[2]..""
startpos = startpos + 1
end
user:SendPM(Bot, data)
return 1
end,
["showimm"] = function(user, data)
startpos = 1
endpos = table.getn(tHubs["Immune"])
user:SendPM(Bot, "The Immune list contains "..endpos.." hub(s)")
data = ""
for a,b in pairs(tHubs["Immune"]) do
data = data .."\n\n*****Hub "..startpos.."***** - indexnr: "..a.."\n Name: "..b[3].."\n Adress: "..b[1].."\n Port: "..b[2]..""
startpos = startpos + 1
end
user:SendPM(Bot, data)
return 1
end,
["addred"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
local s,_,sDomain,iPort,sName = string.find(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)%s+(.+)")
if sDomain and iPort and sName then
if tHubs and tHubs["Online"] then
local bIsFound = 0 
for k = 1, table.getn(tHubs["Online"]) do 
if tHubs["Online"][k][1] == sDomain or tHubs["Online"][k][3] == sName then
bIsFound = 1
end
end
if bIsFound == 0 and tHubs["Offline"] then
for k = 1, table.getn(tHubs["Offline"]) do
if tHubs["Offline"][k][1] == sDomain or tHubs["Offline"][k][3] == sName then
bIsFound = 1
end
end
end
if bIsFound == 0 then
tHubs["Online"][table.getn(tHubs["Online"]) +1] = { sDomain, iPort, sName, "0"}--tab
saveTableToFile(arrayfile, tHubs, "tHubs")
SendToOps(Bot, user.sName.. "  Added A New Array To DataBase ** "..
sDomain..":"..iPort.." - "..sName.."\n")
LoadTableFromFile(arrayfile)
else
SendToOps(Bot, user.sName.." attempted to add a redirect "..
"that already exists. Let's all laugh at that fool.\n")
end
else
tHubs["Online"] = {}
tHubs["Online"][1] = { sDomain, iPort, sName, "0"}
saveTableToFile(arrayfile, tHubs, "tHubs")
SendToOps(Bot, user.sName.. "  Added A New Array To DataBase ** "..
sDomain..":"..iPort.." - "..sName.."\n")
LoadTableFromFile(arrayfile)
end
else
user:SendPM(Bot, "*** Error! Usage: "..CmdPrefix[prefix].."addred "..
"<hubadress> <hubport> <hubname>")
end
return 1
end
end,
["addzero"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
local s,_,sDomain,iPort,sName = string.find(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)%s+(.+)")
if sDomain and iPort and sName then
if tHubs and tHubs["ZeroShare"] then
local bIsFound = 0 
for k = 1, table.getn(tHubs["ZeroShare"]) do 
if tHubs["ZeroShare"][k][1] == sDomain or tHubs["ZeroShare"][k][3] == sName then
bIsFound = 1
end
end
if bIsFound == 0 and tHubs["Offlinez"] then
for k = 1, table.getn(tHubs["Offlinez"]) do
if tHubs["Offlinez"][k][1] == sDomain or tHubs["Offlinez"][k][3] == sName then
bIsFound = 1
end
end
end
if bIsFound == 0 then
tHubs["ZeroShare"][table.getn(tHubs["ZeroShare"]) +1] = { sDomain, iPort, sName, "0"}--tab
saveTableToFile(arrayfile, tHubs, "tHubs")
SendToOps(Bot, user.sName.. "  Added A New Array To DataBase ** "..
sDomain..":"..iPort.." - "..sName.."\n")
LoadTableFromFile(arrayfile)
else
SendToOps(Bot, user.sName.." attempted to add a redirect "..
"that already exists. Let's all laugh at that fool.\n")
end
else
tHubs["ZeroShare"] = {}
tHubs["ZeroShare"][1] = { sDomain, iPort, sName, "0"}
saveTableToFile(arrayfile, tHubs, "tHubs")
SendToOps(Bot, user.sName.. "  Added A New Array To DataBase ** "..
sDomain..":"..iPort.." - "..sName.."\n")
LoadTableFromFile(arrayfile)
end
else
user:SendPM(Bot, "*** Error! Usage: "..CmdPrefix[prefix].."addzero "..
"<hubadress> <hubport> <hubname>")
end
return 1
end
end,
["addimm"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
local s,_,sDomain,iPort,sName = string.find(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)%s+(.+)")
if sDomain and iPort and sName then
if tHubs and tHubs["Immune"] then 
local bIsFound = 0
for k = 1, table.getn(tHubs["Immune"]) do 
if tHubs["Immune"][k][1] == sDomain or tHubs["Immune"][k][3] == sName then
bIsFound = 1
end
end
if bIsFound == 0 then
tHubs["Immune"][table.getn(tHubs["Immune"]) +1] = { sDomain, iPort, sName,""}--tab
saveTableToFile(arrayfile, tHubs, "tHubs")
SendToOps(Bot, user.sName.. "  Added A New Array To The Immune DataBase ** "..
sDomain..":"..iPort.." - "..sName.."\n")
LoadTableFromFile(arrayfile)
else
SendToOps(Bot, user.sName.." attempted to add a Immune hub "..
"that already exists. Let's all laugh at that fool.\n")
end
else
tHubs["Immune"] = {}
tHubs["Immune"][1] = { sDomain, iPort, sName} 
saveTableToFile(arrayfile, tHubs, "tHubs")
SendToOps(Bot, user.sName.. "  Added A New Array To The Immune DataBase ** "..
sDomain..":"..iPort.." - "..sName.."\n")
LoadTableFromFile(arrayfile)
end
else
user:SendPM(Bot, "*** Error! Usage: "..CmdPrefix[prefix].."addimm "..
"<hubadress> <hubport> <hubname>")
end
return 1
end
end,
["delred"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
local s,_,nr = string.find(data, "%b<>%s+%S+%s+(%d+)")
if s and _ then
if tHubs["Online"][tonumber(nr)] then
table.remove(tHubs["Online"],nr)
SendToOps(Bot, user.sName.. " deleted Array nr."..nr.." from the Arraylist! **\n")
LoadTableFromFile(arrayfile)
else
user:SendPM(Bot, "*** Array nr."..nr.." is not in Arraylist! use !showred to get Arraylist")
end
else
user:SendPM(Bot, "*** Error! Usage: !delred <index> to delete an Array from list ")
end
end return 1
end,
["delzero"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
local s,_,nr = string.find(data, "%b<>%s+%S+%s+(%d+)")
if s and _ then
if tHubs["ZeroShare"][tonumber(nr)] then
table.remove(tHubs["ZeroShare"],nr)
SendToOps(Bot, user.sName.. " deleted ZeroArray nr."..nr.." from the ZeroArraylist! **\n")
LoadTableFromFile(arrayfile)
else
user:SendPM(Bot, "*** ZeroArray nr."..nr.." is not in ZeroArraylist! use !showzero to get ZeroArraylist")
end
else
user:SendPM(Bot, "*** Error! Usage: !delzero <index> to delete an Array from list ")
end
end return 1
end,
["deloffzero"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
local s,_,nr = string.find(data, "%b<>%s+%S+%s+(%d+)")
if s and _ then
if tHubs["Offline"][tonumber(nr)] then
table.remove(tHubs["Offlinez"],nr)
SendToOps(Bot, user.sName.. " deleted OfflineZero hub nr."..nr.." from the OfflineZero list! **\n")
LoadTableFromFile(arrayfile)
else
user:SendPM(Bot, "*** OfflineZero hub nr."..nr.." is not in OfflineZero list! use !showoffzero to get OfflineZero list")
end
else
user:SendPM(Bot, "*** Error! Usage: !deloffzero <index> to delete an OfflineZero hub from list ")
end
end return 1
end,
["delimm"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
local s,_,nr = string.find(data, "%b<>%s+%S+%s+(%d+)")
if s and _ then
if tHubs["Immune"][tonumber(nr)] then
table.remove(tHubs["Immune"],nr)
SendToOps(Bot, user.sName.. " deleted Immune hub nr."..nr.." from the Immune list! **\n")
LoadTableFromFile(arrayfile)
else
user:SendPM(Bot, "*** Immune hub nr."..nr.." is not in Immune list! use !showimm to get Immune list")
end
else
user:SendPM(Bot, "*** Error! Usage: !delimm <index> to delete an Immune hub from list ")
end
end return 1
end,
["deloff"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
local s,_,nr = string.find(data, "%b<>%s+%S+%s+(%d+)")
if s and _ then
if tHubs["Offline"][tonumber(nr)] then
table.remove(tHubs["Offline"],nr)
SendToOps(Bot, user.sName.. " deleted Offline hub nr."..nr.." from the Offline list! **\n")
LoadTableFromFile(arrayfile)
else
user:SendPM(Bot, "*** Offline hub nr."..nr.." is not in Offline list! use !showoff to get Offline list")
end
else
user:SendPM(Bot, "*** Error! Usage: !deloff <index> to delete an Offline hub from list ")
end
end return 1
end,
["on"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
ShowMainInfo = "on"
SendToAll(Bot, "*** MainChatInfo Enabled...\n")
end return 1
end,
["off"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
SendToOps(Bot, "*** MainChatInfo Disabled...\n")
ShowMainInfo = "off"
end return 1
end,
["doping"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
SendToOps(Bot, "*** "..user.sName.. " Started a manual ping for checking online hubs...\n")
SendToOps(Bot, "\t\tЁ˜??є? Checking online hubs ?є??˜Ё\n")
DoConnect()
SendToOps(Bot, "\t\tЁ˜??є? Hubs are Pinged succesfully ?є??˜Ё\n")
if webstat == "on" then
SaveHtml(html) -- save to html for status
end
end return 1
end,
["pingon"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
PingHubs = "on"
SendToAll(Bot, "*** HubPing Enabled\n")
end return 1
end,
["pingoff"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
SendToOps(Bot, "*** HubPing Disabled\n")
PingHubs = "off"
end return 1
end,
["webon"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
webstat = "on"
SendToAll(Bot, "*** WebStats Enabled...\n")
end return 1
end,
["weboff"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
SendToOps(Bot, "*** WebStats Disabled...\n")
webstat = "off"
end return 1
end,
["rebuild"] = function(user, data)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
if PingHubs == "on" then
TableRebuild()
end
end return 1
end
}
--//Functions-----------------------------------------------------------------------------

-- Creating a Socket for the ping-----------------
--------------------------------------------------
DoConnect = function()
if PingHubs == "on" then
TableRebuild() -- insert the offline hubs back to the online table for ping
-- Now we start using the table content the hubs added
for k = 1, table.getn(tHubs["ZeroShare"]) do
-- Now we create a socket
ErConnect, ConnectStr, curSocket = WSA.NewSocket(0)
if ErConnect then -- fail in creating socket
SendToOps(Bot, "*** Error: Please check your connecting settings for errors or blocking")
end
-- Now we start connecting to those hubs
ErConnect, ConnectStr = WSA.Connect(curSocket, tHubs["ZeroShare"][k][1], tHubs["ZeroShare"][k][2])
if ErConnect then -- connection failed
answerzerob = "*** [OFFLINE] ==>> "..tHubs["ZeroShare"][k][3].." Hubadres: "..tHubs["ZeroShare"][k][1].." with port: "..tHubs["ZeroShare"][k][2].." <<== [TEMPREMOVED]\n"
SendToOps(Bot, answerzerob)
if tHubs["ZeroShare"] then
tHubs["Offlinez"][table.getn(tHubs["Offlinez"]) +1] = { tHubs["ZeroShare"][k][1], tHubs["ZeroShare"][k][2], tHubs["ZeroShare"][k][3], tHubs["ZeroShare"][k][4] }
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
table.remove(tHubs["ZeroShare"],k) -- delete the offline hub from online table and sorts the online table // fix tnx to Hungarista
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
else
tHubs["Offlinez"] = {}
-- add the hub to the offline table
tHubs["Offlinez"][1] = { tHubs["ZeroShare"][k][1], tHubs["ZeroShare"][k][2], tHubs["ZeroShare"][k][3], tHubs["ZeroShare"][k][4] }
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
end
bConnected = false
WSA.Close(curSocket) -- close the bloody socket
else -- connection established
answerzero = "*** Online: "..tHubs["ZeroShare"][k][3].." Hubadres: "..tHubs["ZeroShare"][k][1].." with port: "..tHubs["ZeroShare"][k][2]..".....\n"
SendToOps(Bot, answerzero)    
bConnected = true
end
WSA.Close(curSocket) -- close the socket for this session
  end
for k = 1, table.getn(tHubs["Online"]) do
-- Now we create a socket
ErConnect, ConnectStr, curSocket = WSA.NewSocket(0)
if ErConnect then -- fail in creating socket
SendToOps(Bot, "*** Error: Please check your connecting settings for errors or blocking")
end
-- Now we start connecting to those hubs
ErConnect, ConnectStr = WSA.Connect(curSocket, tHubs["Online"][k][1], tHubs["Online"][k][2])
if ErConnect then -- connection failed
answerb = "*** [OFFLINE] ==>> "..tHubs["Online"][k][3].." Hubadres: "..tHubs["Online"][k][1].." with port: "..tHubs["Online"][k][2].." <<== [TEMPREMOVED]\n"
SendToOps(Bot, answerb)
if tHubs["Online"] then
tHubs["Offline"][table.getn(tHubs["Offline"]) +1] = { tHubs["Online"][k][1], tHubs["Online"][k][2], tHubs["Online"][k][3], tHubs["Online"][k][4] }
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
table.remove(tHubs["Online"],k) -- delete the offline hub from online table and sorts the online table // fix tnx to Hungarista
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
else
tHubs["Offline"] = {}
-- add the hub to the offline table
tHubs["Offline"][1] = { tHubs["Online"][k][1], tHubs["Online"][k][2], tHubs["Online"][k][3], tHubs["Online"][k][4] }
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
end
if tHubs["Immune"] == nil then
tHubs["Immune"] = {}
else
for k = 1, table.getn(tHubs["Immune"]) do -- place the immune hubs back into the online table
if tHubs["Immune"] then
tHubs["Online"][table.getn(tHubs["Online"]) +1] = { tHubs["Immune"][k][1], tHubs["Immune"][k][2], tHubs["Immune"][k][3], tHubs["Immune"][k][4] }
saveTableToFile(arrayfile, tHubs, "tHubs")
SendToOps(Bot, "*** Immune hub "..tHubs["Immune"][k][3].." is added back to online list...\n")
table.remove(tHubs["Offline"],k)
LoadTableFromFile(arrayfile)
-- SendToOps(Bot, "*** Immune hub "..tHubs["Immune"][k][3].." is added back to online list...")
else
-- tHubs["Immune"] = {}
-- tHubs["Online"][1] = { tHubs["Immune"][k][1], tHubs["Immune"][k][2], tHubs["Immune"][k][3], tHubs["Immune"][k][4] }
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
-- SendToOps(Bot, "*** All Immune hubs are added back to online list...")
end
end
end
if tHubs["ZeroShare"] == nil then
tHubs["ZeroShare"] = {}
else
for k = 1, table.getn(tHubs["Offlinez"]) do -- place the ZeroShare hubs back into the online table
if tHubs["Offlinez"] then
tHubs["ZeroShare"][table.getn(tHubs["ZeroShare"]) +1] = { tHubs["Offlinez"][k][1], tHubs["Offlinez"][k][2], tHubs["Offlinez"][k][3], tHubs["Offlinez"][k][4] }
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
SendToOps(Bot, "*** All Offlinezero hubs are added back to ZeroShare list...\n")
else
tHubs["ZeroShare"] = {}
tHubs["ZeroShare"][1] = { tHubs["Offlinez"][k][1], tHubs["Offlinez"][k][2], tHubs["Offlinez"][k][3], tHubs["Offlinez"][k][4] }
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
-- SendToOps(Bot, "*** All Offlinezero hubs are added back to ZeroShare list...")
end
end
end
bConnected = false
WSA.Close(curSocket) -- close the bloody socket
else -- connection established
    answerg = "*** Online: "..tHubs["Online"][k][3].." Hubadres: "..tHubs["Online"][k][1].." with port: "..tHubs["Online"][k][2]..".....\n"
SendToOps(Bot, answerg)    
bConnected = true
end
WSA.Close(curSocket) -- close the socket for this session
  end
else
SendToOps(Bot, "*** HubPing is disabled... skipped hub check...")
end
end
---------------------------------Mutor's html code -----------------------
function SaveHtml(File)
SendToOps(Bot, "*** Publishing Stats To "..webservaddy.."\n")
local f,e = io.open(File, "w" )
local html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n'..
'<html>\n<head>\n'..
'<TITLE>Redirect Status</TITLE>\n'..
'<meta http-equiv=Page-Enter content="blendTrans(Duration=1)">\n'..
'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\n'..
'<META NAME=ROBOTS CONTENT="NOINDEX,NOFOLLOW">\n'..
'<META http-equiv=Pragma content=no-cache>\n'..
'<LINK REL="SHORTCUT ICON" HREF="favicon.ico">\n'..
'</head>\n<body><center>'..
'<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>'..
'<td align="left" valign="middle"><font size="4">'
for a,b in pairs(tHubs["Online"]) do
html = html.. '&#8226;&nbsp;&nbsp;Online ==>> Hubaddress: '..
b[1]..' with port: '..b[2]..' redicount = '..b[4]..'<br>'
end
for i,v in pairs(tHubs["Offline"]) do
html = html.. '&#8226;&nbsp;&nbsp;Offline ==>> Hubaddress: '..
v[1]..' with port: '..v[2]..'<br>'
end
for i,v in pairs(tHubs["Offlinez"]) do
html = html.. '&#8226;&nbsp;&nbsp;Offline ==>> Hubaddress: '..
v[1]..' with port: '..v[2]..'<br>'
end
html = html..'</font></td></tr></table></center></body></html>'
f:write(html)
f:flush()
f:close()
end

---------------------------Mutor's html code end ---------------------------------------
TableRebuild = function()
if PingHubs == "on" then
SendToOps(Bot, "*** Rebuilding Arraylist...\n")
for k = 1, table.getn(tHubs["Offline"]) do
if tHubs["Offline"] then
SendToOps(Bot, "*** Added hub => "..tHubs["Offline"][k][3].." <= back in online list for PingCheck\n")
tHubs["Online"][table.getn(tHubs["Online"])+1] = { tHubs["Offline"][k][1], tHubs["Offline"][k][2], tHubs["Offline"][k][3], tHubs["Offline"][k][4] }
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
table.remove(tHubs["Offline"],k)
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
else
tHubs["Online"] = {}
tHubs["Online"][1] = { tHubs["Offline"][k][1], tHubs["Offline"][k][2], tHubs["Offline"][k][3], tHubs["Online"][k][4] }
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
SendToOps(Bot, "*** All Clear...")
end
if tHubs["Offlinez"] then
SendToOps(Bot, "*** Added ZeroShareHub => "..tHubs["Offlinez"][k][3].." <= back in online list for PingCheck\n")
tHubs["ZeroShare"][table.getn(tHubs["ZeroShare"])+1] = { tHubs["Offlinez"][k][1], tHubs["Offlinez"][k][2], tHubs["Offlinez"][k][3], tHubs["Offlinez"][k][4] }
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
table.remove(tHubs["Offlinez"],k)
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
else
tHubs["ZeroShare"] = {}
tHubs["ZeroShare"][1] = { tHubs["Offlinez"][k][1], tHubs["Offlinez"][k][2], tHubs["Offlinez"][k][3], tHubs["Offlinez"][k][4] }
saveTableToFile(arrayfile, tHubs, "tHubs")
LoadTableFromFile(arrayfile)
-- SendToOps(Bot, "*** All Clear...")
end
end
SendToOps(Bot, "*** Rebuilding Arraylist Completed...\n")
end
end
-- set timer -------------------new
RegTimer = function(f, Interval)
local tmpTrig = Interval / TmrFreq
assert(Interval >= TmrFreq , "RegTimer(): Please Adjust TmrFreq")
local Timer = {n=0}
Timer.func=f
Timer.trig=tmpTrig
Timer.count=1
table.insert(tabTimers, Timer)
end

OnTimer = function()
for i in ipairs(tabTimers) do
tabTimers[i].count = tabTimers[i].count + 1
if tabTimers[i].count > tabTimers[i].trig then
tabTimers[i].count=1
tabTimers[i]:func()
end
end
end

TimerCon = function()
if PingHubs == "on" then
SendToOps(Bot, "\t\tЁ˜??є? Checking online hubs ?є??˜Ё\n")
DoConnect()
SendToOps(Bot, "\t\tЁ˜??є? Hubs are Pinged succesfully ?є??˜Ё\n")
if webstat == "on" then
SaveHtml(html) -- save to html for status
end
end
end

function TimerLagMess()
if PingHubs == "on" then
SendToOps(Bot, "\n\t\t\t\t\tЁ˜??є? Ping will start in a minute...?є??˜Ё\n\t\t\t\t\t...this will lag the hub a few seconds...\n")
end
end

--------------------------------new end
tFunctions.GetCommands = function(user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,prefix,cmd=string.find(data, "%b<>%s*(%S)(%S+)")
if prefix and CmdPrefix[prefix] and tCommands[cmd] then return tCommands[cmd](user, data) end
end

tFunctions.SendCommands = function(user)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
user:SendData("$UserCommand 0 3")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Misc\\?Help$<%[mynick]> !redhelp&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Ping\\?Do manual ping$<%[mynick]> !doping&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Ping\\?Enable HubPing$<%[mynick]> !pingon&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Ping\\?Disable HubPing$<%[mynick]> !pingoff&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Hubs\\?Add\\?Add new Hub$<%[mynick]> !addred %[line:HubAdress] %[line:HubPort] %[line:HubName] &#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Hubs\\?Add\\?Add ZeroShare Hub$<%[mynick]> !addzero %[line:HubAdress] %[line:HubPort] %[line:HubName] &#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Hubs\\?Add\\?Add Immune Hub$<%[mynick]> !addimm %[line:HubAdress] %[line:HubPort] %[line:HubName] &#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Hubs\\?Delete\\?Delete an Online hub$<%[mynick]> !delred %[line:Indexnr] &#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Hubs\\?Delete\\?Delete an ZeroShare hub$<%[mynick]> !delzero %[line:Indexnr] &#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Hubs\\?Delete\\?Delete an Immune hub$<%[mynick]> !delimm %[line:Indexnr] &#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Hubs\\?Delete\\?Delete an Offline hub$<%[mynick]> !deloff %[line:Indexnr] &#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Hubs\\?Delete\\?Delete an OfflineZero hub$<%[mynick]> !deloffzero %[line:Indexnr] &#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Hubs\\?Show\\?Show Online list$<%[mynick]> !showred&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Hubs\\?Show\\?Show ZeroShare list$<%[mynick]> !showzero&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Hubs\\?Show\\?Show Offline list$<%[mynick]> !showoff&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Hubs\\?Show\\?Show OfflineZero list$<%[mynick]> !showoffzero&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Hubs\\?Show\\?Show Immune list$<%[mynick]> !showimm&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Misc\\?Rebuild Arraylist$<%[mynick]> !rebuild&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Misc\\?Toggle main info on$<%[mynick]> !on&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Misc\\?Toggle main info off$<%[mynick]> !off&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Misc\\?Toggle WebStats on$<%[mynick]> !webon&#124;")
user:SendData("$UserCommand 1 3 "..UserComMenu.."\\?? Misc\\?Toggle WebStats off$<%[mynick]> !weboff&#124;")
end
end

function OnIntro(user)
if MasterProfiles[user.iProfile] and MasterProfiles[user.iProfile] == 1 then
user:SendData(Bot, "\n\n\t\tЁ˜??є? This Is Hub Array script "..sCript..sVersion.." made by Daywalker? ?є??˜Ё\n\n"..
"\t\t\t\t*** This is a full functional array script.. \n\n"..
"\t\t\t\t*** what can we expect from this tiny script... \n\n"..
"\t\t\t\t\t 1] Low mem usage.. \n\n"..
"\t\t\t\t\t 2] Fast redirecting.. \n\n"..
"\t\t\t\t\t 3] Inbuild webstats.. \n\n"..
"\t\t\t\t\t 4] Dumphub add possible..\n\n"..
"\t\t\t\t\t 5] Inbuild ping off hubs..\n\n"..
"\t\t\t\t\t 6] when hub is offline it becomes numb..\n\n"..
"\t\t\t\t\t 7] and will be re added at next ping..\n\n"..
"\t\t\t\t\t 8] and much more..\n\n"..
"\t\t\t\t\t 9] For availble Commands use the RC..\n\n"..
"\t\t\t\t\t10] or use !redhelp in mainchat..\n\n\n"..
"\t\t\t\tЁ˜??є? More info @ http://yourlink.eu/daywalker ?є??˜Ё\n"..
"\t\t\t\t           Ё˜??є? I hope you enjoy this script ?є??˜Ё\n\n")
end
end

function OnError(ErrorMsg)
SendToOps(Bot, "\r\n\t\t\t\t\t*** An Error Occured ***\r\n\r\n\t\t"..ErrorMsg.."\r\n\t\tError added to Error.log....\r\n");
local sFile = io.open("Triblade/Error.log", "a+")
sFile:write(os.date().." - "..ErrorMsg.."\n")
sFile:close() vError = ErrorMsg
end
-----------------------------------------------------------------------
-- function Serialize(tTable, sTableName, sTab) handles table format --
-----------------------------------------------------------------------
Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in pairs(tTable) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Serialize(value, sKey, hFile, sTab.."\t")
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
hFile:write( sTab.."\t"..sKey.." = "..sValue)
end
hFile:write( ",\n")
end
hFile:write( sTab.."}")
end

saveTableToFile = function(file,table , tablename)
local hFile = io.open (file , "w")
Serialize(table, tablename, hFile)
hFile:flush()
hFile:close()
collectgarbage("collect")
end

LoadTableFromFile = function(file)
local handle = io.open(file,"r")
if handle then
local sdata = ""
local line = ""
for line in handle:lines() do
sdata = sdata..line.."\r\n"
end
return sdata
else
sdata = "*** File / command not available!"
return sdata
end
handle:close()
end
Title: Re: redirect-array with some more options
Post by: Toast on 20 November, 2007, 19:18:04
Quote from: Daywalker? on 22 September, 2006, 19:43:44

hopefully now it's easier to use by more ppl then only the owner of tha hub  :)

--Just learning ^^

[19:16] Syntax ...and Settings\Toast\array\scripts\array.lua:143: attempt to concatenate field '?' (a nil value)

keep getting this error