mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2016
Posts: 1
M
Mostly harmless
OP Offline
Mostly harmless
M
Joined: Jul 2016
Posts: 1
I'm new in mIRC programming, so i need a script that add +1 in the chat command, like this:
user types: !cry
the bot respond with: "streamer nick" cried (the count of the times) times!


Last edited by ManoZulu; 09/07/16 05:00 AM.
Joined: Jun 2015
Posts: 84
F
Babel fish
Offline
Babel fish
F
Joined: Jun 2015
Posts: 84
I think this should work.

Code:
on *:TEXT:!cry:#: {
 if (%flood.cries) || ($nick != $mid(#,2) { halt } 
 if (!%cries) { 
  set %cries 1
  msg # $mid(#,2) has started crying for the first time! 
 }
 set -u5 %flood.cries On
 inc %cries
 msg # $mid(#,2) cried %cries times!
} 


This will check if the variable %cries exists, and if it doesn't, then it'll create it and give the "silly" message, with any uses after being the standard "cried X times".

This should also set a global 5 second cooldown as to keep the spam down to more "reasonable" amounts.


For more details about how it works, try /help /inc and /help /var.
(I recommend /help /var since it shows details on how incrementing worked. It's better to global set a variable otherwise if you're going to keep track. /help /set for details there.)

Last edited by Fonic_Artes; 09/07/16 07:32 AM. Reason: Added /help suggestions
Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
Code:
on *:TEXT:!cry:#: {
 if (%flood.cries) || ($nick != $mid(#,2) return
 inc %cries
 if (%cries == 1) msg # $mid(#,2) has started crying for the first time! 
 else msg # $mid(#,2) cried %cries times!
 set -u5 %flood.cries On
}
You weren't using /else for your /if, meaning it would first set %cries to 1 and immediately increment it to 2 for one !cry. I also removed /set, you can simply use /inc on a non existing variable and it will create a global variable. Changed /halt to /return because halt is meaningless inside an event, it will simply act as a return, however /return most likely involves less steps.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard