mIRC Home    About    Download    Register    News    Help

Topic Options
#253215 - 01/06/15 02:54 AM need help to get variable text and send it in chat
Truc Offline
Self-satisified door

Registered: 01/06/15
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.


Edited by Truc (01/06/15 02:55 AM)

Top
#253217 - 01/06/15 05:56 AM Re: need help to get variable text and send it in chat [Re: Truc]
Sakana Offline
Fjord artisan

Registered: 19/09/14
Posts: 259
Can you give an example sentence and what you want to capture from it?

Top
#253224 - 01/06/15 01:26 PM Re: need help to get variable text and send it in chat [Re: Sakana]
Truc Offline
Self-satisified door

Registered: 01/06/15
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.

Top
#253225 - 01/06/15 01:51 PM Re: need help to get variable text and send it in chat [Re: Truc]
Sakana Offline
Fjord artisan

Registered: 19/09/14
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 }

}

}


Edited by Sakana (01/06/15 01:59 PM)

Top
#253226 - 01/06/15 02:16 PM Re: need help to get variable text and send it in chat [Re: Sakana]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3515
Loc: France
/^!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

Top
#253227 - 01/06/15 02:29 PM Re: need help to get variable text and send it in chat [Re: Wims]
Sakana Offline
Fjord artisan

Registered: 19/09/14
Posts: 259
Oh, of course. Derppp^_^

Top
#253228 - 01/06/15 03:06 PM Re: need help to get variable text and send it in chat [Re: Sakana]
Truc Offline
Self-satisified door

Registered: 01/06/15
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.

Top
#253229 - 01/06/15 03:39 PM Re: need help to get variable text and send it in chat [Re: Truc]
Sakana Offline
Fjord artisan

Registered: 19/09/14
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
   }
}

Top
#253230 - 01/06/15 03:50 PM Re: need help to get variable text and send it in chat [Re: Sakana]
Truc Offline
Self-satisified door

Registered: 01/06/15
Posts: 4
It works perfectly thx you smile

Top