PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: enema on 23 September, 2004, 20:15:52

Title: Passive users have 2 x bigger min share
Post by: enema on 23 September, 2004, 20:15:52
Hi!

I know, I probably keep smart side of the forum bussy all the time with my freekin' ideas, but I was drinkin beer and I noticed, that I have to many passive users... Hate that s*it... So I figured out, that it would be cool, if the passive users would have 2 x bigger min share than active users.... Or something like that. Is it possible???

P.S.

I am learning how to make scripts on my own, so maybe like 6 months later I will give you more of my weird ideas already finished... who knows  ;)
Title:
Post by: bastya_elvtars on 23 September, 2004, 21:49:23
Hope this is what you need...

minshareforpassive=1 -- min. share for passive users in Gigabytes

--- code below, dont edit

function NewUserConnected(user)
if strfind(user.sMyInfoString,"M:P") then
seeshare(user)
return 1
end
end

function DataArrival(user,data)
if strsub(data, 1, 7) == "$MyINFO" then
if strfind(user.sMyInfoString,"M:P") then
seeshare(user)
return 1
end
end
end

function seeshare(user)
local _,_,shareinbytes=strfind(user.sMyInfoString, "$(%d+)%$")
if shareinbytes user:SendData(" You do not meet the share minimum for passive users. You are being disconnected.")
user:Disconnect()
end
end
Title:
Post by: enema on 25 September, 2004, 11:08:05
It doesnt work :( Thats probably because Im using RoboCop.... Maybe creators of robocop will include this feature in further robocop editions....
Title:
Post by: NightLitch on 25 September, 2004, 13:40:50
haven't tried it but it should work...

-------------------------------------------------
-- Works like this:
-- Enter RC_MinShare for users
-- The Share will double for passive users
-------------------------------------------------
-- By: NightLitch (2004)
-------------------------------------------------
RC_MinShare = "1 GB"
-------------------------------------------------
-- Don't edit --
-------------------------------------------------
sUnit = {}
sUnit["KB"]= 1024
sUnit["MB"]= 1048576
sUnit["GB"]= 1073741824
sUnit["TB"]= 1099511627776

function Main()
   if tonumber(RC_MinShare) == nil then s,e,num,cur = string.find(RC_MinShare, "(%d+)%s+(%S+)") RC_MinShare = num * sUnit[cur] end
end

function DataArrival(user,data)
if strsub(data, 1, 7) == "$MyINFO" then
if strfind(data,"M:P") then
local _,_,share = (data, "(%d+)%$%|$")
if tonumber(share) < tonumber(RC_MinShare * 2) then
user:SendData(" You do not meet the minimum share for passive users. You are being disconnected.")
user:Disconnect()
return 1
end
end
end
end
Title:
Post by: enema on 26 September, 2004, 15:31:57
nope, somethings wrong

Syntax error: `)' expected;
  last token read: `,' at line 25 in string "-------------------------------------------------
..."
Title:
Post by: nErBoS on 26 September, 2004, 18:03:41
Hi,

Found some bug, try ou this...

-------------------------------------------------
-- Works like this:
-- Enter RC_MinShare for users
-- The Share will double for passive users
-------------------------------------------------
-- By: NightLitch (2004)
-------------------------------------------------
RC_MinShare = "1 GB"
-------------------------------------------------
-- Don't edit --
-------------------------------------------------
sUnit = {}
sUnit["KB"]= 1024
sUnit["MB"]= 1048576
sUnit["GB"]= 1073741824
sUnit["TB"]= 1099511627776

function Main()
   if tonumber(RC_MinShare) == nil then s,e,num,cur = strfind(RC_MinShare, "(%d+)%s+(%S+)") RC_MinShare = num * sUnit[cur] end
end

function DataArrival(user,data)
if strsub(data, 1, 7) == "$MyINFO" then
if strfind(data,"M:P") then
local _,_,share = strfind(data, "(%d+)%$%|$")
if tonumber(share) < tonumber(RC_MinShare * 2) then
user:SendData(" You do not meet the minimum share for passive users. You are being disconnected.")
user:Disconnect()
return 1
end
end
end
end

Best regards, nErBoS
Title:
Post by: NightLitch on 26 September, 2004, 19:36:13
nice thanks nErBoS, I forgot to change some parts from Lua 5 to Lua 4. hehe
Title:
Post by: nErBoS on 26 September, 2004, 19:47:24
Hi,

hehe i have notice that. I have to start playing with Lua 5 as well.

Best regards, nErBoS
Title:
Post by: enema on 28 September, 2004, 19:25:58
thanks guys, youre the best ;)
Title:
Post by: enema on 28 September, 2004, 19:27:24
btw, I dont wanna sound like a lamer, but what is lua 5 or lua 4 that you are talking about???
Title:
Post by: NightLitch on 28 September, 2004, 21:39:02
QuoteOriginally posted by enema
btw, I dont wanna sound like a lamer, but what is lua 5 or lua 4 that you are talking about???

different version of Lua, the programming language PtokaX uses...

PtokaX use: Lua 4.0.1

BCDC use: Lua 5.0.2

/NightLitch
Title:
Post by: Modifier on 30 November, 2004, 10:54:37
Hi.

i like that script and it worked fine, but is there any way to add an option so it doesn't check VIP or OP share.
i was looking script like that for long time and was glad to find it    :)
Title:
Post by: bastya_elvtars on 30 November, 2004, 11:37:36
QuoteOriginally posted by Modifier
Hi.

i like that script and it worked fine, but is there any way to add an option so it doesn't check VIP or OP share.
i was looking script like that for long time and was glad to find it    :)

to which?
Title:
Post by: Modifier on 30 November, 2004, 11:47:00
that passive users minshare script, so it doesn't check passive OPs and VIPs share.
I have couple OP who are passive but i don't want that they have to share cause one of them is also hubowner and she want to keep her upload speed free for the hub.


hope you understand, cause my english ain't so good
Title:
Post by: Modifier on 30 November, 2004, 21:03:47
Could somebody help me for that script ?
Title:
Post by: Madman on 30 November, 2004, 21:35:49
Try This.... =)
-------------------------------------------------
-- Works like this:
-- Enter RC_MinShare for users
-- The Share will double for passive users
-------------------------------------------------
-- By: NightLitch (2004)
-- Modded By Madman (2004)
-- Check What Profiles
-- Based On NightLitch's Ultimate Client Check
-------------------------------------------------
RC_MinShare = "1 GB"
-------------------------------------------------
-- Check What Profiles?
-------------------------------------------------
User = 1
Reg = 1
Vip = 0
Op = 0
Master = 0
-------------------------------------------------
-- Don't edit --
-------------------------------------------------
sUnit = {}
sUnit["KB"]= 1024
sUnit["MB"]= 1048576
sUnit["GB"]= 1073741824
sUnit["TB"]= 1099511627776

Profiles = {
[-1] = 1, -- regular user
[3] = 2, -- registered user
[2] = 3,  -- vip user
[1] = 4, -- operator
[0] = 5, -- master/admin
}

Check = {
[1] = {[1] = User},
[2] = {[1] = Reg},
[3] = {[1] = Vip},
[4] = {[1] = Op},
[5] = {[1] = Master},
}

function Main()
   if tonumber(RC_MinShare) == nil then s,e,num,cur = strfind(RC_MinShare, "(%d+)%s+(%S+)") RC_MinShare = num * sUnit[cur] end
end

function DataArrival(user,data)
if Check[Profiles[user.iProfile] ][1]==1 then
if strsub(data, 1, 7) == "$MyINFO" then
if strfind(data,"M:P") then
local _,_,share = strfind(data, "(%d+)%$%|$")
if tonumber(share) < tonumber(RC_MinShare * 2) then
user:SendData(" You do not meet the minimum share for passive users. You are being disconnected.")
user:Disconnect()
return 1
end
end
end
end
end
Title:
Post by: Modifier on 01 December, 2004, 06:16:36
Thank you for that.   :)
Title:
Post by: Modifier on 01 December, 2004, 11:15:25
It gives me some error when it has been on for a couple of minutes ?

Syntax error: table index is nil
stack traceback:
   1:  function `DataArrival' at line 50
Title:
Post by: Madman on 01 December, 2004, 16:12:16
I know what makes the error...
Do you run Robocop or some other big bot?
if not RC then open my the Profiles.dat in Notepad and copy everything in it...
Then i can fix the error =)
Title:
Post by: Modifier on 01 December, 2004, 16:15:33
i have RC9.0C running, is that what cause that error ?
Title:
Post by: Madman on 01 December, 2004, 16:21:03
Kind of...
I Added The Profiles
NetFounder and Moderator

-------------------------------------------------
-- Works like this:
-- Enter RC_MinShare for users
-- The Share will double for passive users
-------------------------------------------------
-- By: NightLitch (2004)
-- Modded By Madman (2004)
-- Check What Profiles
-- Based On NightLitch's Ultimate Client Check
-- Added RC Profiles
-------------------------------------------------
RC_MinShare = "1 GB"
-------------------------------------------------
-- Check What Profiles?
-------------------------------------------------
User = 1
Reg = 1
Vip = 0
Op = 0
Master = 0
Moderator = 0
NetFounder = 0
-------------------------------------------------
-- Don't edit --
-------------------------------------------------
sUnit = {}
sUnit["KB"]= 1024
sUnit["MB"]= 1048576
sUnit["GB"]= 1073741824
sUnit["TB"]= 1099511627776

Profiles = {
[-1] = 1, -- regular user
[3] = 2, -- registered user
[2] = 3,  -- vip user
[1] = 4, -- operator
[0] = 5, -- master/admin
[4] = 6,   -- Moderator
[5] = 7,   -- NetFounder
}

Check = {
[1] = {[1] = User},
[2] = {[1] = Reg},
[3] = {[1] = Vip},
[4] = {[1] = Op},
[5] = {[1] = Master},
[6] = {[1] = Moderator},
[7] = {[1] = NetFounder},

}

function Main()
if tonumber(RC_MinShare) == nil then s,e,num,cur = strfind(RC_MinShare, "(%d+)%s+(%S+)") RC_MinShare = num * sUnit[cur] end
end

function DataArrival(user,data)
if Check[Profiles[user.iProfile] ][1]==1 then
if strsub(data, 1, 7) == "$MyINFO" then
if strfind(data,"M:P") then
local _,_,share = strfind(data, "(%d+)%$%|$")
if tonumber(share) < tonumber(RC_MinShare * 2) then
user:SendData(" You do not meet the minimum share for passive users. You are being disconnected.")
user:Disconnect()
return 1
end
end
end
end
end
Title:
Post by: Modifier on 01 December, 2004, 16:23:51
Thanks, i'll test it now