ok, i know, a couple of topics earlier someone asked for the same, but i mean something different. well i already got one for pinging hubs, but it works just fine, now we want to change the network, every hub has a signifacant min hub share (ie 5 gb min 10 gb min 20 gb min 50 gb min, ETC.) so now we want a redirect array that lets a user of 30 gb not join join the 50 GB + hub but automatically one of the lower ones.
So a script that can redirect someone by it's share
(i can't care if it's lua4 or 5)
Cheers ICE
I already got this:
(lua5)
function NewUserConnected(User)
--//sharesize return is in bytes
user_sharesize = User.iShareSize
--//0B-30GiB exclusively
if (user_sharesize > 0) and (user_sharesize < 30720000000) then
User:Redirect(Address, Reason)
--//greater than OR equal to 30GiB
elseif (user_sharesize >= 30720000000) then
User:Redirect(Address, Reason)
end
end
--[[
= ShareToRed by Herodes =
- Redirects users acorrding to share...
- you may set custom redirect messages.
--]]
tUnit = "gb" -- lower-case the unit in which the sharesize limits are counted... ( maybe i'll work on more that later .. )
tHubs = { -- ["number_of_units_required"] = { "hub.address.com", "excuse for redirecting.." }, --- be sure that you keep this format.. mind the last comma..
["5"] = { "hub1.no.way", "Our 5GB MinShare Hub", },
["10"] = { "hub2.no.way", "Our 10GB MinShare Hub", },
["20"] = { "hub3.no.way", "Our 20GB MinShare Hub", },
["50"] = { "hub4.no.way", "Our 50GB MinShare Hub", },
["100"] = { "hub5.no.way", "Our 100GB MinShare Hub", },
}
function LookForRed( share )
local tUnits, hub = { ["kb"] = 1, ["mb"] = 2, ["gb"] = 3, ["pb"] = 4 }, nil
for s,h in tHubs do
if (share < tonumber(s)*1024*tUnits[tUnit]) then hub = h
else break;
end
end
return hub
end
function NewUserConnected(user)
local where = LookForRed(user.iShareSize)
if where then
user:Redirect(where[1], where[2])
end
end
function whichServer(SomeNum)
servernum = math.random(SomeNum)
if (servernum < 1) then
return hub1.ip.org
elseif (servernum >= 1) and (servernum < 2) then
return hub2.ip.org
elseif (servernum >= 2) and (servernum < 3) then
return hub3.ip.org
end
--//in case of some error just send to hub1
return hub1.no-ip.org
end
function NewUserConnected(User)
--//sharesize return is in bytes
user_sharesize = User.iShareSize
--//0B-20GiB exclusively
if (user_sharesize > 0) and (user_sharesize < 20480000000) then
User:Redirect(whichServer(2), Reason)
--//greater than OR equal to 20GiB
elseif (user_sharesize >= 20480000000) then
User:Redirect(whichServer(3), Reason)
end
end
-- multiple return values example ...
function give_me_five()
return 1,2,3,4,5
end
one, two, three, four, five = give_me_five()
-- those variables will now have the following values
--[[
one == 1
two == 2
...
five == 5
--]]
-- multiple return types example ...
function give_smth()
return { "good", [1] = 23, ["now"] = "good time to learn smth new" }, true, "great", 4
end
table, bool, string, number = give_smth()
-- those variables will now have the following values..
--[[
table == { "good", [1] = 23, ["now"] = "good time to learn smth new" }
bool == true
string == "great"
number == 4
--]]
Thx to Jemte & Herodes
But how to continue from this?
i get this:
[01:19] *** Connecting to XXXXXXX.redirectme.net:XXX...
[01:19] *** Connected
[01:19]
You are being redirected to
[01:19] *** Disconnected
Cheers ICE