mIRC Home    About    Download    Register    News    Help

Print Thread
need help to get variable text and send it in chat #253215 01/06/15 01:54 AM
Joined: Jun 2015
Posts: 4
T
Truc Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Jun 2015
Posts: 4
Hello, I need some help with this little script plz.
I made this from topic I read
Quote:
on *:text:*whatever - Type !take* to whatever.:#: if ($nick == MyNickName) { msg # !take* }



Here is my goal, there is a number behind this * at the end of !take and I need to copy paste this number in my msg or copy paste the whole !take(with the number ofc)

It's a number from 1 to 99.

If anyone could help me please.
Thankyou for your time.

Last edited by Truc; 01/06/15 01:55 AM.
Re: need help to get variable text and send it in chat [Re: Truc] #253217 01/06/15 04:56 AM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Can you give an example sentence and what you want to capture from it?

Re: need help to get variable text and send it in chat [Re: Sakana] #253224 01/06/15 12:26 PM
Joined: Jun 2015
Posts: 4
T
Truc Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Jun 2015
Posts: 4
thx for your answer there is a full example

- 1 - Bot > Truc drop an Item - Type !take10 to take the Item.

- 2 - Trucluc > !take10

So, someone drop and item and bot answer with a number from 1 to 99 at the end of !take, then someone esle can write !take10 to take the Item.

Re: need help to get variable text and send it in chat [Re: Truc] #253225 01/06/15 12:51 PM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Ok, this should capture a number from 0-99. At the moment I can't think of a way to capture 1-99 using only regex, but this will exit if the number is 0, so basically the same thing

Code:
on *:TEXT:*:#: {
if ($regex($1-,/^!take([1-9]?[0-9])$/i)) { 
var %number = $regml(1) 
if (%number == 0) { return }

}

}

Last edited by Sakana; 01/06/15 12:59 PM.
Re: need help to get variable text and send it in chat [Re: Sakana] #253226 01/06/15 01:16 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
/^!take([1-9][0-9]?)$/i looks ok to me, to match 1-99, just put the '?' on the second [0-9] character class, which can be written as \d btw.

/^!take([1-9]\d?)$/i


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: need help to get variable text and send it in chat [Re: Wims] #253227 01/06/15 01:29 PM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Oh, of course. Derppp^_^

Re: need help to get variable text and send it in chat [Re: Sakana] #253228 01/06/15 02:06 PM
Joined: Jun 2015
Posts: 4
T
Truc Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Jun 2015
Posts: 4
thx both of u it works almost perfectly.
This code just work if the message it's "!take(number)" but in a complet sentense like in my example it doesnt work.

I have 3 issues:
1- do the code only, if ($nick == Bot)
2-find the number in any full sentence or juste in the example
3- write it with !take { msg # take$regml(1) } this doesnt work and I dont know how write text + var

I'm sorry for probably dumb question like the "third" issues but I'm very new at it.

Re: need help to get variable text and send it in chat [Re: Truc] #253229 01/06/15 02:39 PM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Try this
Code:
on *:TEXT:*:#: {
if ($regex($1-,/!take([1-9]\d?)/i)) { 
if ($nick != BOT) { return }
var %number = $regml(1) 
msg # take $+ %number
   }
}

Re: need help to get variable text and send it in chat [Re: Sakana] #253230 01/06/15 02:50 PM
Joined: Jun 2015
Posts: 4
T
Truc Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Jun 2015
Posts: 4
It works perfectly thx you smile