Special Redirect Array Script Needed...
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Special Redirect Array Script Needed...

Started by Metaphase, 04 October, 2004, 05:39:15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Metaphase

Hi all.

I am in need of a special redirect array script. I am looking for a script that can redirect all non-registered users to one of my other hubs according to how much they are sharing... For example;

Users with 1GB or less shares get redirected to Hub1.no-ip.org.
Users with 1GB to 7GB shares get redirected to Hub2.no-ip.org.
Users with 7GB to 40GB shares get redirected to Hub3.no-ip.org.

Any assistance on this script would be appriciated.

Metaphase

I have found this script on the forum but it needs a little altering in order for it to be useful for my setup. It seems this script is designed for 2 hubs but my network has 5 hubs, including the one it will be redirecting from. Here is the script....

Quote--Requested by 3lancer
--Made by nErBoS
--Corrected by NightLitch

Bot = "Share-Redirecter"

redshare1 = "1.1.1.1"
redshare2 = "1.1.1.2"
share1 = 5 --GB
share2 = 10 --GB

function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user, data)

local s,e,share = strfind(user.sMyInfoString, "$MyINFO $ALL [^$]+$ $[^$]*$[^$]*$([^$]+)")
share = share / (1024*1024*1024)
if(tonumber(share) ~= nil) then
if(tonumber(share) > tonumber(share1) and tonumber(share) < share2) then
user:SendData("$ForceMove "..redshare1.."|")
elseif(tonumber(share) >= tonumber(share2)) then
user:SendData("$ForceMove "..redshare2.."|")
else
end
else
end

end

If anyone is able to modify this script to be used with 5 hubs then please help  :)

plop

try this 1.
--Requested by 3lancer
--Made by nErBoS
--Corrected by NightLitch
-- added endless amount of hubs by plop

Bot = "Share-Redirecter"

-- biggest hub 1st, share size in GB
tHubs = {
   { share = 10,  ip = "1.1.1.1", name = "hubname1" },
   { share = 5, ip = "1.1.1.2", name = "hubname2" }
}

function Main()
   frmHub:RegBot(Bot)
end

function NewUserConnected(user, data)
   local s,e,share = strfind(user.sMyInfoString, "$MyINFO $ALL [^$]+$ $[^$]*$[^$]*$([^$]+)")
   if(tonumber(share)) then
	share = tonumber(share) / (1024*1024*1024)
	for i=1,getn(tHubs) do
	   if share > tHubs[i][share] then
		user:SendData(Bot, "You are being redirected to "..tHubs[i][name].."|$ForceMove "..tHubs[i][ip].."|")
	   end
	end
   end
end

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Metaphase

#3
Thanks alot Plop. I will give it a try. Am I right in thinking that when I want to add more hubs to the redirect list I only have to add an extra one of these lines per hub???

Quote{ share = 10,  ip = "1.1.1.1", name = "hubname1" },

Also, is it possible to change the IP address to the DNS of the hub as most hubs in the network have dynamic IP's?

nErBoS

Hi,

Offcourse you can put a IP or an addy.

Best regards, nErBoS
--## nErBoS Spot ##--

Metaphase

Thanks nErBoS.

One thing I have noticed about this script by looking at it is that it doesn't seem to redirect un-registered users only. Any ideas on what needs adding to achieve this?

bastya_elvtars

#6
I hope we think the same :D

--Requested by 3lancer
--Made by nErBoS
--Corrected by NightLitch
-- added endless amount of hubs by plop
-- modded for setting user levels to be redirected by bastya_elvtars (nice crew in here)
-- CheckUserLevel originally by Nathanos


-- who can be redirected?
level=2	-- 5:all users
			-- 4 ops & below
			-- 3 vips & below
			-- 2 registered users & below
			-- 1 guests only


Bot = "Share-Redirecter"


-- biggest hub 1st, share size in GB
tHubs = {
   { share = 10,  ip = "1.1.1.1", name = "hubname1" },
   { share = 5, ip = "1.1.1.2", name = "hubname2" }
}


function Main()
   frmHub:RegBot(Bot)
end


function NewUserConnected(user, data)
	if CheckUserLevel(user) < level then
		   local s,e,share = strfind(user.sMyInfoString, "$MyINFO $ALL [^$]+$ $[^$]*$[^$]*$([^$]+)")
		   if(tonumber(share)) then
			share = tonumber(share) / (1024*1024*1024)
			for i=1,getn(tHubs) do
			   if share > tHubs[i][share] then
				user:SendData(Bot, "You are being redirected to "..tHubs[i][name].."|$ForceMove "..tHubs[i][ip].."|")
			   end
			end
		   end
	end
end

function CheckUserLevel(user)
	if user.iProfile==0 then
		return 5
	elseif user.iProfile==1 then
		return 4
	elseif user.iProfile==3 then
		return 2
	elseif user.iProfile==2 then
		return 3
	else 
		return 1
	end
end
:D  :D  :D
Everything could have been anything else and it would have just as much meaning.

Metaphase

#7
Thanks for your quick reply bastya_elvtars.

I tried the script and I am getting the following error..

Syntax error: attempt to compare number with nil
stack traceback:
   1:  function `NewUserConnected' at line 38 [file `...\PtokaX 0.330 Debug Build 15.25\scripts\121.lua']

I only get this error when a user connects to the hub.

Herodes

well in fact better try this one ....
--Requested by 3lancer
--Made by nErBoS
--Corrected by NightLitch
-- added endless amount of hubs by plop
-- modded for setting user levels to be redirected by bastya_elvtars (nice crew in here)
-- CheckUserLevel originally by Nathanos


-- who can be redirected?
level=2	-- 5:all users
			-- 4 ops & below
			-- 3 vips & below
			-- 2 registered users & below
			-- 1 guests only


Bot = "Share-Redirecter"


-- biggest hub 1st, share size in GB
tHubs = {
   { ["share"] = 10,  ["ip"] = "1.1.1.1", ["name"] = "hubname1" },
   { ["share"] = 5, ["ip"] = "1.1.1.2", ["name"] = "hubname2" }
}


function Main()
   frmHub:RegBot(Bot)
end


function NewUserConnected(user, data)
	if CheckUserLevel(user) < level then
		   local s,e,share = strfind(user.sMyInfoString, "$MyINFO $ALL [^$]+$ $[^$]*$[^$]*$([^$]+)"
		   if(tonumber(share)) then
			share = tonumber(share) / (1024*1024*1024)
			for i=1,getn(tHubs) do
			   if share > tHubs[i]["share"] then
				user:SendData(Bot, "You are being redirected to "..tHubs[i]["name"].."|$ForceMove "..tHubs[i]["ip"].."|"
			   end
			end
		   end
	end
end

function CheckUserLevel(user)
	if user.iProfile==0 then
		return 5
	elseif user.iProfile==1 then
		return 4
	elseif user.iProfile==3 then
		return 2
	elseif user.iProfile==2 then
		return 3
	else 
		return 1
	end
end

the error above was cause because of these lines ...
share = tonumber(share) / (1024*1024*1024) --- declaring the value of ' share ' variable  
			for i=1,getn(tHubs) do
			   if share > tHubs[i][share] then --- if the value of 'share' variable is more than the value of 'share' index in table ' i ' of table ' tHubs ' then ...

so infact if share = 23 then tHubs[23] is really true .. :)

Metaphase

#9
Thanks Herodes.

The script now seems to be working fine. Its another script for Plops Archive. :)

bastya_elvtars

QuoteOriginally posted by Metaphase
Thanks Herodes.

The script now seems to be working fine. Its another script for Plops Archive. :)

but who is the author?  :D  :D  :D
Everything could have been anything else and it would have just as much meaning.

plop

-- Requested by 3lancer
-- Made by nErBoS
-- Corrected by NightLitch
-- added endless amount of hubs by plop
-- modded for setting user levels to be redirected by bastya_elvtars (nice crew in here)
-- CheckUserLevel originally by Nathanos
-- rewritennen CheckUserLevel by plop


-- who can be redirected?
level=2	-- 5:all users
		-- 4 ops & below
		-- 3 vips & below
		-- 2 registered users & below
		-- 1 guests only

Bot = "Share-Redirecter"

-- biggest hub 1st, share size in GB
tHubs = {
	{ ["share"] = 10,  ["ip"] = "1.1.1.1", ["name"] = "hubname1" },
	{ ["share"] = 5, ["ip"] = "1.1.1.2", ["name"] = "hubname2" }
}

function Main()
	frmHub:RegBot(Bot)
end

function NewUserConnected(user, data)
	if CheckUserLevel(user) < level then
		local s,e,share = strfind(user.sMyInfoString, "$MyINFO $ALL [^$]+$ $[^$]*$[^$]*$([^$]+)"
		if(tonumber(share)) then
			share = tonumber(share) / (1024*1024*1024)
			for i=1,getn(tHubs) do
				if share > tHubs[i]["share"] then
					user:SendData(Bot, "You are being redirected to "..tHubs[i]["name"].."|$ForceMove "..tHubs[i]["ip"].."|"
				end
			end
		end
	end
end

tLevels = {
	[0]=5,
	[1]=4,
	[2]=3,
	[3]=2,
}

function CheckUserLevel(user)
	if tLevels[(user.iProfile}]then
		return tLevels[(user.iProfile}]
	else 
		return 1
	end
end

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Herodes

Uhm ... Shouldn't this
function CheckUserLevel(user)
	if tLevels[(user.iProfile}]then
		return tLevels[(user.iProfile}]
	else 
		return 1
	end
end
be like this?
function CheckUserLevel(user)
	if tLevels[(user.iProfile[b])[/b]]then
		return tLevels[(user.iProfile[b])[/b]]
	else 
		return 1
	end
end

plop

more like this actualy.
damn mistyped a bit there.
function CheckUserLevel(user)
	return tLevels[(user.iProfile)] or 1
end

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

plop

#14
which you can shorten a bit more.
-- Requested by 3lancer
-- Made by nErBoS
-- Corrected by NightLitch
-- added endless amount of hubs by plop
-- modded for setting user levels to be redirected by bastya_elvtars (nice crew in here)
-- CheckUserLevel originally by Nathanos
-- CheckUserLevel eliminated by plop


-- who can be redirected?
iLevel=2	-- 5:all users
		-- 4 ops & below
		-- 3 vips & below
		-- 2 registered users & below
		-- 1 guests only

Bot = "Share-Redirecter"

-- biggest hub 1st, share size in GB
tHubs = {
	{ ["share"] = 10,  ["ip"] = "1.1.1.1", ["name"] = "hubname1" },
	{ ["share"] = 5, ["ip"] = "1.1.1.2", ["name"] = "hubname2" }
}

function Main()
	frmHub:RegBot(Bot)
end

tLevels = {
	[0]=5,
	[1]=4,
	[2]=3,
	[3]=2,
}

function NewUserConnected(user, data)
	if (tLevels[(user.iProfile)] or 1) < iLevel then
		local s,e,share = strfind(user.sMyInfoString, "$MyINFO $ALL [^$]+$ $[^$]*$[^$]*$([^$]+)")
		if(tonumber(share)) then
			share = tonumber(share) / (1024*1024*1024)
			for i=1,getn(tHubs) do
				if share > tHubs[i]["share"] then
					user:SendData(Bot, "You are being redirected to "..tHubs[i]["name"].."|$ForceMove "..tHubs[i]["ip"].."|")
				end
			end
		end
	end
end

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Metaphase

Well all I can say is thanks alot guys. The script is working great and we havn't had one single user get passed it and into the hub. Our hubs are now starting to fill up according to share sizes.  :D

Without people like you lot, DC would just be a protocol.  ;)

SMF spam blocked by CleanTalk