Reinitializing a Timer...
 

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

Reinitializing a Timer...

Started by xjr13sp, 29 January, 2004, 16:07:06

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

xjr13sp

Hi,

I have troubles to finish a little script. This script is to manage Flood in the CC. It works ok, but I'd like to add a Timer (because if I say 3x the same word in a range time of 1 or 2 min it's ok, but if I do that in a range time of 10 hours it is not good) but I don't know how to do :-/

If you could help me... thx :-)

max
	
4
	
-- 
nb maxi de r?p?tition avant action
table
	
= {}
sec
	
1000
min
	
60 sec


warnmsg 
"Merci de ne pas flooder..."
kickmsg "Flood..."

function Main()
	
SetTimer(10000)
	
--
SetTimer(min)
	
StartTimer()
end

function DataArrival(userdata)
	
if 
strsub(data11) == "<" and not user.bOperator then
	
	
local sestr strfind(data"^%b<> (.*)|$")
	
	
return 
check(userstr)
	
end
end


function check(userstr)
	
local tmpret table[user.sName] or {}
	
if 
tmp[1] ~= str then
	
	
tmp = { str}
	
else
	
	
tmp[2] = tmp[2] + 1
	
	
if 
tmp[2] == max 1 then
	
	
	
user:SendData("Hub-Security"warnmsg)
	
	
elseif 
tmp[2] == max then
	
	
	
user:Kick(kickmsg)
	
	
	
SendPmToOps("Hub-Security"user.sName.." a ?t? kick? pour flood. Il a dit : ["..str.."] "..max.." fois")
	
	
	
tmpret nil1
	
	
end
	
end table[user.sName] = tmp
	
return 
ret
end

function OnTimer()
	
table nil 
end

NightLitch

just a hint for clearing the table:

function OnTimer()
    table = nil
    table = {}
end
//NL

NightLitch

otherwise I find no problems in your script for maybe the calculation you wanna do with the time.
//NL

NightLitch

#3
here is for your calculation:


Sec    = 1000
Min    = 60 * sec

function Main()
   SetTimer(5 * Min)
   StartTimer()
end
//NL

xjr13sp

Thank you NightLitch :)

xjr13sp

After testing, here is my problem:

1- I say 3 times "test"
2- I get the message in field warnmsg
3- I wait for the re-init of the Timer and the Table
4- After re-init, I say 3 times again "test"
5- I get the message in field warnmsg and I'm disconnected... I don't understand why because I haven't a user:disconnected in the script  ?(

At step 4 if I say something different of at step 1, I'm not disconnected...

NightLitch

Well one other guess can maybe be that you have a low number
in hubsoft than is detecting spamming.
either turn it off 0 in both boxes or set it a little bit higher than you have now.

just a guess...
//NL

VidFamne

Was thinking of this line;
local tmp, ret = table[user.sName] or {}
Shouldnt it be like this or something
local tmp, ret = table[user.sName] or {}, 0

SMF spam blocked by CleanTalk