min share script...
 

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

min share script...

Started by BobyJ, 03 November, 2007, 10:57:14

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BobyJ

Hello mates  ;)
First sorry for my bad english.  :'(

I search for script that allows users with less "min share ex. ...(50GB)"of my hub,to connect it,but can't download from others users that are with 50GB and more.Only between users with share less then (...50GB). Can i explain clearly,sorry again for my bad english mates.
Is there any script like this ,that can help me against leechers?
Or can someone to make it?
Please if anybody knows and can help,let me say
Thanks in advance friends.  :)

P.s
I use PtokaX 0.3.6.0,Robocop 10.023, and some little scripts...


Have a nice day  :)
Regards..

CrazyGuy

Well, you'll need to dump RoboCop first, and that will give you some less headaches in the future as well  ;)

If I understand your request correctly, you'd like to use the minimum share not as a criteria to connect, but as a criteria to download.

For example :

User A has 52 GB share.
User B has 99 GB share.
User C shares nothing.

User A and B are able to download from eachother, but User C cannot download from either 1 of them because it doesn't have the minimum required of 50 GB share. However, User C is able to connect and sit in the hub and talk.

Is this what you mean ?

BobyJ

Hello CrazyGuy  :)

First thanks for your quickly response.  :)
Yes, this is what i mean,but user C to can download,not only talk.
I want that user C can download only from users like him i mean (users with share under 50GB)
Is this possibly?

For Robocop, yes i think many times to stop him  ;)
But i must to find suitable alternate scripts and then i will make this.  8)


Have i nice day CrazyGuy  :)

Regards...

CrazyGuy

Try this script, and see if it fits your needs

--[[
Script by CrazyGuy
LUA 5.1.x
for PtokaX old and new API
Last updated November 6th 2007

This script checks the size of the share of the user sending a connection request
If this sharesize is less than the sharesize specified by iMinShareToDLFromAll,
this user is only allowed to download from others who also have less share.
If the user doesn't make the min required share and has a connection request to a user who does,
this request will be blocked.
In all other cases, the request will proceed
]]--

iMinShareToDLFromAll = (50 * 1024 * 1024 * 1024 )	-- 50 GB limit

ConnectToMeArrival = function(User,Data)
	-- get the users sharesize
	local iCurShare = tAPI.GetShareSize(User)
	-- check if it's less then required, otherwise it's okay
	if iCurShare < iMinShareToDLFromAll then		
		-- less than required, get the user he's trying to connect to
		-- determine if it's a passive or active request
		local sVictim = ""
		if Data:find("RevConnectToMe") then
			-- passive
			_,_,sVictim = Data:find("%$RevConnectToMe%s%S+%s(%S+)|")	
		else
			-- active
			_,_,sVictim = Data:find("%$ConnectToMe%s(%S+)%s.*|")
		end			
		local tVictim = tAPI.GetUser(sVictim)
		-- get the targets sharesize
		local iVicShare = tAPI.GetShareSize(tVictim)
		-- if the targets sharesize is above requirement
		if iVicShare > iMinShareToDLFromAll then
			-- block this request
			return tAPI.ReturnBlock()
		end
	end
	-- in all other cases we do not block the request
end
RevConnectToMeArrival = ConnectToMeArrival

tAPI = {
	["GetShareSize"] = function(oUser)
		if Core then
			Core.GetUserData(oUser,16)
		end
		return oUser.iShareSize
	end,
	["GetUser"] = function(sNick)
		if Core then
			return Core.GetUser(sNick)
		else
			return GetItemByName(sNick)
		end
	end,
	["ReturnBlock"] = function()
		if Core then
			return true
		else
			return 1
		end
	end,
}


P.S. I haven't tested it, so in case of errors, lemmy know :)

BobyJ

Hello CrazyGuy   :D

The script give not any syntax error!  :)  But i don't test it yet in hub,maybe after two days.
I have a one more question. Is it  possibility to add in the script notice to the users which are blocked: 
Eg......    "Your download from this user is blocked ,becouse you have less then min share 50GB..."   or something like that
And where and how i can change the min share in the script?
maybe here:

iMinShareToDLFromAll = (50 * 1024 * 1024 * 1024 )   -- 50 GB limit

Thanks CrazyGuy,you are great scripter  8)

Regards...
Have a nice day

CrazyGuy

#5
Quote from: BobyJ on 08 November, 2007, 10:16:50
And where and how i can change the min share in the script?
maybe here:

iMinShareToDLFromAll = (50 * 1024 * 1024 * 1024 )   -- 50 GB limit

Yes, exactly there. Put a different number there if you want a different share.

Hereunder, an update which notifies the user in pm that the connection request was blocked.

--[[
Script by CrazyGuy
LUA 5.1.x
for PtokaX old and new API
Last updated November 6th 2007

Changelog November 8th 2007
-- Added notification in PM to user when request is blocked

This script checks the size of the share of the user sending a connection request
If this sharesize is less than the sharesize specified by iMinShareToDLFromAll,
this user is only allowed to download from others who also have less share.
If the user doesn't make the min required share and has a connection request to a user who does,
this request will be blocked.
In all other cases, the request will proceed
]]--

iMinShareToDLFromAll = (50 * 1024 * 1024 * 1024 )	-- 50 GB limit

ConnectToMeArrival = function(User,Data)
	-- get the users sharesize
	local iCurShare = tAPI.GetShareSize(User)
	-- check if it's less then required, otherwise it's okay
	if iCurShare < iMinShareToDLFromAll then		
		-- less than required, get the user he's trying to connect to
		-- determine if it's a passive or active request
		local sVictim = ""
		if Data:find("RevConnectToMe") then
			-- passive
			_,_,sVictim = Data:find("%$RevConnectToMe%s%S+%s(%S+)|")	
		else
			-- active
			_,_,sVictim = Data:find("%$ConnectToMe%s(%S+)%s.*|")
		end			
		local tVictim = tAPI.GetUser(sVictim)
		-- get the targets sharesize
		local iVicShare = tAPI.GetShareSize(tVictim)
		-- if the targets sharesize is above requirement
		if iVicShare > iMinShareToDLFromAll then
			-- notify the user
			tAPI.NotifyUser(User)
			-- block this request
			return tAPI.ReturnBlock()
		end
	end
	-- in all other cases we do not block the request
end
RevConnectToMeArrival = ConnectToMeArrival

tAPI = {
	["GetTresholdInUnits"] = function()
		local iLngShare = iMinShareToDLFromAll
		local iCntr = 0
		while iLngShare > 1024 do
			iLngShare = (iLngShare/1024)
			iCntr = iCntr + 1
		end
		local tUnit = {
			[0] = " Bytes",
			[1] = " Kilobytes",
			[2] = " Megabytes",
			[3] = " Gigabytes",
			[4] = " Terabytes",
		}
		return iLngShare..tUnit[iCntr]
	end,
	["GetShareSize"] = function(oUser)
		if Core then
			Core.GetUserData(oUser,16)
		end
		return oUser.iShareSize
	end,
	["GetUser"] = function(sNick)
		if Core then
			return Core.GetUser(sNick)
		else
			return GetItemByName(sNick)
		end
	end,
	["ReturnBlock"] = function()
		if Core then
			return true
		else
			return 1
		end
	end,
	["NotifyUser"] = function(oUser)
		local sMessage = "Your connection request has been blocked because you sharesize is below the treshold while that of the user you try to connect to is above. To avoid this message, please share more than "..tAPI.GetTresholdInUnits().."."
		if Core then
			Core.SendPmToUser(oUser, SetMan.GetString(21), sMessage.."|")
		else
			SendPmToNick(oUser.sName, frmHub:GetHubBotName(), sMessage)
		end
	end,
}



BobyJ

#6
Hello CrazyGuy   :)

i was correct the script for 20GB min share.
Now is look like this:

--[[
Script by CrazyGuy
LUA 5.1.x
for PtokaX old and new API
Last updated November 6th 2007

Changelog November 8th 2007
-- Added notification in PM to user when request is blocked

This script checks the size of the share of the user sending a connection request
If this sharesize is less than the sharesize specified by iMinShareToDLFromAll,
this user is only allowed to download from others who also have less share.
If the user doesn't make the min required share and has a connection request to a user who does,
this request will be blocked.
In all other cases, the request will proceed
]]--

iMinShareToDLFromAll = (20 * 1024 * 1024 * 1024 )	-- 20 GB limit

ConnectToMeArrival = function(User,Data)
	-- get the users sharesize
	local iCurShare = tAPI.GetShareSize(User)
	-- check if it's less then required, otherwise it's okay
	if iCurShare < iMinShareToDLFromAll then		
		-- less than required, get the user he's trying to connect to
		-- determine if it's a passive or active request
		local sVictim = ""
		if Data:find("RevConnectToMe") then
			-- passive
			_,_,sVictim = Data:find("%$RevConnectToMe%s%S+%s(%S+)|")	
		else
			-- active
			_,_,sVictim = Data:find("%$ConnectToMe%s(%S+)%s.*|")
		end			
		local tVictim = tAPI.GetUser(sVictim)
		-- get the targets sharesize
		local iVicShare = tAPI.GetShareSize(tVictim)
		-- if the targets sharesize is above requirement
		if iVicShare > iMinShareToDLFromAll then
			-- notify the user
			tAPI.NotifyUser(tVictim)
			-- block this request
			return tAPI.ReturnBlock()
		end
	end
	-- in all other cases we do not block the request
end
RevConnectToMeArrival = ConnectToMeArrival

tAPI = {
	["GetTresholdInUnits"] = function()
		local iLngShare = iMinShareToDLFromAll
		local iCntr = 0
		while iLngShare > 1024 do
			iLngShare = (iLngShare/1024)
			iCntr = iCntr + 1
		end
		local tUnit = {
			[0] = " Bytes",
			[1] = " Kilobytes",
			[2] = " Megabytes",
			[3] = " Gigabytes",
			[4] = " Terabytes",
		}
		return iLngShare..tUnit[iCntr]
	end,
	["GetShareSize"] = function(oUser)
		if Core then
			Core.GetUserData(oUser,16)
		end
		return oUser.iShareSize
	end,
	["GetUser"] = function(sNick)
		if Core then
			return Core.GetUser(sNick)
		else
			return GetItemByName(sNick)
		end
	end,
	["ReturnBlock"] = function()
		if Core then
			return true
		else
			return 1
		end
	end,
	["NotifyUser"] = function(oUser)
		local sMessage = "Your connection request has been blocked because you sharesize is below the treshold while that of the user you try to connect to is above. To avoid this message, please share more than "..tAPI.GetTresholdInUnits.."."
		if Core then
			Core.SendPmToUser(oUser, SetMan.GetString(21), sMessage.."|")
		else
			SendPmToNick(oUser.sName, frmHub:GetHubBotName(), sMessage)
		end
	end,
}


But it give me this message in the PtokaX script window:

[19:43] Syntax ... LUA 5.1.2\scripts\CrazyGuy 20 GB.lua:88: attempt to concatenate field 'GetTresholdInUnits' (a function value)


I was made few attempts,but i think that the script not work
Is that script for all users in hub (including Op's,Masters,Moderators) or only for not registered?



Have a nice day....

Regards...

CrazyGuy

The script should work on all profiles. I see I forgot a set of brackets somewhere which causes the error.
The script in the above post is updated wih the fix, Lemmy know if there's anything else  :)

BobyJ

Ok, i will try the new one and i will tell you what is the situation.  ;)

Thanks CrazyGuy!  :)



Have a nice day

Regards...

BobyJ

#9
Hello CrazyGuy.

Sorry for that i must say it ,but the script is showing me the same text:

[17:14] Syntax ....3.6.0 with LUA 5.1.2\scripts\CrazyCuy 20GB last.lua:88: attempt to concatenate field 'GetTresholdInUnits' (a function value)

Please ,see it again for any error.
What i make:
I was copy from the code: window above (replay nr.6) ,paste in notepad and then rename to .lua
Then i was paste in PtokaX\scripts  folder
I think that i do not  a mistake,isn't it?

:-\


Have a nice day and good luck


Regards...

CrazyGuy

Reply # 6 is your own post with the code with error.
Please use the code in Reply # 5  ;)

BobyJ

oohhhh,sorry mate.
I'm not see the right post.My fault.   ;)
I'll try the script in post #5,and will type if is it any problem or not.
Thanks  :)




Have a nice day


Regards...

BobyJ

#12
Now the script work.  :)
But the user who is below the min share and try to connect to others with more then 20 GB ,don't recive in PM the notice...   :-\
When other users try to connect to me with share below 20GB i recive the message from Hub-Security bot.
I want the user with share below 20GB which try to connect to others with share above 20GB ,to recive in PM the notice message.
Can you fix this?  ;)



Regards...

CrazyGuy

lol , indeed, I made a dumb mistake there  ;D

look for
tAPI.NotifyUser(tVictim)


and change that to
tAPI.NotifyUser(User)


I will also update the post in Reply # 5 again  :)

BobyJ

Yahooooooo  :) :) :)

Now everything is allright.
Well done CrazyGuy.  :)
Thanks a lot for this help,you are great scripter.  :)
If i have any new question ,i will type here again.  ;)
Have a nice evening mate, and good luck!


Regards...

CrazyGuy

You're welcome, and don't give too much credit, I might get lazy  :P

SMF spam blocked by CleanTalk