mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2019
Posts: 7
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Mar 2019
Posts: 7
Hello,
I'm trying to make a script that echos the first 3 lines of the output of the comand /names #channel.

I've being guessing of geting the output of names command into a variable, but I don't know how to do it.

I supose there's a better way to do it.

Any help or tip is welcome.

Thank you in advance.
Miguel

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Why only the first 3 lines?

Is it a channel that you're already in? If so, you can just use $nick(#,%i) to iterate though them.

RAW 353:*: { } will fire for each line of names listings

RAW 366:*: { } will fire for End of /Names List.

Use /debug -p @debug


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Mar 2019
Posts: 7
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Mar 2019
Posts: 7
I want to make a command to execute it in the status window. Let's say I want to print the first N lines of the names output of the M input arguments of the command:

/mycommand #chan1 #chan2 ... #chanM 4

The output should be the first 4 lines of the /names output of the M channels.

Another option could be to print the last M users connected to each channel.

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Are these channels that you are already joined to, or are these channels that you are sitting outside of?


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Mar 2019
Posts: 7
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Mar 2019
Posts: 7
In principle these are channels I'm sitting outside of.

Joined: Apr 2018
Posts: 83
E
Babel fish
Offline
Babel fish
E
Joined: Apr 2018
Posts: 83
I too don't understand why you only want the 1st 3 lines.

I also dont understand why you find this difficult.
Code:
 
; set line counter to 1 and then only echo the lines 1-3
; to the status window. Use haltdef to prevent mIRC
; from sending any line to status window.
; needs to be set at some point -- say @ raw 001
On raw 001 :*: {
   Set %LineCounter 1
}

On raw 353:*: {
   if (%LineCounter <= 3) { //echo -s $1- }
   inc %LineCounter
   haltdef
}

; reset counter to 1 ready for next channel
On raw 366:*: { %LineCounter = 1 }


Of course this will affect any usage of the /names command, so you could set a variable in your 'mycommand' which you test for in the above on raw events, then reset that variable at the end of your command, to allow for normal usage.

Last edited by Erasimus; 22/03/19 07:19 PM.
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Not every network outputs RAW 001. Use On Connect instead to initialize your variables.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Mar 2019
Posts: 7
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Mar 2019
Posts: 7
The final objective is to get the last users connected to several channels in only one command invokation.

I'm new to mirc scripting. That's why I find this difficult eek

Thank you for your help.

Joined: Apr 2018
Posts: 83
E
Babel fish
Offline
Babel fish
E
Joined: Apr 2018
Posts: 83
Ooops, I forgot something from the last part of the code I gave.
Code:
; reset counter to 1 ready for next channel
On raw 366:*: { 
   %LineCounter = 1
   haltdef
}


As stated in the comments at the start of the previous code I detailed, haltdef tells mIRC to NOT display it's default output from the raw 366 message, namely the 'End of /NAMES list.'

Sorry about that .. I was coding on the fly at the time of my previous posting

Joined: Mar 2019
Posts: 7
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Mar 2019
Posts: 7
I'm a bit confused ... I was trying to make a function in the Aliases window, but I cannot see any piece of code with that syntax (On raw ...) ... So I don't know where I'm suppose to include that code confused

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
aliases window can only hold aliases, without the alias keyword. The alt+R remotes tab can have aliases, as well as events, so the ON events go there.

Good reading on various topics here

Joined: Mar 2019
Posts: 7
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Mar 2019
Posts: 7
So after reading a bit and reading your code, I think I cannot do what I mean.

With your code, what I get is first 3 lines of names command everytime I invoke /names command.

What I wanted is to create a command (or alias) with which I get first 3 lines of names of each channel is input as argument of that command, but all the users are output if the normal /names command is used.

I don't know if inside a alias (or a command) I can set a flag variable that I can read inside a raw event to decide wether to output all the lines of names or only the first 3 ...

Joined: Apr 2018
Posts: 83
E
Babel fish
Offline
Babel fish
E
Joined: Apr 2018
Posts: 83
You missed a bit from my 1st post in this thread:
Quote:
Of course this will affect any usage of the /names command, so you could set a variable in your 'mycommand' which you test for in the above on raw events, then reset that variable at the end of your command, to allow for normal usage.


If I remeber correctly your alias is called 'MyCommand'. In there set a variable to 1 and at the end of that alias set it to 0 (zero). Into that section On Raw 353

You put a test of that variable and only execute the code I wrote if it is true (i.e. is equal to 1).

Change things to this as an example
Code:
On raw 001 :*: {
   Set %LineCounter 1
}

On raw 353:*: {
   if (%MyTrigger) {
      if (%LineCounter <= 3) { //echo -s $1- }
      inc %LineCounter
      haltdef
   }
}

; reset counter to 1 ready for next channel
On raw 366:*: { 
   if (%MyTrigger) {
      %LineCounter = 1
      haltdef
   }
}


Now your My command will set %MyTrigger to 1, and any name commands that the alias sends will only get the 1st 3 lines displayed, and when all channels have been processed, you alias sets %MyTrigger to 0. If you then type /names #<whatever> the 'if %MyTrigger' will be false and those lines about %linecounter and haltdef are not executed.

Last edited by Erasimus; 09/04/19 06:39 PM.
Joined: Mar 2019
Posts: 7
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Mar 2019
Posts: 7
Thank you!!

Now it's much clearer smile


Link Copied to Clipboard