PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: angelsanges on 22 January, 2004, 09:54:37

Title: help....
Post by: angelsanges on 22 January, 2004, 09:54:37
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
Title:
Post by: BlazeXxX on 22 January, 2004, 11:07:10
You mean minimum share of 2GB?
Title:
Post by: Pedro on 22 January, 2004, 12:26:43
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
------------------------------------------------------------------------
Title:
Post by: Pedro on 22 January, 2004, 12:30:03
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
Title:
Post by: NightLitch on 22 January, 2004, 12:35:26
Well yes, but you need to check the MyInfoString... :-)
Title:
Post by: NightLitch on 22 January, 2004, 13:06:20
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.
Title:
Post by: c h i l l a on 22 January, 2004, 13:20:54
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.
Title:
Post by: NightLitch on 22 January, 2004, 13:38:07
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.
Title:
Post by: c h i l l a on 22 January, 2004, 13:53:24
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)
Title:
Post by: NightLitch on 22 January, 2004, 14:03:32
thx that will alot. but take a look here:

Here (http://board.univ-angers.fr/thread.php?threadid=1127&boardid=6&styleid=1&sid=3ca21ca2c39c7200faed675b661d3943&page=1#1)
Title:
Post by: [NL]Pur on 28 January, 2004, 00:32:44
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
Title:
Post by: pHaTTy on 28 January, 2004, 06:42:14
huh, hmmm so like an image etc
Title:
Post by: c h i l l a on 28 January, 2004, 09:32:24
well one gets drifted away and finds something new ;).

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