PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: [NL]trucker on 01 December, 2003, 11:52:31

Title: anti flooder/connection script
Post by: [NL]trucker on 01 December, 2003, 11:52:31
hello you fine scripters.

i would like to have a script that prevents users to log in
more than a specific numbers of times .

the problem i have is that i get flooded by messages
like user xxx has connected
      user xxx  has been disconnected

so i want a script that allows users to log in 3-5 times per minut and after that he gets tempbanned for trying to do that more times.

with a message to the user why he is tempbanned.

like you have been tempbanned for trying to log in more then x times pro minut.
Title:
Post by: [NL]trucker on 02 December, 2003, 12:14:57
please is someone gonna look into this request??

i reeeeeeeeaaaaaaaaly would like to have it :-)))
Title:
Post by: plop on 02 December, 2003, 12:37:36
QuoteOriginally posted by [NL]trucker
please is someone gonna look into this request??

i reeeeeeeeaaaaaaaaly would like to have it :-)))
it's allready in my future 2do list, odin also requested it.
but it's not in a hurry yet.
so maby some1 else can do it or wait for my version if/when it is released.
gotta find a decent way 2 do it 1st.

plop
Title:
Post by: pHaTTy on 02 December, 2003, 19:01:55
hmm not mucg time, one in G-5 will be so much bettr but here a qucik one ;)



--quick anti hammer v1 by Phatty
--will reset on scripts restart


function Main()
Bot = "GoD"
lucifer = {}
hammeramount = 5
end

function NewUserConnected(jesus)
if lucifer[user.sName]==nil then
lucifer[user.sName]=1
elseif lucifer[user.sName]==hammeramount then
user:Ban()
SendPmToOps(Bot,user.sName.." has been lucified for hammering the server")
else
lucifer[user.sName]=lucifer[user.sName]+1
end
end


l8rr,,

-phatz
Title:
Post by: plop on 02 December, 2003, 19:31:06
i gues in G-5 there whill be a timer 2 reset the count, because this version whill ban every1 after 5 attempts  even if it's over a 5 day period.

plop
Title:
Post by: pHaTTy on 02 December, 2003, 19:46:53
he he he yep like i said it quick he he he


G-5 if the user has been in hub for over 10mins they will be reset, but, only thing, im having lots a truble with huge timer.................:/
Title:
Post by: plop on 02 December, 2003, 20:51:29
how about this. ??

--quick anti hammer v1 by Phatty
--will reset on scripts restart
-- reset every 10 mins without timer by plop

function Main()
Bot = "GoD"
lucifer = {}
hammeramount = 5
end

function NewUserConnected(jesus)
if lucifer[user.sName]==nil then
lucifer[user.sName]=1
elseif lucifer[user.sName]==hammeramount then
user:Ban()
SendPmToOps(Bot,user.sName.." has been lucified for hammering the server")
else
lucifer[user.sName]=lucifer[user.sName]+1
end
end

function DataArrival(user, data)
   if HomeMadeTimer ~= strfind(date("%M"), "^%d") then
      HomeMadeTimer = strfind(date("%M"), "^%d")
      lucifer = nil
      lucifer = {}
   end
end
works as a timer 2 reset every 10 mins.
you can also move it 2 the NewUserConnected so it's procest a bit less.

plop
Title:
Post by: [NL]trucker on 02 December, 2003, 21:30:57
thnx folks

one question left how to make sure he gets a message to with the reason?

is it with :
SendPmToUser(Bot,user.sName..") "you have been tempbanned for connecting more than x times pro min."
Title:
Post by: plop on 02 December, 2003, 22:07:52
is this like you want it ??

--quick anti hammer v1 by Phatty
--will reset on scripts restart


function Main()
Bot = "GoD"
lucifer = {}
hammeramount = 5
time = 20 -- mins duration of the ban
end

function NewUserConnected(jesus)
if lucifer[user.sName]==nil then
lucifer[user.sName]=1
elseif lucifer[user.sName]==hammeramount then
SendPmToOps(Bot,user.sName.." has been lucified for hammering the server")
      user:SendPM(Bot, "you have been tempbanned for "..time.." min, because of connecting more than "..hammeramount.." times in 10 min. |")
      user:TimeBan(time)
else
lucifer[user.sName]=lucifer[user.sName]+1
end
end

function DataArrival(user, data)
   if HomeMadeTimer ~= strfind(date("%M"), "^%d") then
      HomeMadeTimer = strfind(date("%M"), "^%d")
      lucifer = nil
      lucifer = {}
   end
end
plop
Title:
Post by: [NL]trucker on 02 December, 2003, 22:56:42
yep you hit the spot plop


but i get this error message in ptotax

Syntax error: attempt to index global `user' (a nil value)
stack traceback:
   1:  function `NewUserConnected' at line 12 [file `E:\ptotaxbuild15.16\scripts\anti-hammer.lua']
Title:
Post by: pHaTTy on 02 December, 2003, 23:03:50
loool


--quick anti hammer v1 by Phatty
--will reset on scripts restart


function Main()
Bot = "GoD"
lucifer = {}
hammeramount = 5
time = 20 -- mins duration of the ban
end

function NewUserConnected(user)
if lucifer[user.sName]==nil then
lucifer[user.sName]=1
elseif lucifer[user.sName]==hammeramount then
SendPmToOps(Bot,user.sName.." has been lucified for hammering the server")
      user:SendPM(Bot, "you have been tempbanned for "..time.." min, because of connecting more than "..hammeramount.." times in 10 min. |")
      user:TimeBan(time)
else
lucifer[user.sName]=lucifer[user.sName]+1
end
end

function DataArrival(user, data)
   if HomeMadeTimer ~= strfind(date("%M"), "^%d") then
      HomeMadeTimer = strfind(date("%M"), "^%d")
      lucifer = nil
      lucifer = {}
   end
end

Title:
Post by: pHaTTy on 02 December, 2003, 23:06:12
hmm im not to sure about the homemade timer it tho....:/
Title:
Post by: pHaTTy on 02 December, 2003, 23:09:19
hmmm


--quick anti hammer v1 by Phatty
--will reset on scripts restart


function Main()
Bot = "GoD"
lucifer = {}
hammeramount = 5
time = 20
SetTimer(10*60000)
end

function OnTimer()
ResetCounter()
StopTimer()
end

function ResetCounter()
lucifer = {}
SendPmToOps(Bot,"Hammer counter has been reset")
end

function NewUserConnected(user)
if lucifer[user.sName]==nil then
lucifer[user.sName]=1
elseif lucifer[user.sName]==hammeramount then
SendPmToOps(Bot,user.sName.." has been lucified for hammering the server")
      user:SendPM(Bot, "you have been tempbanned for "..time.." min, because of connecting more than "..hammeramount.." times in 10 min. |")
      user:TimeBan(time)
StartTimer()
else
lucifer[user.sName]=lucifer[user.sName]+1
end
end

Title:
Post by: plop on 03 December, 2003, 01:25:36
QuoteOriginally posted by [NL]trucker
yep you hit the spot plop


but i get this error message in ptotax

Syntax error: attempt to index global `user' (a nil value)
stack traceback:
   1:  function `NewUserConnected' at line 12 [file `E:\ptotaxbuild15.16\scripts\anti-hammer.lua']
loooooooooooooooooooool
blame phatty.
function NewUserConnected(jesus)
jesus instead of user

phatty give it a try, i'm using the same here on my registered user cleaner and it's working great.
had 2 find something as freeslots used the timer alllready.
[00:00] <-Bure-> The cleaner has been called. Every registered user who hasn't been in the hub for 4 weeks will be deleted. (contact the OP's if your gone be away for a period longer then that)
as you can see it triggers on midnight there as i use the change of date.
programing = 80% creativety and 20% knowledge.
if you don't got an idea... you don't get to the programming.
%M minute (48) [00?59]
as you can see it always returns 2 numbers, i'm using the 1st number wich as everybody knows changes every 10 minutes.
try it, maby it can solve your problems on G-5.

plop
Title:
Post by: pHaTTy on 03 December, 2003, 10:49:33
hmm thx i will sure take a close look :)
Title:
Post by: pHaTTy on 03 December, 2003, 10:57:36
well actually i can show you a trick, i am using my timer for many things loool, chatbot, freeslots, and sharechecker and some others, its about sending different data, and setting diferr settings,

if setting == 1 then


dataarival

if cmd = "freeslots" then
setting = 1
whatevr then at end of the freeslots you nil the setting ;)


l8r
Title:
Post by: [NL]trucker on 03 December, 2003, 11:40:26
hello plop and phatty

it seems the last update did it:-))

working good now thanks all.
Title:
Post by: pHaTTy on 03 December, 2003, 12:44:04
your welcome m8 :)
Title:
Post by: kepp on 05 December, 2003, 18:00:54
You don't mind if i implente this do ya? :)
Title:
Post by: pHaTTy on 05 December, 2003, 18:52:36
well sure i certainly dont mind at all dont think plop does neither if you take his version yep :))
Title:
Post by: plop on 05 December, 2003, 18:58:35
every piece of code i post here on the forum may be used by every1 on every way he/she likes.
no need 2 ask, if you like it use it, or modify it 2 your needs.

plop
Title:
Post by: kepp on 05 December, 2003, 19:39:58
Thanks, Just to be sure....
Ofcorse i'll make a comment that i got the idea or that it was based on yours :D