mIRC Homepage
Posted By: NXwolf C++ and MIRC - 19/09/10 05:02 AM
I'm new to the programming world of MIRC. I know some C++ which is what I'mt rying to work with.

basically, I'd like to know if I can design and create programs using C++ code that can interact with MIRC channels. I know enough about MIRC that I've created scripts for it using mrc files and such, but I want to add some more things such as a timer to some scripts and don't know how with MIRC, but do know with C++.

If this is possible, how would I go about making a program that can read from say "a game server admin channel" and perform several task's that I want it to do. Such as, one of the things I'd like to create is a program that once a person in game types !pollendgame, that people can start to type out !vote yes/no and have a tally done on it. From the moment !pollendgame was read on IRC, the program would have 30 seconds before it would end, tally up the votes, and do the appropreate action based on the votes.

A lot of the things I'd like to create are based on a timer and incrementing a variable. I know how to do all this with C++, but I don't know how to get a C++ program to read and recognize data from IRC.

Thanks for any help you can offer.
Posted By: firefox Re: C++ and MIRC - 19/09/10 06:42 AM
you would probably need a dll for c

you csn do most stuff in mirc though

read the manual and download some scripts to see how they are

then post here when you need help
Posted By: Masoud Re: C++ and MIRC - 19/09/10 07:53 AM
Well, for what you just described you need 2 things:
1) Making the trigger with 'ON TEXT' event

Note: You have two ways to declare a variable: (Variable sign in mIRC is '%')
A) Using '/set'; It makes the variable GLOBAL and you can use it in other functions and events.
B) Using '/var'; It makes the variable LOCAL and it will be automatically unset after the function/event reachs the end.

Another note: You don't need to use '/' within your code. But you can use DOT '.' to make some commands SILENCE

Code:
on *:Text:*:*:{
  ; First i should say that you can use semicolon ';' to make a comment in your script.

  ; Let's begin:
  ; $1 means the FIRST WORD, $2 means the second WORD and .... for more info type /help $1- in your mIRC.
  if ($1 == !pollendgame) && (%inProcess != $true) {
    ; We are declaring 4 variables with the first trigger which is !pollendgame.
    ;   1) %inProcess to check if the vote is already in process.
    ;   2 & 3) %Positive and %Negative to counting the votes. We giving a '0' when we declaring them.
    ;   4) %VoteChannel which contains the Channel name.
    ; /help /set and /help /var
    set %inProcess $true
    set %Positive 0
    set %Negative 0

    ; $chan means that channel which caused the event trigger.
    set %VoteChannel $chan

    ; Here we sending a message to channel to let the users know that a vote is started and they should !vote. /help /msg
    msg $chan For vote type !vote Yes/No

    ; We're executing a timer which will send the result to channel and unset the variables.
    ; Timers may have a name. If you don't specify a name then the next timer that you execute will be
    ; replaced to the old one.
    ; Timer usage: /timer[N/name] [-cdeomhipr] [time] <repetitions> <interval> <command>
    ; Those parts in [] means they're optional and <> means you should define them.
    ; For more info /help /timer
    ; Here we telling the timer to execute the 'EndVote' function ONE TIME after 30seconds
    ; (Like you said: "the program would have 30 seconds before it would end".
    .timerVOTE 1 30 /EndVote

    ; And 'return' i'm sure that you know what it does...
    return
  }
  elseif ($1 == !vote) && ($2 == Yes || $2 == No) && (%inProcess) {
   ; $calc means Calculator for more info /help $calc
   ; Also for increasing and decreasing you can use /inc and /dec the it would be: /inc %Positive
   ; /help /inc and /help /dec.
    if ($2 == Yes) { set %Positive $calc(%Positive + 1) }
    elseif ($2 == No) { set %Negative $calc(%Negative + 1) }
  }
}

2) A function that will send the result to channel and makes our operation done:
(Of course, you can write the codes in the /timer then you don't need any functions. But i wrote it like this to be more understandable.)


Code:
alias EndVote {
  ; Here we're sending the result to channel and unsetting the used variables.
  msg %VoteChannel Vote results > Positive: %Positive -- Negative: %Negative
  unset %inProcess
  unset %Positive
  unset %Negative
  unset %VoteChannel
}

What i just wrote for you was so basic. It can be improved to make it better/shorter with more options.

Don't forget to read the mIRC's help file, it's fair enough to start and being expert in mIRC Scripting...

I hope this would help you to figure out how you should write code in mIRC Script. (Sorry about my English if it wasn't so good...)
© mIRC Discussion Forums