mIRC Home    About    Download    Register    News    Help

Print Thread
#249725 12/12/14 10:54 PM
S
SBDOnslaught
SBDOnslaught
S
Hey guys,
Keep in mind this is for Twitch.
So i need help with "timers". I've looked around and couldn't really find the same problem i was having somewhere else. Anyways, on my scripts a have, as i like to call them, anti-flooders.
Quote:
on *:text:!social:#:{
if ((%floodsocial) || ($($+(%,floodsocial.,$nick),2))) { return }
set -u10 %floodsocial On
set -u30 %floodsocial. $+ $nick On
msg $chan /me KIK Me @SBDO07 Follow me on Twitter & Instagram @YanisMT.
}

So people can't spam the command, well i have other commands that have like hour long antiflooders.. so id like to make an if statement that would tell the person how long they would have to wait before being able to use the command again.

Ex:
Me: !social
Bot: KIK Me @SBDO07 Follow me on Twitter & Instagram @YanisMT.
Me: !social
Bot: Command is ready to use in 10 seconds.
---
That type of thing.

Thank you all! laugh

#249726 12/12/14 11:36 PM
J
JuanAm
JuanAm
J
Try this:
Code:
On *:text:*:#:{
  if ($strip($1) == !social) {
    if (%floodsocial [ $+ [ $nick ] ])  { msg # $nick Command is ready to use in  $duration($calc($ctime - $v1)) | halt }
    set -u10 %floodsocial [ $+ [ $nick ] ] $ctime
    msg # KIK Me @SBDO07 Follow me on Twitter & Instagram @YanisMT. 
  }
}

#249727 13/12/14 12:01 AM
B
Belhifet
Belhifet
B
Why would you use a msg response for your antispam on a command that sends a message?

#249728 13/12/14 12:09 AM
S
SBDOnslaught
SBDOnslaught
S
The timer message isn't for that command.. like a said, i have commands that have hour long timers on them and play along side with things, like points.
So when people keep spamming the command to earn points, and let's say there's 30 minutes left, at least they'll stop spamming the command for a sort period. or lets say someone recently join chat and tries to execute the command, they'll know it's already been used and they'll have to wait.

#249729 13/12/14 12:13 AM
J
JuanAm
JuanAm
J
Originally Posted By: SBDOnslaught
The timer message isn't for that command.. like a said, i have commands that have hour long timers on them and play along side with things, like points.
So when people keep spamming the command to earn points, and let's say there's 30 minutes left, at least they'll stop spamming the command for a sort period. or lets say someone recently join chat and tries to execute the command, they'll know it's already been used and they'll have to wait.


SBDOnslaught, it worked my code?
You can change the commands and time in the -u set.

#249730 13/12/14 12:15 AM
S
SBDOnslaught
SBDOnslaught
S
JuanAm,
Seems to be working, but instead of counting down, it counts up :P

#249732 13/12/14 01:25 AM
J
JuanAm
JuanAm
J
SBDOnslaught removes the code above.


Try this:
Code:
On *:text:*:#channel:{
  if ($strip($1) == !social) {
    if ($timer(AntiFlood [ $+ [ $nick ] ]) == $null) { set %lessnums [ $+ [ $nick ] ] 10 | .timerAntiFlood [ $+ [ $nick ] ] 10 1 dec %lessnums [ $+ [ $nick ] ] }
    else { msg # $nick Command is ready to use in %lessnums [ $+ [ $nick ] ] seconds | return }
  }
  if (%lessnums [ $+ [ $nick ] ] != 0) {
    msg $chan KIK Me @SBDO07 Follow me on Twitter & Instagram @YanisMT.
    halt  
  }
}

You have to change the #channel where this bot and time is set to 10 seconds, which also can change.
On *:text:*:#channel:{
Quote:
if ($timer(AntiFlood [ $+ [ $nick ] ]) == $null) { set %lessnums [ $+ [ $nick ] ] 10 | .timerAntiFlood [ $+ [ $nick ] ] 10 1 dec %lessnums [ $+ [ $nick ] ]



You can also add multiple commands at once:

Code:
if ($strip($1) == !social) || ($strip($1) == !command2) || ($strip($1) == !command3) || ($strip($1) == !command4) {

#249735 13/12/14 03:58 AM
S
SBDOnslaught
SBDOnslaught
S
Hey JuanAm,
Would you mind explaining it so i can work with it a bit? smile
and thank you very much for the help! smile

#249739 13/12/14 11:39 AM
J
JuanAm
JuanAm
J
Originally Posted By: SBDOnslaught
Hey JuanAm,
Would you mind explaining it so i can work with it a bit? smile
and thank you very much for the help! smile


SBDOnslaught, I have given all the elements so you can work with the code.

You only need to modify the items marked in red.
#channel = channel where will the bot.
10 = the seconds expected the user running the command to rerun again .

The time must be modified in both places mentioned in the variable %lessnum and the timerAntiFlood.

$strip = ignores the format of colors, bold, underline, etc

[$ [$ Nick]] = customizes the timer for each user running the command.

dec = decrease the variable countdown to 1 second.

Originally Posted By: SBDOnslaught
The timer message isn't for that command.. like a said, i have commands that have hour long timers on them and play along side with things, like points.
So when people keep spamming the command to earn points, and let's say there's 30 minutes left, at least they'll stop spamming the command for a sort period. or lets say someone recently join chat and tries to execute the command, they'll know it's already been used and they'll have to wait.

If you want the antiflood not be customized for each user running the command, being that when executed by a user can not do another user until after the scheduled time, you must remove the code, all identifiers [$ [$ Nick]].
30 minutes = 1800 seconds

Example:
Code:
On *:text:*:#channel:{
  if ($strip($1) == !point) {
    if ($timer(AntiFlood) == $null) { set %lessnums 1800 | .timerAntiFlood 1800 1 dec %lessnums }
    else { msg # $nick the command has already been used, will be ready to use in $int($calc(%lessnums / 60)) minutes | return }
  }
  if (%lessnums != 0) {
    msg $chan You can now use the !point.
    halt  
  }
}


$int($calc(%lessnums / 60))= returns the integer part of the result of the arithmetic operation of dividing seconds between 60, to return me the minutes.

If you want to add more commands to antiflood, eg commands !play, !stats, you must change line 2.

Code:
if ($strip($1) == !point) || ($strip($1) == !play) || ($strip($1) == !stats) {


|| = or

I think it has all the elements to work with the code.

To learn how this code is assembled, I advise you to enter in your mIRC:
/help if then else
/help on text
/help timers
/help variables
/help identifiers

Last edited by JuanAm; 13/12/14 12:57 PM.
#249742 13/12/14 03:05 PM
Joined: Jan 2004
Posts: 1,330
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,330
This functionality all exists in /set and $duration.

Code:
on *:text:!social:#:{ 
  if (%floodsocial) || (%floodsocial. [ $+ [ $nick ] ]) {
    var %max = $iif(%floodsocial > %floodsocial. [ $+ [ $nick ] ],$v1,$v2)
    msg # Command cannot be used for $duration(%max)
    return
  }
  set -z %floodsocial 10
  set -z %floodsocial. $+ $nick 30
  msg $chan /me KIK Me @SBDO07 Follow me on Twitter & Instagram  @YanisMT.
}

S
SBDOnslaught
SBDOnslaught
S
You guys were a great help! Thank you so much! laugh <3


Link Copied to Clipboard