when u have a quote bot and u lazy to access to ur bot and set ramdom play quote, this is a simple snippet that let's u on ur ramdom play quote with out accessing ur bot.
Note: this tigger can only be on by same ip as bot, becouse some ppl may off it using !quote
on 1:TEXT:*:#:{
if ($1 == !Quotes) {
if ($2 == start) {
set %addressnick $remove($address($nick,2),*!*@)
set %addressme $remove($address($me,2),*!*@)
if (%addressnick = %addressme) {
if (%quotesystemstatus == off) {
/set %quotesystemstatus on
/set %totalquotes $lines(C:\quotes.txt)
/set %quoteline $rand(0,%totalquotes)
.timerquote 0 300 msg # (# $+ %quoteline $+ ) $!read(C:\quotes.txt, %quoteline)
}
else {
.notice $nick Sorry Owner. You already start the Quote System! if you wan to stop pls type !Quotes Stop.
}
}
else {
.notice Sorry You are not my owner.
}
}
elseif ($2 == add) {
set %addressnick $remove($address($nick,2),*!*@)
set %addressme $remove($address($me,2),*!*@)
if (%addressnick = %addressme) {
/write C:\quotes.txt $3-
}
else {
.notice Sorry You are not my owner.
}
}
elseif ($2 == stop) {
set %addressnick $remove($address($nick,2),*!*@)
set %addressme $remove($address($me,2),*!*@)
if (%addressnick = %addressme) {
/set %quotesystemstatus off
.timerquote off
}
else {
.notice Sorry You are not my owner.
}
}
}
}
DragonFlare, > if ($1 == AddQuote) { if (%Quotes == On) {You should use the handy && operator:
if ($1 == AddQuote) && (%Quotes == On) {
...
}
elseif (...) && (...) {
...
}
Why put another if statement within the else condition and halt it? (In fact, you don't need the else condition at all) You don't want your code to appear redundant. Same for the rest.
If possible, don't make the use of pipe a habit, as well as the the /halt where it's not necessary.
Edit: I see what you tried to achieve. But this will look a lot better nevertheless:
on *:text:*:#:{
tokenize 32 $strip($1-)
if ($1 == quotes) && ($2 == on) {
set %Quotes On
msg Random Quotes Activated.
}
elseif ($1 == quotes) && ($2 == off) {
msg $chan Random Quotes Are Off.
}
}
If you know regex, it can be shortened a bit further:
on $*:text:/^quotes\so(n|ff)$/iS:#:{
if ($regml(1) == n) {
set %quotes On
msg # Random Quotes Activated.
}
else {
set %quotes off
msg # Random Quotes Are Off.
}
}
Why when you could just set it as a variable like and have it triggered the way you're doing it is pointless here
On *:Text:*:#:{
var %Quote write QuoteDatabase.txt $2-
var %Read $read(QuoteDatabase.txt)
tokenize 32 $Strip($1-)
if ($1 == Quotes) { if ($2 == On) { set %Quotes On | msg Random Quotes Activated. }
else { if ($2 == Off) { set %Quotes Off | msg $chan Random Quotes Are Off. }
}
}
if ($1 == AddQuote) { if (%Quotes == On) { %Quote | msg $chan $2- Added. }
else { if (%Quotes == Off) { Halt }
}
}
if ($1 == Quote) { if (%Quotes == On) { msg chan %Read }
else { if (%Quotes == Off) { Halt }
}
}
}
Simple Bot Code Without the Hassle.
And don't use /'s in scripts they look better without them