PtokaX forum

Archive => Archived 5.1 boards => Finished Scripts => Topic started by: BobyJ on 03 November, 2007, 10:57:14

Title: min share script...
Post by: BobyJ on 03 November, 2007, 10:57:14
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..
Title: Re: min share script...
Post by: CrazyGuy on 04 November, 2007, 12:33:36
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 ?
Title: Re: min share script...
Post by: BobyJ on 06 November, 2007, 10:55:23
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...
Title: Re: min share script...
Post by: CrazyGuy on 06 November, 2007, 13:50:24
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 :)
Title: Re: min share script...
Post by: BobyJ on 08 November, 2007, 10:16:50
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
Title: Re: min share script...
Post by: CrazyGuy on 08 November, 2007, 15:28:33
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,
}


Title: Re: min share script...
Post by: BobyJ on 15 November, 2007, 12:35:45
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...
Title: Re: min share script...
Post by: CrazyGuy on 15 November, 2007, 13:19:28
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  :)
Title: Re: min share script...
Post by: BobyJ on 16 November, 2007, 11:45:24
Ok, i will try the new one and i will tell you what is the situation.  ;)

Thanks CrazyGuy!  :)



Have a nice day

Regards...
Title: Re: min share script...
Post by: BobyJ on 16 November, 2007, 16:26:23
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...
Title: Re: min share script...
Post by: CrazyGuy on 17 November, 2007, 15:38:32
Reply # 6 is your own post with the code with error.
Please use the code in Reply # 5  ;)
Title: Re: min share script...
Post by: BobyJ on 19 November, 2007, 13:44:19
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...
Title: Re: min share script...
Post by: BobyJ on 19 November, 2007, 23:01:46
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...
Title: Re: min share script...
Post by: CrazyGuy on 20 November, 2007, 12:42:40
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  :)
Title: Re: min share script...
Post by: BobyJ on 20 November, 2007, 16:50:15
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...
Title: Re: min share script...
Post by: CrazyGuy on 20 November, 2007, 22:02:38
You're welcome, and don't give too much credit, I might get lazy  :P