PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: (????H??v?????v?L????) on 09 September, 2004, 19:44:28

Title: Max passive users
Post by: (????H??v?????v?L????) on 09 September, 2004, 19:44:28
Hi,

Is there a script that can limit the amout of passive users in a hub, like set the user limit to say 300 and only allow 50 passive users (example)

Can this be done, would be very nice :)

Thanx HeavensDevil :)
Title:
Post by: bastya_elvtars on 09 September, 2004, 21:23:18
Hi!

This does not do a save, script restart will reset it, so careful! (Save would introduce a fake number and passive users could not log in.)
OPs arent checked.

-- maximum passive by bastya_elvtars, written for (??^(o)?He^a*ve^n~??e^v?L?^(o)??)

Bot="PassiveKiller"

maximum=50 -- max nuber of passive users that can be in the hub simultaneously

-- please dont edit below

loggedinpassive={}

function NewUserConnected(user)
if checknumber() if strfind (user.sMyInfoString,"M:P") then
loggedinpassive[user]=1
end
elseif checknumber()==maximum then
user:SendData(Bot,"No more passive users accepted, there are already "..maximum.." logged in!")
end
end

function UserDisconnected(user)
if loggedinpassive(user) then
loggedinpassive[user]=nil
end
end

function checknumber()
local arr={}
for a,b in loggedinpassive do
tinsert(arr,a)
end
return getn(arr)
end

Title:
Post by: bastya_elvtars on 09 September, 2004, 23:46:12
I said this before (and will have to i know) that you should give feedbacks even if its works good. My self-confidence won1t be destroyed then ^^
Title: error
Post by: (????H??v?????v?L????) on 20 September, 2004, 19:41:36
ello,

i keep getting this error :(


Syntax error: attempt to call global `loggedinpassive' (a table value)
stack traceback:
   1:  function `UserDisconnected' at line 43 [file `...\0.330.b15.25.dbg\scripts\max passive users.lua']
Title:
Post by: Herodes on 20 September, 2004, 20:52:27
Watch out for this small typo ;)
function UserDisconnected(user)
if loggedinpassive[b][[/b]user[b]][/b] then
loggedinpassive[user]=nil
end
end