Congratulator MarkII - Trivia House

General Concepts

There are three scripts that work together:
  • Capturing the player name
  • Randomly selecting the format
  • Randomly Colouring the output
  • Requirements

    Basic Requirement
  • Simple alias and remote scripting skills
  • Identify mIRC editor and various
  • Using the layered alias and remote views
  • Listening to all Events


  • Advanced requirements
  • Loading or intergrating scripts
  • Editing dynamic variables
  • Adding global Variables
  • Modifying scripts
  • Passing parameters



  • Basic Scripting

    Capturing the player name.

    The origins of this script arose simply becuase I wanted congratulate players and it was distracting. Typing 'wd' alone was not enough so I decided to quickly add a method of capturing the players name and making the congrats more personal. It was easy to do and quite a satisfying solution. This was quite simple, in to Remote tab of the mIRC editor I added the following 3 lines:

    ON 1:TEXT:*answered the question*:*: {
      set %answered $2
    }

    The script listens for an Events trigger for text in a channel containing "answered the question" and then sets a global variable to the second parameter of the line ($2). Once this variable is set, it is available to aliases and other scripting. At this point you can check the Variables tab of the mIRC editor to see if the %answered variable is set, using this technique alone free's the need to assign scripts to a player specifically. It's wise to grasp the concept of using a variable before u proceed with using dynamic. variables

    Example:

    /f6 say wd %answered $+ !!

    NOTE: You must have Events checked in the "listen" menu of the mIRC Editor.


    Advanced Scripting

    The Variables

    ;Congratulator MarkII Remote script 'playername answered' variable
    %answered blis

    ;Congratulator MarkII Script Variables
    %mycongrats %congrat[5b]
    %thecongrats wd
    %congratrand 5
    %thetempcongrats !! §¤*~`~*¤§

    ;Congratulator MarkII Random Banners
    %congrat[1a] wd
    %congrat[1b] !!
    %congrat[2a] nj
    %congrat[2b] !!
    %congrat[3a] bravo
    %congrat[3b] !!
    %congrat[4a] gj
    %congrat[4b] !!
    %congrat[5a] §¤*~`~*¤§ nice one
    %congrat[5b] !! §¤*~`~*¤§
    %congrat[6a] ,-*'^'~*-,._.,-*~> bravo
    %congrat[6b] <~*-,._.,-*~'^'~*-,
    %congrat[7a] "¨°º©o.,,.o©º° wtg
    %congrat[7b] !! °º©o.,,.o©º°¨"
    %congrat[8a] ·´¯`·.¸ gj
    %congrat[8b] !! ¸.·´¯`·
    %congrat[9a] wtg
    %congrat[9b] !!
    %congrat[10a] nice one
    %congrat[10b]

    ;Congratulator Custom banners
    %congrat[rowdy1] Nice one Rowds
    %congrat[mjs1] Nice one Mjs!

    ;Colourit Variable
    %act say
    %len wd blis !!
    %colourtext .12w.10d .6b.7l.3i.5s .13!.13!
    %monotext wd blis !!
    %count 11

    Random output format

    After a while, 'wd' %answered alone was becomming monotonous on my part, so I decided to vamp up the /f6 script with a method that uses what we know as an 'array' in the programming world. mIRC allows for string like array variables that I've used in conjuction with %answered to use for a custom format for a specific player. Using a numbered set of dynamic variables I then setup 10 random output formats that I use if a custom format has not been set. Each of the 10 random formats uses two variables, 'part a' for the header and part 'b' for the trailer, answered is bound by these variables.

    /f6 {
    ;Trivia_house thankyou banners
    ;Custom banner definitions %congrat[CustomUSername]
    ;Random banner definitions %congrat[1a] %answered %congrat[1b] - see remote scripts for trap
    ;Get the custom header for the $nick
    %mycongrats = % $+ congrat $+ $chr(91) $+ %answered $+ ]
    %thecongrats = $eval(%mycongrats,2)

    ;If there are no (Null) custom thankyou's, select a random one.
    if ( %thecongrats == $null ) {
      %congratrand = $rand(1,10)

      ;Get the first header using random select
      %mycongrats = % $+ congrat $+ $chr(91) $+ %congratrand $+ a $+ ]
      %thetempcongrats = $eval(%mycongrats,2)
      %thecongrats = $eval(%thetempcongrats)

      ;Embed the %answered variable
      %mycongrats = %answered
      %thecongrats = %thecongrats $+ $chr(32) %mycongrats

      ;Footer/Trailer attachment.
      %mycongrats = % $+ congrat $+ $chr(91) $+ %congratrand $+ b $+ ]
      %thetempcongrats = $eval(%mycongrats,2)
      %thecongrats = %thecongrats $+ $chr(32) $+ $eval(%thetempcongrats)

      ;Colour it using the colour script
      ;/colourit %thecongrats
      ;%thecongrats = %colourtext
    }
    /say %thecongrats

    Integrating Colour

    From there I branched to a modified version of my colour script that sets a global variable %act and %colourtext and used this script to colour the output from the random formatter. Note the semicolons in the formatter script are present. The colour script has beem updated to allow for numeric values, all be it they change if too bright, also note that if the parameter supplied to /colourit begins with a Ctrl-K it will skip the routine.
    /colourit {
    if ($1 == msg) { %act = msg $2 | %len = $3-99 | goto script }
    elseif ($1 == notice) { %act = notice $2 | %len = $3-99 | goto script }
    elseif ($1 == me) { %act = me | %len = $2-99 | goto script }
    elseif ($1 == part) { %act = part $2 | %len = $3-99 | goto script }
    elseif ($1 == sound) { %act = sound $2 | %len = $3-99 }
    elseif ($1 == ame) { %act = ame | %len = $2-99 | goto script }
    elseif ($1 == echo) { %act = echo | %len = $2-99 | goto script }
    elseif ($1 == amsg) { %act = amsg | %len = $2-99 | goto script }
    elseif ($1 == onotice) { %act = onotice Ops on # $+ : | %len = $2-99 | goto script }
    else { %act = say | %len = $1-99 | goto script }
    :script

    %monotext = $replace(%len,$chr(32),$chr(160))
    %count = 1
    var %monochar = $mid(%monotext,%count,1)

    ; Skip routine if precoloured
    if (%monochar == $chr(3)) {
    %colourtext = %len
    goto endcolour
    }

    %colourtext = ""
    :startcolour
    var %monochar = $mid(%monotext,%count,1)
    set %randcol $rand(1,15)
    var %backcol 1 + %randcol
    if (%count <= $len(%len)) {
    if (%monochar isnum || %monochar == $chr(3) || %monochar == , || %monochar == $chr(160) ) {
    set %colourtext %colourtext $+ %monochar
    set %count %count + 1
    goto startcolour
    }
    if (%randcol // 2) {
    set %colourtext %colourtext $+ .
    }
    set %colourtext %colourtext $+ $chr(3) $+ %randcol %monochar
    set %count %count + 1
    goto startcolour
    }
    ;Replace bright colours hence why Peeps99 = Peeps66
    %colourtext = $remove(%colourtext,$chr(32))
    %colourtext = $replace(%colourtext,$chr(160),$chr(32))
    %colourtext = $replace(%colourtext,8,7)
    %colourtext = $replace(%colourtext,9,6)
    %colourtext = $replace(%colourtext,11,10)
    %colourtext = $replace(%colourtext,15,14)

    :endcolour
    set %colourtext %colourtext
    set %act %act
    }

    /c {
    /colourit $1-
    /say %colourtext
    }