Hello,
Ive been searching for a script like this:
!setredirect
which will set a redirect address for each according to: share: the minimum share not met slots: the minimum slots not met hubs: in too many hubs full: when hub is full so that it can redirect automatically to different hubs depending on those 4 things. Thanks a bunch :)
Hi,
Hope it helps...
--## REDIRECT MANAGER BOT --## Requested by morphie --## Made by nErBoS --## Command: --## !setredirect - Set a addy to a Option if not set the minium required --## Option: share/slots/hubs/full (ONLY TO MASTERs) --## Only remove this array if your ptokax supports LUA 5 ##-- string = { sub = strsub, len = strlen, find = strfind, lower = strlower, } --## END of REMOVE ##-- sBot = "RM-Bot" arrAddy = {} arrAddy["share"] = {} arrAddy["slots"] = {} arrAddy["hubs"] = {} arrAddy["full"] = {} arrAddy["share"]["ADDY"] = "" arrAddy["slots"]["ADDY"] = "" arrAddy["hubs"]["ADDY"] = "" arrAddy["full"]["ADDY"] = "" fData = "rules.dat" function Main() frmHub:RegBot(sBot) LoadFromFile(fData) --## Rules Configuration ##-- arrAddy["share"]["RULE"] = 0 -- Min Share required arrAddy["share"]["TYPE"] = 0 -- (0 = B, 1 = KB, 2 = MB, 3 = GB, 4 = TB) arrAddy["slots"]["RULE"] = 0 -- Min Slots required arrAddy["hubs"]["RULE"] = 0 -- Max Hubs allowed arrAddy["full"]["RULE"] = 0 -- Max Useres allowed uLaterPtokax = 0 -- Choose 0 if you are using Ptokax Version 0.3.3.0 or higher -- Choose 1 if you are using Ptokax Version lower then 0.3.3.0 --## END ##-- end function OnExit() SaveToFile(fData , arrAddy , "arrAddy") end function NewUserConnected(user) local s,e,desc,share = string.find(user.sMyInfoString, "%$MyINFO%s+%$ALL%s+%S+.+(%b<>)%$%s+%$.+%$(%d+)%$") if (frmHub:GetUsersCount() > arrAddy["full"]["RULE"]) then user:SendData(sBot, "This HUB is full. You are been redirect to another HUB.") user:SendData(sBot, "Redirecting...") user:SendData("$ForceMove "..arrAddy["full"]["ADDY"].."|") elseif (desc ~= nil) then local s,e,hubs,slots = string.find(desc, "H:(.+),S:(%d+)") share = tonumber(share)/(1024^arrAddy["share"]["TYPE"]) if (tonumber(slots) < arrAddy["slots"]["RULE"]) then user:SendData(sBot, "You must have "..arrAddy["slots"]["RULE"].." slots open to enter this HUB. You are been redirect to another HUB.") user:SendData(sBot, "Redirecting...") user:SendData("$ForceMove "..arrAddy["slots"]["ADDY"].."|") elseif (share < arrAddy["share"]["RULE"]) then local type = "B" if (arrAddy["share"]["TYPE"] == 1) then type = "KB" elseif (arrAddy["share"]["TYPE"] == 2) then type = "MB" elseif (arrAddy["share"]["TYPE"] == 3) then type = "GB" elseif (arrAddy["share"]["TYPE"] == 4) then type = "TB" end user:SendData(sBot, "You must have at least "..arrAddy["share"]["RULE"].." "..type.." to enter this HUB. You are been redirect to another HUB.") user:SendData(sBot, "Redirecting...") user:SendData("$ForceMove "..arrAddy["share"]["ADDY"].."|") else local s,e,unreg,reg,op,count = string.find(hubs, "(%d+)/(%d+)/(%d+)") if (unreg == nil) then count = tonumber(hubs) else count = tonumber(unreg) + tonumber(reg) + tonumber(op) end if (count > arrAddy["hubs"]["RULE"]) then user:SendData(sBot, "You can't be in more then "..arrAddy["slots"]["RULE"].." HUBs. You are been redirect to another HUB.") user:SendData(sBot, "Redirecting...") user:SendData("$ForceMove "..arrAddy["hubs"]["ADDY"].."|") end end end end function DataArrival(user,data) if (string.sub(data,1,1) == "<" or string.sub(data,1,5+string.len(sBot)) == "$To: "..sBot) then data = string.sub(data,1,string.len(data)-1) s,e,cmd = string.find(data, "%b<>%s+(%S+)") if (cmd == "!setredirect" and user.iProfile == 0) then local s,e,opt,addy = string.find(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)") if (opt == nil or addy == nil) then user:SendPM(sBot, "Syntax Error, !setredirect , you must write a option and an addy.") elseif (arrAddy[strlower(opt)] == nil) then user:SendPM(sBot, "Syntax Error, !setredirect , you must write one of this options: share/slots/hubs/full") else user:SendPM(sBot, "The addy of "..opt.." has been changed to: "..addy) arrAddy[strlower(opt)]["ADDY"] = addy if (uLaterPtokax == 1) then OnExit() end end return 1 end end end function Serialize(tTable, sTableName, sTab) assert(tTable, "tTable equals nil"); assert(sTableName, "sTableName equals nil"); assert(type(tTable) == "table", "tTable must be a table!"); assert(type(sTableName) == "string", "sTableName must be a string!"); sTab = sTab or ""; sTmp = "" sTmp = sTmp..sTab..sTableName.." = {\n" for key, value in tTable do local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key); if(type(value) == "table") then sTmp = sTmp..Serialize(value, sKey, sTab.."\t"); else local sValue = (type(value) == "string") and format("%q",value) or tostring(value); sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue end sTmp = sTmp..",\n" end sTmp = sTmp..sTab.."}" return sTmp end function SaveToFile(file , table , tablename) writeto(file) write(Serialize(table, tablename)) writeto() end function LoadFromFile(file) if (readfrom(file) ~= nil) then readfrom(file) dostring(read("*all")) readfrom() end end
Best regards, nErBoS
Thanks alot! That's perfect! I had a few problems i first but got it figured out, it works perfectly as I wanted it. Thanks a bunch :)
Ok I spoke too soon, I now get a Syntax error when new users join the hub:Syntax error: bad argument #1 to `find' (string expected, got nil) stack traceback: 1: method `find' [C] 2: function `NewUserConnected' at line 107 [file `C:\Program Files\Ptokax\scripts\Redirect.lua']
Hi, Have you added anything to the script ?? Because the line of the error is not from newuserconnected function. If yes post it here please. Another question, do you permit NMDC or DC with no tags in your HUB ?? Best regards, nErBoS
Nope i havent added anything and yes i permit NMDC and clients with no tags. Does that explain it?
Hi, I need the script that you are using. Best regards, nErBoS