International Saimoe League Forums


Discussion forum for all ISML matters

Tutorial: mIRC Scripting

Everything else, off-topic. Share your thoughts on sports, news, politics, school, gardening, stamp collecting, etc...

Tutorial: mIRC Scripting

Postby KholdStare88 » Fri Jul 24, 2009 2:35 am

Scripting is fun! It will be much easier if you have previous scripting experience of any kind, whether it be BASIC on your TI-83 or VisualBasic in your CIS 105 class. But if not, then why are you even here?

Lessson 1: How Scripts Work

Anyways, the first basic principle is nesting, or levels. This is basically the order of commands in a script. For example, here is a sample script:

Code: Select all
on *:INPUT:#: {
  if ($1 == !quote) && ($2 != $null) {
    msg $chan $1-
    quote $2-
    haltdef
  }
  if ($1 == !quote) && ($2 == $null) {
    set %quote.text $gettok($read(" $+ $scriptdir $+ quotes.txt $+ "),1,124)
    msg $chan $chr(91) $+ 1 $+ / $+ $lines(" $+ $scriptdir $+ quotes.txt $+ ") $+ $chr(93) %quote.text
    unset %quote*
  }
}


Notice how each level is tabbed in, with the left-most one being executed first. For this script, here is the order: (don't worry if you don't understand the explanations)

1) on *:INPUT:#: {

-This means the script is activated if I say something

2) if ($1 == !quote) && ($2 != $null) { }
2) if ($1 == !quote) && ($2 == $null) { }

-Next, the script checks for these two conditions. If the first condition is true, then it does:

3) msg $chan $1-
3) quote $2-
3) haltdef

-If the second condition is true, then the script will do:

3) set %quote.text $gettok($read(" $+ $scriptdir $+ quotes.txt $+ "),1,124)
3) msg $chan $chr(91) $+ 1 $+ / $+ $lines(" $+ $scriptdir $+ quotes.txt $+ ") $+ $chr(93) %quote.text
3) unset %quote*

-If none of the above conditions are satisfied, then the script will do nothing, even though it was activated.

Now here's the second important part, and that is brackets. Notice that for every { you have, there is a } on the same level. For example:

Code: Select all
on *:INPUT:#: {
  whatever {
    whatever
    whatever
    sup dudes
  }
}


Notice how at the same tabbed position, a command that opens with { has to end with } at that same tabbed position. Well, this is important. Also, as common sense might suggest, you have to close all brackets or else the script will break badly. Now that you know the basics, let's do some basic scripting.
User avatar
KholdStare88
Statistician
Statistician
 
Posts: 4452
Joined: 17 Feb 2009
Worships: Sakagami Tomoyo
Cookies: 1
2013 Nova Favorite: Shirakiin Ririchiyo
2013 Stella Favorite: Yui-nyan
Wish: Miniwa Tsumiki to win ISML

Re: Tutorial: mIRC Scripting

Postby KholdStare88 » Fri Jul 24, 2009 2:35 am

Lesson 2: Triggering Events

To activate a script, something has to be triggered. The most common way to way to trigger a script is:

Code: Select all
on *:TEXT:*:#: {


This means that a message from someone else will activate your script. If you don't know yet, * is a wildcard meaning "everything." If you might have guessed, the event trigger above will be activated when anyone says anything. The first * has to do with users which are slightly complicated, so always leave it as *. The second * can specify which text you want to trigger your script, but it's clumsy and just leave it as *. The # means all channels. You can change this to:

Code: Select all
on *:TEXT:*:#isml: {


...and that script will only activate if the text is said in #isml. Note that this doesn't specify the server, so as long as there is a channel called #isml it will activate.

You notice that you are opening a bracket { in a non-tabbed position. This is important. At some point in the script, you will have to close it.

So then, what do you want to script? Let's say you want to say something every time someone says the word "gay" in any channel. Now we use what is called an if-check:

Code: Select all
on *:TEXT:*:#: {
  if (gay isin $1-) {


Note that we are in another level, which means one tab. (We say tab but in reality we're actually moving in 2 spaces.) This means that in order for the if-check to be activated, the first level (on *:TEXT:*:#:) has to be satisfied. The on TEXT specifies that "gay" has to be something that is said in a channel, not over a query, not in an emote, and can't be something you yourself typed in.

Now let's look at the if-check, which is a statement. Every time you use if, you open a parenthesis. The isin is called an operator. The $1- is called an identifier, and it stands for the whole line that someone said. The if statement says, "if the word 'gay' is in all of what someone says, then do something." So what are we doing?

Code: Select all
on *:TEXT:*:#: {
  if (gay isin $1-) {
    msg $chan No, you're gay.
  }
}


The command itself is in the third level, which means both the first and second levels have to be satisfied for the script to output "No, you're gay." to the channel. Notice that I closed both parentheses at their respective levels. That indicates that I'm done with the if-check and also done with the event. If you are wondering, msg is how to type to the channel using scripts, and $chan is an idenfier which stands for the channel that activated the script. If you are in #isml and someone said gay in #yumsauce, then the response will be outputted to #yumsauce.

Now what if you want to trigger off another word? You have to watch the placement of your next if-check:

Code: Select all
on *:TEXT:*:#: {
  if (gay isin $1-) {
    msg $chan No, you're gay.
  }
  if (fuck isin $1-) {
    msg $chan Watch your language you fucking retard.
  }
}


The next if-check is place after the first }, which means that it is not part of the last if-check. The gay is something else and the fuck is something else. But don't be confused. If the sentence has both gay and fuck, then both both messages will be outputted. If the sentence only has fuck, then only the second message will be outputted. But if the script is:

Code: Select all
on *:TEXT:*:#: {
  if (gay isin $1-) {
    msg $chan No, you're gay.
    if (fuck isin $1-) {
      msg $chan Watch your language you fucking retard.
    }
  }
}


Then the second message won't be outputted unless the first statement is satisfied. In short, if the sentence only has gay, then the script will say the first message. If the sentence has both gay and fuck, then the script will say both messages. But if the sentence only has fuck, then nothing happens, because the gay if-check has to be satisfied. This is why if you are finished with an if statement, then close its bracket.

Other event triggers include:

on *:ACTION:*:#: { }
-The event will trigger on an emote (/me).
on *:INPUT:#: { }
-The event will trigger only on things you type in.
on *:JOIN:#: { }
-The event till trigger when someone joins the channel.
on *:BAN:#: { }
-The event will trigger when someone is banned.
on *:MODE:#: { }
-The event will trigger when a channel mode is change.
User avatar
KholdStare88
Statistician
Statistician
 
Posts: 4452
Joined: 17 Feb 2009
Worships: Sakagami Tomoyo
Cookies: 1
2013 Nova Favorite: Shirakiin Ririchiyo
2013 Stella Favorite: Yui-nyan
Wish: Miniwa Tsumiki to win ISML

Re: Tutorial: mIRC Scripting

Postby KholdStare88 » Fri Jul 24, 2009 2:36 am

Lesson 3: Making a WB Message

If you didn't understand any of the above lessons, then you can still do this. Basically, the format is:

Code: Select all
on *:JOIN:#: {
  if ($nick == someone1) {
    msg $chan <WB $nick WB>: You're gay
    optional
  }
  elseif ($nick == someone2) {
    msg $chan <WB $nick WB>: You're gay
    optional
  }
}


For example:
(make sure to scroll down in the CODE box)

Code: Select all
on *:JOIN:#: {
  if ($nick == $me) {
    msg $chan <WB $nick WB>: KholdStare has arrived~
  }
  elseif ($nick == Aleri) {
    msg $chan <WB $nick WB>: Lolol emo girl.
  }
  elseif ($nick == Basaka) {
    msg $chan <WB $nick WB>: Get a new Internet service plz.
  }
  elseif ($nick == Ichigo-Sora) {
    msg $chan <WB $nick WB>: Hi hi, IchiSora-chan~
    .describe $chan hugs $nick gently.
  }
  elseif ($nick == kevo) {
    msg $chan <WB $nick WB>: How many times have you fapped today?
  }
}


It's pretty easy. Just keep adding elseif, open bracket, put message, and close bracket to add another person. What if a person uses two nicks?

Code: Select all
on *:JOIN:#: {
  if ($nick == $me) {
    msg $chan <WB $nick WB>: KholdStare has arrived~
  }
  elseif ($nick == Aleri) || ($nick == Cecaniah) {
    msg $chan <WB $nick WB>: Lolol emo girl.
  }
}


Just like you guessed, || stands for "or" in mIRC scripting. What the script is saying is:

1) If someone joins the channel,
2) and that person is not yourself (indicated by elseif),
2) and that person is Aleri or Cecaniah,
3) msg $chan <WB $nick WB>: Lolol emo girl.

What if you want a random message?

Code: Select all
on *:JOIN:#: {
  if ($nick == $me) {
    msg $chan <WB $nick WB>: KholdStare has arrived~
  }
  elseif ($nick == Aleri) || ($nick == Cecaniah) {
    var %aleri = $rand(1,3)
    if (%aleri == 1) { msg $chan <WB $nick WB>: Lolol emo girl. }
    if (%aleri == 2) { msg $chan <WB $nick WB>: Get a life. }
    if (%aleri == 3) { msg $chan <WB $nick WB>: Have you thrown a fit today yet? }
  }
}


The difference between = and == is that = stores to a variable while == means equality. Also, note that we did not enter after some of the brackets (but we still had to close them). We use enter to organize the script. While using enter, tabbing, or brackets are not required, we use them so the script is easy to understand and be changed later on.

The script is saying:

1) If someone joins the channel,
2) and that person is not yourself,
2) and that person is Aleri or Cecaniah,
3) Randomize 1-3 and store it in variable %aleri
3) If %aleri is 1, msg $chan <WB $nick WB>: Lolol emo girl.
3) If %aleri is 2, msg $chan <WB $nick WB>: Get a life.
3) If %aleri is 3, msg $chan <WB $nick WB>: Have you thrown a fit today yet?
User avatar
KholdStare88
Statistician
Statistician
 
Posts: 4452
Joined: 17 Feb 2009
Worships: Sakagami Tomoyo
Cookies: 1
2013 Nova Favorite: Shirakiin Ririchiyo
2013 Stella Favorite: Yui-nyan
Wish: Miniwa Tsumiki to win ISML

Re: Tutorial: mIRC Scripting

Postby KholdStare88 » Fri Jul 24, 2009 2:36 am

Lesson 4: Some Scripting Tools

. (period)
-This indicates a command. It is optional, but is often used to clarify a script. It doesn't work with msg.

%
-This indicates a variable that the user specifies.

$
-This indicates an identifier. An identifer is usually a value or string that mIRC assigns automatically or after a calculation.

var x = %y
-This command stores something to a temporary variable.

||
-This indicates "or" in a statement.

&&
-This indicates "and" in a statement.

Code: Select all
on *:JOIN:#: {
  if ($nick == $me) && ($chan == #isml) {
    msg $chan <WB $nick WB>: KholdStare has arrived~
  }
}


In the code above, the message will trigger if the nick is me AND if I joined #isml and not another channel.

$1
-The first word in a line

$2
-The second word in a line

$1-
-The entire line

$2-
-The entire line except for the first word

$null
-blank, has no value

==
-equals

!=
-not equal to

$calc
-perform a calculation (this is not a command but an identifier)

I will add more later. If you have a question, please read the help file.
User avatar
KholdStare88
Statistician
Statistician
 
Posts: 4452
Joined: 17 Feb 2009
Worships: Sakagami Tomoyo
Cookies: 1
2013 Nova Favorite: Shirakiin Ririchiyo
2013 Stella Favorite: Yui-nyan
Wish: Miniwa Tsumiki to win ISML

Re: Tutorial: mIRC Scripting

Postby KholdStare88 » Fri Jul 24, 2009 2:36 am

Lesson 5: Example Scripts

Note:  are color codes. For example, 4 makes the text red on mIRC.

Code: Select all
on *:TEXT:*:#: {
  if ($1 == !moe) && ($2 != $null) {
    var %moe.total $calc($lines(" $+ $scriptdir $+ ismlmoe.txt $+ ") - 1)
    if ($read(" $+ $scriptdir $+ ismlmoe.txt $+ ",w,* $+ $2- $+ *)) && ($2 !isnum) {
      var %moe.contestant $read(" $+ $scriptdir $+ ismlmoe.txt $+ ",$readn)
      var %moe.rank $calc($readn - 1)
      msg $chan 4 $+ %moe.contestant is ranked3 $chr(35) $+ %moe.rank $+ /12 $+ %moe.total on6 $me $+ 's moe list.
    }
    if ($2 isnum 1- $+ %moe.total $+ ) && ($3 == $null) {
      var %moe.contestant $read(" $+ $scriptdir $+ ismlmoe.txt $+ ",$calc($2 + 1))
      var %moe.rank $2
      msg $chan 4 $+ %moe.contestant is ranked3 $chr(35) $+ %moe.rank $+ /12 $+ %moe.total on6 $me $+ 's moe list.
    }
    if (!$read(" $+ $scriptdir $+ ismlmoe.txt $+ ",w,* $+ $2- $+ *)) && ($2 !isnum) { msg $chan That 4character is not moe enough to be on6 $me $+ 's moe list. }
  }
}


1) If someone says something
2) If the first word is !moe and the second word is not blank (there has to be something after !moe)
3) Store one less than the number of lines in ismlmoe.txt in variable %moe.total

3) If everything after !moe is matched in the text file and the second word is not blank
4) Store the line in the text file (in this case just a name) to variable %moe.contestant based on the result of the last search.
4) Store the rank of the character to variable %moe.rank after a calculation
4) Display the message to the channel

3) If the second word in a number between 1 and variable %moe.total
4) Store the character with that rank in variable %moe.contestant
4) Store the rank of the character as the second word
4) Display the message to the channel

3) If everything after !moe doesn't yield a match in the text file
4) Display the message to the channel

Code: Select all
on *:TEXT:$(* $+ $me $+ *):*: {
  .echo -s $nick ( $+ $time $+ ) $+ : $1-
}


1) If someone says something with my nick in it
2) Echo the line to the status window along with the time

Code: Select all
on *:ACTION:$(* $+ hugs $me $+ *):*: {
  .timerpet 1 2 .describe $chan hugs $nick back.
}


1) If someone hugs my nick
2) Two seconds later, emote hug that person back

Code: Select all
on *:INPUT:#: {
  if (touka-sama == $me) && ($chr(47) !isin $1) && ($chr(33) !isin $1) && (%triv != on) && (%triv.single != on) {
    msg $chan $1- $iif($rand(1,5) = 1,~desu wa,)
    haltdef
  }
}


1) If I say something
2) If my nick is Touka-sama
2) and $chr(47), which is !, is not in the message
2) and $chr(33), which is /, is not in the message
2) and variable %triv is not on
2) and varaible %triv.single is not on
3) Output my message with a 20% chance of including ~desu wa.
3) Force the script to halt

Code: Select all
on *:TEXT:*:#: {
  if ($1 == !calc) && ($2 != $null) {
    var %answer $calc($2-)
    msg $chan %answer
  }
}


1) If someone says something
2) If the first word is !calc and the second word is not blank
3) Execute and store the calculation in variable %answer
3) Message the channel the answer.

Code: Select all
on *:text:$(!trivia*):#: {
  if ($read(" $+ $scriptdir $+ trivia_ban.txt $+ ",w, [ *! $+ [ $address ] $+ ] )) { halt }
  if ($1 == !trivia) && ($2 == $null) && (%triv == on) { notice $nick 6Trivia3 is already on }
  if ($1 == !trivia) && (%triv.start.nickaddress == $null) && (%triv != on) && (%triv.start == $null) && (%lock.triv != on) {
    set %triv.start.nickaddress $address($nick,5)
    set %triv.start.limit $2
    msg $chan 6Trivia has been requested by3 $gettok(%triv.start.nickaddress,1,33) $+ 6! Another person must type in 3!trivia 6to initiate trivia.
    .timer.triv.start 1 300 unset %triv.start*
  }
  if ($1 == !trivia) && (%triv != on) && (%triv.start.nickaddress != $null) && ($gettok(%triv.start.nickaddress,1,33) != $nick) && ($gettok(%triv.start.nickaddress,2,33) !isin $address($nick,0)) && (%lock.triv != on) {
    .timer.triv.start off
    set %triv.chan #
    set %triv.limit $iif($round(%triv.start.limit,0) isnum 25-250,%triv.start.limit,50)
    unset %triv.start*
    set %triv.lines $lines(" $+ $scriptdir $+ current_trivia.txt $+ ")
    set %triv.total $calc($lines(" $+ $scriptdir $+ anime_trivia.txt $+ ") + $lines(" $+ $scriptdir $+ academic_trivia.txt $+ "))
    msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Trivia (3beta6) has 3Started6. Names should use 3wapuro romaji 6when applicable (3ou 6instead of 3oh 6for long 3o6). No weird 3diacritics 6needed (umlaut/cedilla/etc...). Type 3!strivia 6to stop trivia. Currently:3 %triv.lines $+ / $+ %triv.total 6questions.
    .timer.triv.champion 1 2 msg $iif(%triv.chan != $null,%triv.chan,$chan) 6The current trivia champion is3 %champion.triv $+ !
    set %triv.question $gettok(%triv.input,1,124)
    set %triv on
    notice $me Trivia is on.
    .timer.triv.new 1 5 trivia.new
    haltdef
  }
  if ($1 == !triviatop10) { trivia.top10 }
}
alias trivia.ban {
  if ($read(" $+ $scriptdir $+ trivia_ban.txt $+ ",w,$address($1,0))) {
    .timer.ban -m 1 250 msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Notice:3 $address($1,0) 6is already 3banned 6from trivia!
  }
  if ($address($1,0) != $null) && (!$read(" $+ $scriptdir $+ trivia_ban.txt $+ ",w,$address($1,0))) {
    write -il1 " $+ $scriptdir $+ trivia_ban.txt $+ " $address($1,0)
    .timer.ban -m 1 250 msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Notice:3 $address($1,0) 6has been 3banned 6from trivia!
  }
}
alias trivia.unban {
  if ($read(" $+ $scriptdir $+ trivia_ban.txt $+ ",w,$address($1,0))) {
    write -dl [ $+ [ $readn ] ] " $+ $scriptdir $+ trivia_ban.txt $+ "
    .timer.unban -m 1 250 msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Notice:3 $address($1,0) 6has been 3unbanned 6from trivia!
  }
}
alias trivia.restrict {
  if ($read(" $+ $scriptdir $+ trivia_restrict.txt $+ ",w,$address($1,0))) {
    .timer.restrict -m 1 250 msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Notice:3 $address($1,0) 6is already 3restricted 6from trivia!
  }
  if ($address($1,0) != $null) && (!$read(" $+ $scriptdir $+ trivia_restrict.txt $+ ",w,$address($1,0))) {
    write -il1 " $+ $scriptdir $+ trivia_restrict.txt $+ " $address($1,0)
    .timer.restrict -m 1 250 msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Notice:3 $address($1,0) 6has been 3restricted 6from trivia!
  }
}
alias trivia.release {
  if ($read(" $+ $scriptdir $+ trivia_restrict.txt $+ ",w,$address($1,0))) {
    write -dl [ $+ [ $readn ] ] " $+ $scriptdir $+ trivia_restrict.txt $+ "
    .timer.release -m 1 250 msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Notice:3 $address($1,0) 6is no longer 3restricted 6from trivia!
  }
  if ($1 == all) {
    write -c " $+ $scriptdir $+ trivia_restrict.txt $+ "
    .timer.release -m 1 250 msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Notice: Trivia 3restrict 6list is 3cleared $+ 6!
  }
}
alias trivia.chem {
  set %triv.question.1 $rand(151,276)
  set %triv.question.2 $rand(0,1)
  set %triv.answer.1 $iif(%triv.question.2 == 0,$round($calc((%triv.question.1 / 2) - $rand(1,9)),0),$round($calc((%triv.question.1 / 2) + $rand(1,11)),0))
  set %triv.question.3 $calc(%triv.question.1 - %triv.answer.1)
  write -dl [ $+ [ %triv.rand ] ] " $+ $scriptdir $+ current_trivia.txt $+ "
  set %triv.question $iif(%triv.question.2 == 0,12Chemistry3: How many protons are in an atom that has %triv.question.3 neutrons with an atomic mass of %triv.question.1 g/mol?,12Chemistry3: How many neutrons are in an atom that has %triv.question.3 protons with an atomic mass of %triv.question.1 g/mol?)
  msg %triv.chan 6Question:3 %triv.question
  .timer.triv.hint 1 10 msg %triv.chan 6Hint:3 proton + neutron = atomic mass
  .timer.triv.wrong 1 25 trivia.wrong
}
alias trivia.filter {
  if ($gettok($gettok($1,2,32),1,124) > $gettok($gettok($2,2,32),1,124)) return -1
  if ($gettok($gettok($1,2,32),1,124) < $gettok($gettok($2,2,32),1,124)) return 1
  if ($gettok($gettok($1,2,32),1,124) == $gettok($gettok($2,2,32),1,124)) return 1
}
alias trivia.limit {
  set %triv.limit $round($1,0)
  .timer.limit -m 1 250 msg %triv.chan 6The limit of correctly answered questions until auto-locking trivia is now3 %triv.limit $+ 6.
}
alias trivia.lock {
  set %lock.triv on
  .timer.triv.lock 1 1800 unset %lock.triv
  .timer.triv.off.msg -m 1 25 $iif(%triv == on,trivia.off,haltdef)
}
alias trivia.unlock {
  unset %lock.triv
  .timer.triv.unlock.msg -m 1 50 msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Trivia is now 3Unlocked6!
  .timer.triv.unlock off
}
alias trivia.off {
  msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Trivia has been 3Halted6!
  .timer.triv.question off
  .timer.triv.hint off
  .timer.triv.wrong off
  .timer.triv.chem off
  unset %triv*
}
alias trivia.shuffle {
  if ($1 == all) {
    filter -ffc " $+ $scriptdir $+ anime_trivia.txt $+ " " $+ $scriptdir $+ current_trivia.txt $+ " *
    filter -ff " $+ $scriptdir $+ academic_trivia.txt $+ " " $+ $scriptdir $+ current_trivia.txt $+ " *
    set %shuffle.trivia $1
    .timer.reshuffle -m 1 250 msg $chan 6Shuffling...3 $lines(" $+ $scriptdir $+ current_trivia.txt $+ ") 6questions are in queue.
  }
  if ($read(" $+ $scriptdir $+ $1 $+ _trivia.txt $+ ")) {
    filter -ffc " $+ $scriptdir $+ $1 $+ _trivia.txt $+ " " $+ $scriptdir $+ current_trivia.txt $+ " *
    set %shuffle.trivia $1
    .timer.reshuffle -m 1 250 msg $chan 6Shuffling...3 $lines(" $+ $scriptdir $+ current_trivia.txt $+ ") 6questions are in queue.
  }
  if ($1 != all) && (!$read(" $+ $scriptdir $+ $1 $+ _trivia.txt $+ ")) { .timer.reshuffle -m 1 250 msg $chan 6Incorrect format. Use: 3anime6, 3academic6, or 3all 6as arguments. }
}
alias trivia.top10 {
  if (%triv.top.prot == 1) {
    notice $nick This command cannot be used again so soon.
    halt
  }
  set %triv.top.prot 1
  .timer.triv.top.prot 1 60 unset %triv.top.prot
  filter -ffac " $+ $scriptdir $+ trivia_scores.txt $+ " " $+ $scriptdir $+ trivia_top_10.txt $+ " trivia.filter *
  set %triv.scorers $lines(" $+ $scriptdir $+ trivia_scores.txt $+ ")
  write -il1 " $+ $scriptdir $+ trivia_top_10.txt $+ " [Top10]
  write -il12 " $+ $scriptdir $+ trivia_top_10.txt $+ " [EndTop10]
  play -aq1m1tTop10 trivia.msg $chan " $+ $scriptdir $+ trivia_top_10.txt $+ " 750
}
alias trivia.msg { msg $1 6 $+ $chr(35) $+ $play($1).pos 3 $+ $gettok($2-,1,32) $+ 6: $gettok($gettok($2-,2,32),1,124) (03 $+ $gettok($gettok($2-,2,32),2,124) $+ 06,03 $+ $round($gettok($gettok($2-,2,32),3,124),1) $+ 06,03 $+ $round($calc($gettok($gettok($2-,2,32),1,124) / $gettok($gettok($2-,2,32),2,124) * 100),1) $+ % $+ 06) }
alias trivia.wrong {
  if (%triv == on) && (%lock.triv != on) {
    msg %triv.chan 6You failed to answer the question completely! 3The next question is in6 5 3seconds!
    .unset %triv.answer* %triv.part*
    .timer.triv.new 1 7 trivia.new
  }
}
alias trivia.new {
  if (%triv == on) && (%lock.triv != on) {
    if ($lines(" $+ $scriptdir $+ current_trivia.txt $+ ") == 0) {
      filter -ffc " $+ $scriptdir $+ anime_trivia.txt $+ " " $+ $scriptdir $+ current_trivia.txt $+ " *
      filter -ff " $+ $scriptdir $+ academic_trivia.txt $+ " " $+ $scriptdir $+ current_trivia.txt $+ " *
      filter -ffac " $+ $scriptdir $+ trivia_scores.txt $+ " " $+ $scriptdir $+ trivia_top_10.txt $+ " trivia.filter *
      set %shuffle.trivia all
      msg %triv.chan 6Reshuffling...3 $lines(" $+ $scriptdir $+ current_trivia.txt $+ ") 6questions are in queue.
      set %triv.champion $read(" $+ $scriptdir $+ trivia_top_10.txt $+ ",1)
      msg %triv.chan 6Congratulations to3 $gettok(%triv.champion,1,32) $+ 6, the trivia champion with3 $gettok(%triv.champion,2,32) 6points!
      set %champion.triv $gettok(%triv.champion,1,32)
      trivia.off
      halt
    }
    set %triv.lines $lines(" $+ $scriptdir $+ current_trivia.txt $+ ")
    set %triv.rand $rand(1,%triv.lines)
    set %triv.input $read(" $+ $scriptdir $+ current_trivia.txt $+ ",%triv.rand)
    set %triv.question $gettok(%triv.input,1,124)
    set %triv.timer.ticks $ticks
    if ([Math] isin %triv.question) {
      trivia.chem
      halt
    }
    set %triv.answer.temp 1
    while (%triv.answer.temp <= 6) {
      set %triv.answer. [ $+ [ %triv.answer.temp ] ] $gettok(%triv.input,$iif(%triv.answer.temp == 1,2,$calc(%triv.answer.temp + 2)),124)
      set %triv.answer.part [ $+ [ %triv.answer.temp ] ] $gettok(%triv.input,$calc(%triv.answer.temp + 1), 92)
      inc %triv.answer.temp
    }
    if (%triv.answer.6 != $null) && ( [ $chr(92) $+ [ %tripart1 ] ] !isin [ %triv.answer.6 ] ) { set %triv.answer.tally 6 }
    if (%triv.answer.6 == $null) || ( [ $chr(92) $+ [ %triv.answer.part1 ] ] isin [ %triv.answer.6 ] ) { set %triv.answer.tally 5 }
    if (%triv.answer.5 == $null) || ( [ $chr(92) $+ [ %triv.answer.part1 ] ] isin [ %triv.answer.5 ] ) { set %triv.answer.tally 4 }
    if (%triv.answer.4 == $null) || ( [ $chr(92) $+ [ %triv.answer.part1 ] ] isin [ %triv.answer.4 ] ) { set %triv.answer.tally 3 }
    if (%triv.answer.3 == $null) || ( [ $chr(92) $+ [ %triv.answer.part1 ] ] isin [ %triv.answer.3 ] ) { set %triv.answer.tally 2 }
    if (%triv.answer.2 == $null) || ( [ $chr(92) $+ [ %triv.answer.part1 ] ] isin [ %triv.answer.2 ] ) { set %triv.answer.tally 1 }
    write -dl [ $+ [ %triv.rand ] ] " $+ $scriptdir $+ current_trivia.txt $+ "
    msg %triv.chan 6Question:3 %triv.question
    set %delay.triv $calc(5 + $len(%triv.question) / 33)
    .timer.triv.hint 1 10 msg %triv.chan 6Hint:3 $gettok(%triv.input,3,124) ( $+ %triv.answer.tally $+ , $+ $iif(%triv.answer.part1 != $null,y,n) $+ )
    .timer.triv.wrong 1 25 trivia.wrong
  }
}
on *:text:*:#: {
  if ($read(" $+ $scriptdir $+ trivia_ban.txt $+ ",w, [ *! $+ [ $address ] $+ ] )) { halt }
  if ($read(" $+ $scriptdir $+ trivia_restrict.txt $+ ",w, [ *! $+ [ $address ] $+ ] )) && ($calc(($ticks - %triv.timer.ticks) / 1000) < %delay.triv) { halt }
  if ((%triv.answer.1 isin $1-) || (%triv.answer.2 isin $1-) || (%triv.answer.3 isin $1-) || (%triv.answer.4 isin $1-) || (%triv.answer.5 isin $1-) || (%triv.answer.6 isin $1-)) && ($chan == %triv.chan) {
    if ($gettok(%triv.part.nickaddress,1,33) == $nick) || ($gettok(%triv.part.nickaddress,2,33) isin $address($nick,0)) { halt }
    .timer.triv.hint off
    .timer.triv.wrong off
    if (!$read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick)) { write " $+ $scriptdir $+ trivia_scores.txt $+ " $nick 0 $+ $chr(124) $+ 0 $+ $chr(124) $+ 0 }
    set %triv.time $calc(($ticks - %triv.timer.ticks) / 1000)
    set %triv.getscore $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),1,124)
    set %triv.getanswer $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),2,124)
    set %triv.gettime $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),3,124)
    set %triv.newscore $round($calc(%triv.getscore + (1.25 - ($ticks - %triv.timer.ticks + (75 * %triv.getscore)) / 1000 / 25 * 0.65) / $iif(%triv.single == on,2,1)),1)
    set %triv.newtime $calc((%triv.getanswer * %triv.gettime + %triv.time)/(%triv.getanswer + 1))
    inc %triv.getanswer
    inc %triv.count
    write -s $+ $nick " $+ $scriptdir $+ trivia_scores.txt $+ " $nick %triv.newscore $+ $chr(124) $+ %triv.getanswer $+ $chr(124) $+ %triv.newtime
    msg %triv.chan 6You got it 3right6 for3 $calc(%triv.newscore - %triv.getscore) 6points! The answer was:3 $iif(%triv.answer.1 isin $1-,%triv.answer.1,$iif(%triv.answer.2 isin $1-,%triv.answer.2,$iif(%triv.answer.3 isin $1-,%triv.answer.3,$iif(%triv.answer.4 isin $1-,%triv.answer.4,$iif(%triv.answer.5 isin $1-,%triv.answer.5,%triv.answer.6))))) $+ 6! $+(3,$nick)$+ 6has3 %triv.newscore 6 $+ $iif(%triv.newscore == 1,point,points) $+ ! ( $+ 03 $+ $round(%triv.time,1) $+ 06 $+ )
    if (%triv.count >= %triv.limit) {
      filter -ffac " $+ $scriptdir $+ trivia_scores.txt $+ " " $+ $scriptdir $+ trivia_top_10.txt $+ " trivia.filter *
      set %triv.champion $read(" $+ $scriptdir $+ trivia_top_10.txt $+ ",1)
      msg %triv.chan 6Congratulations to3 $gettok(%triv.champion,1,32) $+ 6, the trivia champion with3 $gettok($gettok(%triv.champion,2,32),1,124) 6points!
      set %champion.triv $gettok(%triv.champion,1,32)
      set %lock.triv on
      msg %triv.chan 6Trivia is now 3Locked6!
      .timer.triv.unlock 1 1800 unset %lock.triv
      trivia.off
    }
    unset %triv.answer* %triv.part* %triv.single
    if (%triv.single != on) { .timer.triv.new 1 7 trivia.new }
  }
  elseif ((%triv.answer.part1 isin $1-) || (%triv.answer.part2 isin $1-) || (%triv.answer.part3 isin $1-) || (%triv.answer.part4 isin $1-) || (%triv.answer.part5 isin $1-) || (%triv.answer.part6 isin $1-)) && (%triv.part.nickaddress == $null) && ($chan == %triv.chan) {
    set %triv.part.nickaddress $address($nick,5)
    if (!$read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick)) write " $+ $scriptdir $+ trivia_scores.txt $+ " $nick 0
    set %triv.time $calc(($ticks - %triv.timer.ticks) / 1000)
    set %triv.getscore $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),1,124)
    set %triv.getanswer $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),2,124)
    set %triv.gettime $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),3,124)
    set %triv.newscore $round($calc(%triv.getscore + (0.55 - ($ticks - %triv.timer.ticks + (50 * %triv.getscore)) / 1000 / 25 * 0.5) / $iif(%triv.single == on,2,1)),1)
    set %triv.newtime $calc((%triv.getanswer * %triv.gettime + 0.5 * %triv.time)/(%triv.getanswer + 0.5))
    inc %triv.getanswer 0.5
    write -s $+ $nick " $+ $scriptdir $+ trivia_scores.txt $+ " $nick %triv.newscore $+ $chr(124) $+ %triv.getanswer $+ $chr(124) $+ %triv.newtime
    msg %triv.chan 6You got it 3partially right6 for3 $calc(%triv.newscore - %triv.getscore) 6points!3 $nick 6has3 %triv.newscore 6 $+ $iif(%triv.newscore == 1,point,points) $+ ! ( $+ 03 $+ $round(%triv.time,1) $+ 06 $+ )
    haltdef
  }
  if (($1 == !strivia) && (%triv == on) && (%triv.count >= 15)) || (($1 == !strivia) && (%triv != on) && (%triv.start.nickaddress != $null)) {
    if (%stop.triv. [ $+ [ $nick ] ] == 1) || (%stop.triv.address ] ] == 1) {
      notice $nick 6You cannot 3stop 6trivia again so soon.
      halt
    }
    set %stop.triv. [ $+ [ $nick ] ] 1
    set %stop.triv. [ $+ [ $address ] ] 1
    .timer.triv.stop. [ $+ [ $nick ] ] 1 900 unset %stop.triv. [ $+ [ $nick ] ]
    .timer.triv.stop. [ $+ [ $address ] ] 1 900 unset %stop.triv. [ $+ [ $address ] ]
    trivia.off
  }
  if ($1 == !tscore) {
    set %triv.score.check $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),1,124)
    set %triv.answer.check $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),2,124)
    set %triv.time.check $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),3,124)
    set %triv.getscore $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2),1,124)
    set %triv.getanswer $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2),2,124)
    set %triv.gettime $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2),3,124)
    if (%triv.getscore == $null) && ($2 != $null) { msg $iif(%triv.chan != $null,%triv.chan,$chan) 6No scores detected for3 $2 $+ 6! }
    if ($2 == $null) { msg $iif(%triv.chan != $null,%triv.chan,$chan) 6You have3 $iif(%triv.score.check == $null,0,%triv.score.check) 6 $+ $iif(%triv.score.check == 1,point,points) $+ . $iif(%triv.score.check == $null,,(03 $+ %triv.answer.check $+ 06,03 $+ $round(%triv.time.check,1) $+ 6)) }
    if ($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2)) { msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Score for3 $2 6is:3 %triv.getscore $+ 6! $iif(%triv.getanswer == $null,,(03 $+ %triv.getanswer $+ 06,03 $+ $round(%triv.gettime,1) $+ 6)) }
  }
  if ($1 == !shuffle) && (%triv.start == $null) && (%triv != on) { trivia.shuffle $2 }
  if ($1 == !queue) { .timer.questions -m 1 500 msg $chan 6There are3 $lines(" $+ $scriptdir $+ current_trivia.txt $+ ") 6questions are in queue, with3 $iif(%triv.count != $null,%triv.count,0) 6questions answered correctly out of3 $iif(%triv.limit != $null,%triv.limit,100) 6needed to auto-lock trivia. }
  if ($1 == !ban) && (protect isin $level($address)) { trivia.ban $2 }
  if ($1 == !unban) && (protect isin $level($address)) { trivia.unban $2 }
  if ($1 == !trivialock) && ($nick isop %triv.chan) && (%triv == on) { trivia.lock }
  if ($1 == !triviaunlock) && ($nick isop $chan) && (%lock.triv == on) { trivia.unlock }
  if ($1 == !limit) && ($2 isnum 25-250) && ($nick isop %triv.chan) && (%triv == on) { trivia.limit $2 }
  if ($1 == !question) && (%triv != on) && (%triv.single != on) {
    if (%prot.triv. [ $+ [ $nick ] ] == 1) {
      notice $nick Stop trying to spam me, you meanie person.
      halt
    }
    set %prot.triv. [ $+ [ $nick ] ] 1
    .timer.triv.prot. [ $+ [ $nick ] ] 1 90 unset %prot.triv. [ $+ [ $nick ] ]
    trivia.single $2-
  }
  if ($1 == !skip) && (%triv == on) && (protect isin $level($address)) {
    msg %triv.chan 6 $+ $nick has elected to skip the question!
    .unset %triv.answer* %triv.part*
    .timers off
    .timer.triv.new 1 5 trivia.new
  }
}
on *:input:#: {
  if ($1 == !trivia) {
    if (%triv != on) && (%triv.single != on) {
      unset %lock.triv
      msg $chan $1-
      set %triv.chan #
      set %triv.limit $iif($round($2,0) isnum 3-1000,$2,50)
      unset %triv.start*
      set %triv.lines $lines(" $+ $scriptdir $+ current_trivia.txt $+ ")
      set %triv.total $calc($lines(" $+ $scriptdir $+ anime_trivia.txt $+ ") + $lines(" $+ $scriptdir $+ academic_trivia.txt $+ "))
      msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Trivia (3beta6) has 3Started6. Names should use 3wapuro romaji 6when applicable (3ou 6instead of 3oh 6for long 3o6). No weird 3diacritics 6needed (umlaut/cedilla/etc...). Type 3!strivia 6to stop trivia. Currently:3 %triv.lines $+ / $+ %triv.total 6questions.
      .timer.triv.champion 1 2 msg $iif(%triv.chan != $null,%triv.chan,$chan) 6The current trivia champion is3 %champion.triv $+ !
      set %triv on
      .timer.triv.new 1 5 trivia.new
      haltdef
    }
  }
  if (($1 == !strivia) && (%triv == on)) || (($1 == !strivia) && (%triv != on) && (%triv.start.nickaddress != 1)) {
    msg $iif(%triv.chan != $null,%triv.chan,$chan) $1-
    trivia.off
    haltdef
  }
  if ($1 == !tscore) {
    msg $iif(%triv.chan != $null,%triv.chan,$chan) $1-
    set %triv.score.check $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),1,124)
    set %triv.answer.check $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),2,124)
    set %triv.time.check $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),3,124)
    set %triv.getscore $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2),1,124)
    set %triv.getanswer $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2),2,124)
    set %triv.gettime $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2),3,124)
    if (%triv.getscore == $null) && ($2 != $null) { msg $iif(%triv.chan != $null,%triv.chan,$chan) 6No scores detected for3 $2 $+ 6! }
    if ($2 == $null) { msg $iif(%triv.chan != $null,%triv.chan,$chan) 6You have3 $iif(%triv.score.check == $null,0,%triv.score.check) 6 $+ $iif(%triv.score.check == 1,point,points) $+ . $iif(%triv.score.check == $null,,(03 $+ %triv.answer.check $+ 06,03 $+ $round(%triv.time.check,1) $+ 6)) }
    if ($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2)) && ($3 isnum) && (($4 == $null) || ($4 isnum 0.5-1)) {
      inc %triv.getscore $round($3,1)
      if ($3 isnum 0.1-1.2) { inc %triv.getanswer $4 }
      write -s $+ $2 " $+ $scriptdir $+ trivia_scores.txt $+ " $2 %triv.getscore $+ $chr(124) $+ %triv.getanswer $+ $chr(124) $+ %triv.gettime
      msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Score for3 $2 6has been changed to3 %triv.getscore $+ 6! (03 $+ %triv.getanswer $+ 06,03 $+ $round(%triv.gettime,1) $+ 6)
      if (%triv.getscore == 0) { write -dl $readn " $+ $scriptdir $+ trivia_scores.txt $+ " }
    }
    if ($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2)) && ($2 != $null) && ($3- == $null) { msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Score for3 $2 6is:3 %triv.getscore $+ 6! $iif(%triv.getanswer == $null,,(03 $+ %triv.getanswer $+ 06,03 $+ $round(%triv.gettime,1) $+ 6)) }
    if ($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2)) && ($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$3)) {
      set %triv.getscore $calc($gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2),1,124) + $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$3),1,124))
      set %triv.getanswer $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2),2,124) + $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$3),2,124)
      set %triv.gettime $calc((($gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2),2,124) * $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$2),3,124)) + $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$3),2,124) * $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$3),3,124)) / %triv.getanswer)
      write -dl $readn " $+ $scriptdir $+ trivia_scores.txt $+ "
      write -s $+ $2 " $+ $scriptdir $+ trivia_scores.txt $+ " $2 %triv.getscore $+ $chr(124) $+ %triv.getanswer $+ $chr(124) $+ %triv.gettime
      msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Score for3 $2 6and3 $3 6has been consolidated to3 %triv.getscore 6for3 $2 $+ 6! (03 $+ %triv.getanswer $+ 06,03 $+ $round(%triv.gettime,1) $+ 6)
    }
    haltdef
  }
  if ((%triv.answer.1 isin $1-) && ($chan == %triv.chan) || (%triv.answer.2 isin $1-) && ($chan == %triv.chan) || (%triv.answer.3 isin $1-) || (%triv.answer.4 isin $1-) || (%triv.answer.5 isin $1-) || (%triv.answer.6 isin $1-)) && ($chan == %triv.chan) {
    msg $iif(%triv.chan != $null,%triv.chan,$chan) $1-
    .timer.triv.hint off
    .timer.triv.wrong off
    if (!$read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick)) { write " $+ $scriptdir $+ trivia_scores.txt $+ " $nick 0 $+ $chr(124) $+ 0 $+ $chr(124) $+ 0 }
    set %triv.time $calc(($ticks - %triv.timer.ticks) / 1000)
    set %triv.getscore $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),1,124)
    set %triv.getanswer $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),2,124)
    set %triv.gettime $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),3,124)
    set %triv.newscore $round($calc(%triv.getscore + (1.25 - ($ticks - %triv.timer.ticks + (75 * %triv.getscore)) / 1000 / 25 * 0.65) / $iif(%triv.single == on,2,1)),1)
    set %triv.newtime $calc((%triv.getanswer * %triv.gettime + %triv.time)/(%triv.getanswer + 1))
    inc %triv.getanswer
    write -s $+ $nick " $+ $scriptdir $+ trivia_scores.txt $+ " $nick %triv.newscore $+ $chr(124) $+ %triv.getanswer $+ $chr(124) $+ %triv.newtime
    msg %triv.chan 6You got it 3right6 for3 $calc(%triv.newscore - %triv.getscore) 6points! The answer was:3 $iif(%triv.answer.1 isin $1-,%triv.answer.1,$iif(%triv.answer.2 isin $1-,%triv.answer.2,$iif(%triv.answer.3 isin $1-,%triv.answer.3,$iif(%triv.answer.4 isin $1-,%triv.answer.4,$iif(%triv.answer.5 isin $1-,%triv.answer.5,%triv.answer.6))))) $+ 6! $+(3,$nick)$+ 6has3 %triv.newscore 6 $+ $iif(%triv.newscore == 1,point,points) $+ ! ( $+ 03 $+ $round(%triv.time,1) $+ 06 $+ )
    unset %triv.answer* %triv.part*
    .timer.triv.right -m 1 100 unset %triv.single
    if (%triv.single != on) { .timer.triv.new 1 7 trivia.new }
    haltdef
  }
  elseif ((%triv.answer.part1 isin $1-) || (%triv.answer.part2 isin $1-) || (%triv.answer.part3 isin $1-) || (%triv.answer.part4 isin $1-) || (%triv.answer.part5 isin $1-) || (%triv.answer.part6 isin $1-)) && (%triv.part.nickaddress == $null) && ($chan == %triv.chan) {
    msg $iif(%triv.chan != $null,%triv.chan,$chan) $1-
    set %triv.part.nickaddress $address($nick,5)
    if (!$read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick)) write " $+ $scriptdir $+ trivia_scores.txt $+ " $nick 0
    set %triv.time $calc(($ticks - %triv.timer.ticks) / 1000)
    set %triv.getscore $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),1,124)
    set %triv.getanswer $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),2,124)
    set %triv.gettime $gettok($read(" $+ $scriptdir $+ trivia_scores.txt $+ ",s,$nick),3,124)
    set %triv.newscore $round($calc(%triv.getscore + (0.55 - ($ticks - %triv.timer.ticks + (50 * %triv.getscore)) / 1000 / 25 * 0.5) / $iif(%triv.single == on,2,1)),1)
    set %triv.newtime $calc((%triv.getanswer * %triv.gettime + 0.5 * %triv.time)/(%triv.getanswer + 0.5))
    inc %triv.getanswer 0.5
    write -s $+ $nick " $+ $scriptdir $+ trivia_scores.txt $+ " $nick %triv.newscore $+ $chr(124) $+ %triv.getanswer $+ $chr(124) $+ %triv.newtime
    msg %triv.chan 6You got it 3partially right6 for3 $calc(%triv.newscore - %triv.getscore) 6points!3 $nick 6has3 %triv.newscore 6 $+ $iif(%triv.newscore == 1,point,points) $+ ! ( $+ 03 $+ $round(%triv.time,1) $+ 06 $+ )
    .timer.triv.right -m 1 100 unset %triv.single
    haltdef
  }
  if ($1 == !triviatop10) { trivia.top10 }
  if ($1 == !clearscore) {
    write -c " $+ $scriptdir $+ trivia_scores.txt $+ "
    .timer.clear.score -m 1 250 msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Trivia scores are cleared.
  }
  if ($1 == !shuffle) && (%triv.start == $null) { trivia.shuffle $2 }
  if ($1 == !queue) { .timer.questions -m 1 250 msg $chan 6There are3 $lines(" $+ $scriptdir $+ current_trivia.txt $+ ") 6questions are in queue, with3 $iif(%triv.count != $null,%triv.count,0) 6questions answered correctly out of3 $iif(%triv.limit != $null,%triv.limit,100) 6needed to auto-lock trivia. }
  if ($1 == !trivialock) && (%lock.triv != on) { trivia.lock }
  if ($1 == !triviaunlock) && (%lock.triv == on) { trivia.unlock }
  if ($1 == !ban) { trivia.ban $2 }
  if ($1 == !unban) { trivia.unban $2 }
  if ($1 == !restrict) { trivia.restrict $2 }
  if ($1 == !release) { trivia.release $2 }
  if ($1 == !delay) && ($2 isnum 1-20) {
    set %delay.triv $2
    .timer.delay -m 1 250 msg $iif(%triv.chan != $null,%triv.chan,$chan) 6Notice: Trivia 3restriction delay6 has been set to3 $2 $+ 6.
  }
  if ($1 == !limit) && ($2 isnum 3-1000) && (%triv == on) { trivia.limit $2 }
  if ($1 == !question) && (%triv != on) && (%triv.single != on) {
    msg $iif(%triv.chan != $null,%triv.chan,$chan) $1-
    trivia.single $2-
    haltdef
  }
  if ($1 == !banlist) { .timer.banlist -m 1 250 play -m1 " $+ $scriptdir $+ trivia_ban.txt $+ " 750 }
  if ($1 == !restrictlist) { .timer.banlist -m 1 250 play -m1 " $+ $scriptdir $+ trivia_restrict.txt $+ " 750 }
  if ($1 == !skip) && (%triv == on) {
    msg $iif(%triv.chan != $null,%triv.chan,$chan) $1-
    msg %triv.chan 6 $+ $me has elected to skip the question!
    .unset %triv.answer* %triv.part*
    .timers off
    .timer.triv.new 1 5 trivia.new
    haltdef
  }
}
alias trivia.single {
  set %triv.chan #
  set %triv.single on
  if ($1 == anime ) || ($1 == academic) || ($1 == ccs) { set %triv.stack $1 }
  else { set %triv.stack current }
  if ($lines(" $+ $scriptdir $+ current_trivia.txt $+ ") == 0) { trivia.shuffle all }
  set %triv.lines $lines(" $+ $scriptdir $+ %triv.stack $+ _trivia.txt $+ ")
  set %triv.rand $rand(1,%triv.lines)
  set %triv.input $read(" $+ $scriptdir $+ %triv.stack $+ _trivia.txt $+ ",%triv.rand)
  set %triv.question $gettok(%triv.input,1,124)
  set %triv.timer.ticks $ticks
  set %triv.answer.temp 1
  while (%triv.answer.temp <= 6) {
    set %triv.answer. [ $+ [ %triv.answer.temp ] ] $gettok(%triv.input,$iif(%triv.answer.temp == 1,2,$calc(%triv.answer.temp + 2)),124)
    set %triv.answer.part [ $+ [ %triv.answer.temp ] ] $gettok(%triv.input,$calc(%triv.answer.temp + 1), 92)
    inc %triv.answer.temp
  }
  if (%triv.answer.6 != $null) && ( [ $chr(92) $+ [ %tripart1 ] ] !isin [ %triv.answer.6 ] ) { set %triv.answer.tally 6 }
  if (%triv.answer.6 == $null) || ( [ $chr(92) $+ [ %triv.answer.part1 ] ] isin [ %triv.answer.6 ] ) { set %triv.answer.tally 5 }
  if (%triv.answer.5 == $null) || ( [ $chr(92) $+ [ %triv.answer.part1 ] ] isin [ %triv.answer.5 ] ) { set %triv.answer.tally 4 }
  if (%triv.answer.4 == $null) || ( [ $chr(92) $+ [ %triv.answer.part1 ] ] isin [ %triv.answer.4 ] ) { set %triv.answer.tally 3 }
  if (%triv.answer.3 == $null) || ( [ $chr(92) $+ [ %triv.answer.part1 ] ] isin [ %triv.answer.3 ] ) { set %triv.answer.tally 2 }
  if (%triv.answer.2 == $null) || ( [ $chr(92) $+ [ %triv.answer.part1 ] ] isin [ %triv.answer.2 ] ) { set %triv.answer.tally 1 }
  if (%triv.stack == current) { write -dl [ $+ [ %triv.rand ] ] " $+ $scriptdir $+ current_trivia.txt $+ " }
  msg %triv.chan 6Question:3 %triv.question
  set %delay.triv $calc(5 + $len(%triv.question) / 33)
  .timer.triv.hint 1 10 msg %triv.chan 6Hint:3 $gettok(%triv.input,3,124) ( $+ %triv.answer.tally $+ , $+ $iif(%triv.answer.part1 != $null,y,n) $+ )
  .timer.triv.wrong 1 25 msg %triv.chan 6You failed to answer the question completely!
  .timer.triv.single 1 26 unset %triv*
}


Trivia...
User avatar
KholdStare88
Statistician
Statistician
 
Posts: 4452
Joined: 17 Feb 2009
Worships: Sakagami Tomoyo
Cookies: 1
2013 Nova Favorite: Shirakiin Ririchiyo
2013 Stella Favorite: Yui-nyan
Wish: Miniwa Tsumiki to win ISML

Re: Tutorial: mIRC Scripting

Postby hobbes » Fri Jul 24, 2009 2:53 am

Yay! Thanks KS for posting this! I am now going to become a scripting master
Image
Image
User avatar
hobbes
Temple priestess
Temple priestess
 
Posts: 69
Joined: 17 Jul 2009
Cookies: 1

Re: Tutorial: mIRC Scripting

Postby Eater-of-All » Fri Jul 24, 2009 3:36 am

Wow, I've always known you were the anal type with scripting, but I'd never expected to see you make a tutorial about it too.


By the way, a period really indicates a command? The only instance I've ever seen of that is from .timer, and even that is pretty rare. Slashes (or the lack thereof) are much more common, so I think you should at least mention a bit of that in Lesson 4.

Also, always stress the importance of the mIRC help file. It's something you can't go a day without. :lol:

PS: I like your usage of words in Lesson 2.
User avatar
Eater-of-All
State alchemist
State alchemist
 
Posts: 1880
Joined: 18 Feb 2009
Cookies: 17

Re: Tutorial: mIRC Scripting

Postby KholdStare88 » Fri Jul 24, 2009 3:42 am

Slashes and periods are the exact same thing. They can be substituted and such. The only difference is when you paste a script to a channel, if you have a slash, it will try to execute that command. If you have a period, it will paste normally. For me, it's like a "bold." You can put it in front of a command to signify importance.

I also added the help file thing to Lesson 4, thanks.
User avatar
KholdStare88
Statistician
Statistician
 
Posts: 4452
Joined: 17 Feb 2009
Worships: Sakagami Tomoyo
Cookies: 1
2013 Nova Favorite: Shirakiin Ririchiyo
2013 Stella Favorite: Yui-nyan
Wish: Miniwa Tsumiki to win ISML

Re: Tutorial: mIRC Scripting

Postby Eater-of-All » Fri Jul 24, 2009 3:54 am

KholdStare88 wrote:Slashes and periods are the exact same thing. They can be substituted and such. The only difference is when you paste a script to a channel, if you have a slash, it will try to execute that command. If you have a period, it will paste normally. For me, it's like a "bold." You can put it in front of a command to signify importance.

Ah, I see. Just goes to show how fail I am at scripting nowadays orz.
User avatar
Eater-of-All
State alchemist
State alchemist
 
Posts: 1880
Joined: 18 Feb 2009
Cookies: 17

Re: Tutorial: mIRC Scripting

Postby chaosprophet » Fri Jul 24, 2009 9:59 pm

Thanks for this topic KS! It's very informative and interesting.
User avatar
chaosprophet
Dragon slayer
Dragon slayer
 
Posts: 2393
Joined: 18 Feb 2009
Location: Brasil
Worships: Evangeline McDowell
Cookies: 1
Wish: Negima anime adaptation done right.

Re: Tutorial: mIRC Scripting

Postby Fate » Tue Aug 04, 2009 10:25 pm

chaosprophet helped make me a Fate pic script and a welcome back script, woo.
ImageImage
ImageALL HAIL FATE T. HARLAOWN!Image
#Feitoism @ irc.rizon.net
User avatar
Fate
Shinigami
Shinigami
 
Posts: 2526
Joined: 18 Feb 2009
Location: Fate's bed
Worships: Fate Testarossa
Cookies: 32
2013 Nova Favorite: Sanka Rea
2013 Stella Favorite: Aisaka Taiga
Wish: Fate's happiness (and love & trust)

Re: Tutorial: mIRC Scripting

Postby chaosprophet » Thu Sep 24, 2009 5:14 am

Those scripting lessons were very nice, making wb is fun! Don't you agree Kholdstare?
User avatar
chaosprophet
Dragon slayer
Dragon slayer
 
Posts: 2393
Joined: 18 Feb 2009
Location: Brasil
Worships: Evangeline McDowell
Cookies: 1
Wish: Negima anime adaptation done right.

Re: Tutorial: mIRC Scripting

Postby Fate » Sat Nov 07, 2009 10:08 pm

Requesting a custom script from chaosprophet please~:

Basically the command will be !Fate select choice_a choiceb choicec and so forth
The message will respond with Fate Testarossa chooses choice_a. for example. Anyone including I can activate it.

Thanks!
ImageImage
ImageALL HAIL FATE T. HARLAOWN!Image
#Feitoism @ irc.rizon.net
User avatar
Fate
Shinigami
Shinigami
 
Posts: 2526
Joined: 18 Feb 2009
Location: Fate's bed
Worships: Fate Testarossa
Cookies: 32
2013 Nova Favorite: Sanka Rea
2013 Stella Favorite: Aisaka Taiga
Wish: Fate's happiness (and love & trust)

Re: Tutorial: mIRC Scripting

Postby harux3 » Mon Feb 01, 2010 6:16 am

Woah... @__@
Image
Image
Spoiler:
Supports: Eucliwood Hellscythe • Makise Kurisu • Tachibana Kanade • Victorique de Blois • Akiyama Mio • Shana • Katsura Hinagiku • Nagato Yuki • Irisviel von Einzbern • Fujibayashi Kyō • Saber
User avatar
harux3
Harem lead
Harem lead
 
Posts: 191
Joined: 9 Jan 2010
Location: Jyougamachi
Worships: Eucliwood Hellscythe
Cookies: 1
Wish: more hours in the day :c

Re: Tutorial: mIRC Scripting

Postby Fate » Wed Mar 24, 2010 11:15 pm

I would like to request another welcome back script message for the nick/user AnCeEp, the message is comprised of this:

<@Sakurei> I don't need to have sex to make my own porn. <@AnCeEp> I KNOW. <@AnCeEp> staring at feito is basically porn

Thanks!
ImageImage
ImageALL HAIL FATE T. HARLAOWN!Image
#Feitoism @ irc.rizon.net
User avatar
Fate
Shinigami
Shinigami
 
Posts: 2526
Joined: 18 Feb 2009
Location: Fate's bed
Worships: Fate Testarossa
Cookies: 32
2013 Nova Favorite: Sanka Rea
2013 Stella Favorite: Aisaka Taiga
Wish: Fate's happiness (and love & trust)

Re: Tutorial: mIRC Scripting

Postby Mist- » Wed Sep 08, 2010 12:09 pm

wow very helpful tutorial.. i've been using mIRC for 2 years now but never knew scripting.
thanks so much!
Image
Hitagi-san lost to Shana on first round but i don't take it hard since Shana is my favourite too! Besides, she's still new.. Someday, she will get popular, just believe it!!
User avatar
Mist-
Ninja cadet
Ninja cadet
 
Posts: 2
Joined: 8 Sep 2010
Location: Malaysia
Worships: Haruno Sakura
Cookies: 1
Wish: For now, my wish will be.. Selamat Hari Raya Aidilfitri to ALL Muslims out there! Maaf Zahir & Batin! Ahlan Wasahlan ya Syawal!

Re: Tutorial: mIRC Scripting

Postby HinagikuAyasaki » Fri Sep 24, 2010 12:40 pm

its hard to get it
Image
Spoiler:
Image
ImageImage
User avatar
HinagikuAyasaki
Shrine maiden
Shrine maiden
 
Posts: 63
Joined: 28 Aug 2010
Location: Tokyo,Japan
Cookies: 1
Wish: pretty cute president of hakuo academy go! go! go! H-I-N-A-G-I-K-U! Go!

Re: Tutorial: mIRC Scripting

Postby Cassiopeia » Sat Apr 23, 2011 1:02 pm

I give up before even trying.. oh welll i will read it through when I am free.
Image

Credit to Awesome Hikarin <3 ISML2011 FINAL <3
User avatar
Cassiopeia
Combat butler
Combat butler
 
Posts: 1057
Joined: 3 Jan 2010
Location: Ontario, Canada
Worships: Tennos "A-tan" Athena
Cookies: 1

Re: Tutorial: mIRC Scripting

Postby HeartClover » Tue Jun 07, 2011 12:26 am

uuuhhhhhhhhhh. self destruct button activated.

10...9...8....
Last edited by HeartClover on Fri Jul 01, 2011 4:14 am, edited 2 times in total.
Image
Thanks to Hikarin, Emjay, and Arctic for the sigs~
Spoiler for More Supports:
ImageImageImageImageImageImageImageImageImageImageImageImageImageImage
User avatar
HeartClover
Space cowboy
Space cowboy
 
Posts: 2886
Joined: 22 Apr 2011
Location: the internet
Worships: Edward Elric
Cookies: 31
Wish: happiness

Re: Tutorial: mIRC Scripting

Postby shiraoky » Thu Jun 23, 2011 4:33 am

o.o ....brain...overload...
Image
Thanks to M-J for the beautiful sigs<3~!
User avatar
shiraoky
Senior Member
Senior Member
 
Posts: 5253
Joined: 10 Feb 2011
Location: Candyland!
Worships: Kise Ryouta<3333
Cookies: 86
2013 Nova Favorite: Shirakiin Ririchiyo
2013 Stella Favorite: Gokō Ruri (Kuroneko)
Wish: more time to laze around and have fun!

Next

Return to General Chat

Who is online

Users browsing this forum: DurianDude and 1 guest