Thx guys it works gr8 now , here we go again

is it possible first off
to have all hubs shown on the RC''s so that a user only has to right click , see the list of hubs and click the on they want instead of copy & paste ?
second
i know you have done this script exactly as i have asked
but it it also possible to use the RC''s to redirect self and also stay in the main hub running the redirect script ?
either way thx for all your hard work

While testing, I haven't found a working way to have a user stay in the current hub AND open a new hub window with the new hub from the redirect tables.
But, I have added that hub addresses will be send to UserCommands so they are simply clickable.
Everytime a hub is added or deleted from the table however, all UserCommands have to be resend to all users by the script.
It works, but it might cause quite some data flow in a big hub when the rd table is big as well
Anyways, here's the script
--[[
HubJumper
LUA 5.1.x
A redirect-self script
By CrazyGuy
On request by Då®k][Wîzå®d™
Last updated April 8th 2007
* Saves addresses to own file (04/22/07), Cêñoßy†ê
* Changed Permission table (05/04/07), Cêñoßy†ê
* Fixed file saving when restarting script (05/04/07), Cêñoßy†ê
]]--
sBotname = "Hub-Jumper"
sFile = "Redirect.tbl"
cmdAddHub = "addhub"
cmdDelHub = "delhub"
cmdShowHubs = "showhubs"
cmdHelp = "redirhelp"
cmdRD = "jump"
tRDHubs = {}
local f,e = io.open(sFile, "a+" ) if f then f:write("" ) f:close() end
tPermissions = {
[0] = {
["add_del"] = 1, -- use 1 for allowed, 0 for not allowed
["show"] = 1,
["rd"] = 0,
},
[1] = {
["add_del"] = 1, -- use 1 for allowed, 0 for not allowed
["show"] = 1,
["rd"] = 1,
},
[2] = {
["add_del"] = 1, -- use 1 for allowed, 0 for not allowed
["show"] = 1,
["rd"] = 1,
},
[3] = {
["add_del"] = 0, -- use 1 for allowed, 0 for not allowed
["show"] = 1,
["rd"] = 1,
},
[4] = {
["add_del"] = 0, -- use 1 for allowed, 0 for not allowed
["show"] = 1,
["rd"] = 1,
},
[5] = {
["add_del"] = 1, -- use 1 for allowed, 0 for not allowed
["show"] = 1,
["rd"] = 0,
},
[-1] = {
["add_del"] = 0, -- use 1 for allowed, 0 for not allowed
["show"] = 1,
["rd"] = 1,
},
}
tCMD = {
[cmdHelp] = function(sNick,iProf,sArg)
local sHelp = "Available commands:\n\n\t\t!"..cmdHelp.."\t\t\t-Shows this help file\n"
if tPermissions[iProf].add_del == 1 then
sHelp = sHelp.."\n\t\t!"..cmdAddHub.." <address:port>\t-Add a hub to the list\n"
.."\t\t!"..cmdDelHub.." <address:port>\t-Delete a hub from the list\n"
end
if tPermissions[iProf].show == 1 then
sHelp = sHelp.."\n\t\t!"..cmdShowHubs.."\t\t-Shows all hubs in the list\n"
end
if tPermissions[iProf].rd == 1 then
sHelp = sHelp.."\n\t\t!"..cmdRD.." <address:port>\t-Redirect yourself to the specified hub\n"
end
return sHelp
end,
[cmdRD] = function(sNick,iProf,sArg)
if sArg then
if tPermissions[iProf].rd == 1 then
return 1
else
return "You are not allowed to use this command"
end
else
return "Please specify an address -> !"..cmdRD.." <address:port>"
end
end,
[cmdShowHubs] = function(sNick,iProf,sArg)
if tPermissions[iProf].show == 1 then
local sHubs = "Current hubs to redirect to:\n\n"
for k in pairs(tRDHubs) do
sHubs = sHubs.."\t\t"..tRDHubs[k].."\n"
end
return sHubs
else
return "You are not allowed to use this command"
end
end,
[cmdAddHub] = function(sNick,iProf,sArg)
if sArg then -- if address is specified
if tPermissions[iProf].add_del == 1 then
table.insert(tRDHubs,sArg) -- add hub
SaveToFile(sFile,tRDHubs,"tRDHubs")
local tAllUsers = frmHub:GetOnlineUsers()
for _,k in pairs(tAllUsers) do
SendUserCommands(k.sName)
end
return sArg.." has been added to the list"
else
return "You are not allowed to use this command"
end
else
return "Please specify an address -> !"..cmdAddHub.." <address:port>"
end
end,
[cmdDelHub] = function(sNick,iProf,sArg)
if sArg then
if tPermissions[iProf].add_del == 1 then
for k in pairs(tRDHubs) do
if tRDHubs[k] == sArg then
table.remove(tRDHubs, k) -- remove hub
SaveToFile(sFile,tRDHubs,"tRDHubs")
break
end
end
local tAllUsers = frmHub:GetOnlineUsers()
for _,k in pairs(tAllUsers) do
SendUserCommands(k.sName)
end
return sArg.." has been removed from the list"
else
return "You are not allowed to use this command"
end
else
return "Please specify an address -> !"..cmdDelHub.." <address:port>"
end
end,
}
Main = function()
dofile(sFile)
frmHub:RegBot(sBotname)
end
OnExit = function()
SaveToFile(sFile,tRDHubs,"tRDHubs")
end
ChatArrival = function(User,Data)
local _,_,cmd,sArgs = string.find(Data, "%b<>%s%p(%S+)%s(.*)|")
if sArgs then
if tCMD[cmd] then
local sReturn = tCMD[cmd](User.sName,User.iProfile,sArgs)
if sReturn == 1 then
-- user will be redirected
User:SendData(sBotname, "You will now be redirected to "..sArgs)
User:Redirect(sArgs, "You have choosen to be redirected to this hub. Enjoy your stay there")
else
-- return the message
User:SendData(sBotname,sReturn)
end
return 1
end
else
-- no arguments, could be show or help command
local _,_,sCmd = string.find(Data, "%b<>%s%p(%S+)|")
if tCMD[sCmd] then
User:SendData(sBotname, tCMD[sCmd](User.sName,User.iProfile,nil))
return 1
end
end
end
ToArrival = function(User,Data)
local _,_,cmd,sArgs = string.find(Data, "%b<>%s%p(%S+)%s(.*)|")
if sArgs then
if tCMD[cmd] then
local sReturn = tCMD[cmd](User.sName,User.iProfile,sArgs)
if sReturn == 1 then
-- user will be redirected
User:SendPM(sBotname, "You will now be redirected to "..sArgs)
User:Redirect(sArgs, "You have choosen to be redirected to this hub. Enjoy your stay there")
else
-- return the message
User:SendData(sBotname,sReturn)
end
return 1
end
else
-- no arguments, could be show or help command
local _,_,sCmd = string.find(Data, "%b<>%s%p(%S+)|")
if tCMD[sCmd] then
User:SendPM(sBotname, tCMD[sCmd](User.sName,User.iProfile,nil))
return 1
end
end
end
NewUserConnected = function(User)
SendUserCommands(User.sName)
end
OpConnected = NewUserConnected
SendUserCommands = function(sNick)
local sMenu = frmHub:GetHubName()
local User = GetItemByName(sNick)
User:SendData("$UserCommand 255 9|")
User:SendData("$UserCommand 1 3 "..sMenu.."\\"..sBotname.."\\Help$<%[mynick]> !"..cmdHelp.."||")
if tPermissions[User.iProfile].add_del == 1 then
User:SendData("$UserCommand 0 3 ||")
User:SendData("$UserCommand 1 3 "..sMenu.."\\"..sBotname.."\\Add Hub$<%[mynick]> !"..cmdAddHub.." %[line:Address]||")
User:SendData("$UserCommand 1 3 "..sMenu.."\\"..sBotname.."\\Delete Hub$<%[mynick]> !"..cmdDelHub.." %[line:Address]||")
end
if tPermissions[User.iProfile].show == 1 then
User:SendData("$UserCommand 0 3 ||")
User:SendData("$UserCommand 1 3 "..sMenu.."\\"..sBotname.."\\Show Hubs$<%[mynick]> !"..cmdShowHubs.."||")
end
if tPermissions[User.iProfile].rd == 1 then
User:SendData("$UserCommand 0 3 ||")
User:SendData("$UserCommand 1 3 "..sMenu.."\\"..sBotname.."\\Redirect Self$<%[mynick]> !"..cmdRD.." %[line:Address]||")
for k in pairs(tRDHubs) do
User:SendData("$UserCommand 1 3 "..sMenu.."\\"..sBotname.."\\Redirect Self to "..tRDHubs[k].."$<%[mynick]> !"..cmdRD.." "..tRDHubs[k].."||")
end
end
end
Serialize = function(tTable,sTableName,hFile,sTab)
sTab = sTab or ""
hFile:write(sTab..sTableName.." = {\n")
for key,value in pairs(tTable) do
if (type(value) ~= "function") then
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
end
hFile:write(sTab.."}")
end
SaveToFile = function(file, table, tablename)
local handle = io.open(file,"w")
Serialize(table,tablename,handle)
handle:close()
end
Greetz, CG ;-)