help....
 

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

help....

Started by angelsanges, 22 January, 2004, 09:54:37

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

angelsanges

it is possible to build a script that disconnect users that do not have file up to 2 gb in share?

PS it must function at the "login" fase  :D

thanks in advance

BlazeXxX

You mean minimum share of 2GB?

Pedro

I am learning by imitation of existing scripts..

I hope this works for you..

-----------------------------------------------------------------------
botname = "minshare"
minShareGB = 2


kb = 1024
mb = kb*kb
gb = kb*kb*kb
minShare = minShareGB * gb

function NewUserConnected(user)
   local t = tokenize(user.sMyInfoString,"$")
   local num = t[getn(t)]

   if tonumber( num ) < minShare then
    user:SendPM( botname, "You have not reached the minimum share amount "..minShareGB.."GB")
         curUser:Disconnect()
     end
  end
------------------------------------------------------------------------
if it aint broke, open it up and find out why...

Pedro

Remove this.....

function NewUserConnected(user)
local t = tokenize(user.sMyInfoString,"$")
local num = t[getn(t)]


I dont think it plays any part of the share check..

I am sure the higher beings will keep me right on that tho. :P
if it aint broke, open it up and find out why...

NightLitch

Well yes, but you need to check the MyInfoString... :-)
//NL

NightLitch

this is what you need:
s,e, vShare = strfind(curUser.sMyInfoString,"$+(%d+)$+|+")
if vShare ~= nil then

this is where you should put it:

botname = "minshare" 
minShareGB = 2 


kb = 1024 
mb = kb*kb 
gb = kb*kb*kb 
minShare = minShareGB * gb 

function NewUserConnected(user) -- <----- LOOK HERE, THIS IS THE USER "code" you should use on every user line.
-- REMOVE  local t = tokenize(user.sMyInfoString,"$") 
-- REMOVE  local num = t[getn(t)] 
-------------------------------------------
-- ABOVE CODE HERE
-------------------------------------------
-- CHANGE ( num ) TO ( vShare )
if tonumber( num ) < minShare then 

-- NOTE user here...
user:SendPM( botname, "You have not reached the minimum share amount "..minShareGB.."GB") 

-- NOTE curUser here...
curUser:Disconnect() 
end 
end

so choose between ( user ) and ( curUser ) in this code, or
change user/curUser to whatever you like maybe Alien, Heppo etc.

ex:

function Example(whatever,data)
whatever:SendData("Hello "..whatever.sName)
end

hope you understand my points here now... though you wanna learn so didn't put the script together.
//NL

c h i l l a

#6
I think this is a nice way to get the share


_,_,share = strfind(curUser.sMyInfoString,"%$(%d+)%$|$")


and this

function GetShare(curUser)
	for i = 1,strlen(curUser.sMyInfoString)-2,1 do
		i2 = strlen(curUser.sMyInfoString)-1-i
		if strsub(curUser.sMyInfoString,i2,i2) == "$" then
			return(strsub(curUser.sMyInfoString,i2+1,strlen(curUser.sMyInfoString)-2))
		end
	end
end
havens't checked whitch one is faster but I guess the first one.

NightLitch

nice solusion Chilla.

can you explain this to me:

_,_,share = strfind(curUser.sMyInfoString,"%$(%d+)%$|$")

"%

what does the % do ??? do you mind explaining each character to me... sure I now (%d+) getting digits(numbers)
and the last $ is for reading from the back and the other 2
is in the MyInfoString, but what do the "extra" % do ?

and liked you calling the share. must learn more I see.

but above first. Trying to make my Own hole from the begining Client-Check now. so plz.
//NL

c h i l l a

#8
sure

_,_,  I do this when I know the string is there so I don't declare any other variables then the ones needed.

dunno s is I think the lenght and e is if it true or false dunno.

the %  is to tell LUA on strfind that the char after % is meant as char and not as magical characer whitch $ is.

so %$ means I mean a $ in a string while

$  on the end of strfind  e.g.  |$  means its the end of the string.

as you already know :)

plop told me that strfind is actually only using  strsub.
and I just tested the t 2 ways of getting the share.
and it turn out they are the same mostly. (wish I had a realtime OS to really try it.)


tried with this code

---$MyINFO $ALL dumbo12 <++ V:0.306,M:A,H:1/0/0,S:0,B:4>$ $28.8Kbps$$7445568923$|

Infostr = "$MyINFO $ALL dumbo12 <++ V:0.306,M:A,H:1/0/0,S:0,B:4>$ $28.8Kbps$$7445568923$|"

infocut = "$MyINFO $ALL dumbo12 <++ V:0.306,M:A,H:1/0/0,S:0,B:4>$ $28.8Kbps$$"


function Compshare(infocut)

local var1,var2 = 0,0

local srun = 10000

for i = 1,srun do
	local infoshare = infocut..i.."$|"
	
	t1 = clock()

	_,_,share = strfind(infoshare,"%$(%d+)%$|$")
	
	if tonumber(share) then
	end

	t2 = clock()

	if tonumber(GetShare(infoshare)) then
	end

	t3 = clock()

	var1 = var1 + (t2-t1)
	var2 = var2 + (t3-t2)
end

print("Used Time:   "..(var1/srun).."     2   "..(var2/srun))


end

function GetShare(curInfoString)
	for i = 1,strlen(curInfoString)-2,1 do
		i2 = strlen(curInfoString)-1-i
		if strsub(curInfoString,i2,i2) == "$" then
			return(strsub(curInfoString,i2+1,strlen(curInfoString)-2))
		end
	end
end

Compshare(infocut)

NightLitch

thx that will alot. but take a look here:

Here
//NL

[NL]Pur

with all respect too NightLitch
and chilla but this are all min share scripts.

and i don't think angelsanges has requested that.

Quotethat disconnect users that do not  have file  up to 2 gb in share?

my guess is that he wants ppl that share 2 gig+ files

pHaTTy

huh, hmmm so like an image etc
Resistance is futile!

c h i l l a

#12
well one gets drifted away and finds something new ;).

well angelsanges...  I guess one can't do what you want.

SMF spam blocked by CleanTalk