mIRC Home    About    Download    Register    News    Help

Print Thread
#254792 03/09/15 08:45 AM
Joined: Sep 2015
Posts: 7
T
Trax Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2015
Posts: 7
Hello everyone! I hope someone will finally help me over here.
In the following command, I get the same value over and over again :

Code:
/timer 1 1 timercheck 0 2 msg #mirc $rand(1,20)


Why does it happen, and what should I do to get different values?

THANKS! grin

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
use this: /timer 1 1 msg #mirc $rand(1,20)


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Sep 2015
Posts: 7
T
Trax Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2015
Posts: 7
the problem is - i need the two of the timers for a bigger script.
I can exchange the second timer for a "while" script, but i still get the same problem.

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
I did not understand but if i get you try use this code:

Code:
alias safe return $decode($encode($1-, m) ,m)


and run the time like:

Code:
/timer[test] 0 10 echo -a Rand Number: $safe($rand(1,10))


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Sep 2015
Posts: 7
T
Trax Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2015
Posts: 7
well, it works fine without another timer.
when i try this command :
Code:
/timer 1 1 /timer[test] 0 10 echo -a Rand Number: $safe($rand(1,10))

i just get the same number over and over...

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Try use this:

Code:
//timer 1 1 timer[test] 0 10 echo -a Rand Number: $!safe($!rand(1,10))


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Sep 2015
Posts: 7
T
Trax Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2015
Posts: 7
It works!! Thanks!!
but why? blush

Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
This is by design: http://en.wikichip.org/wiki/mirc/msl_injection#Nested_command
Originally Posted By: /help /timer
You can force identifiers to be re-evaluated when used in a /timer command by using the format $!me or $!time.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Sep 2015
Posts: 7
T
Trax Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2015
Posts: 7
but it seems like :
Code:
/timer1 1 1 /timer2 1 1 msg #mirc $!rand(1,20)

wont work, but :
Code:
/timer1 1 1 msg #mirc $!rand(1,20)

would work

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Check my example above, you are missing the $!safe ...


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Sep 2015
Posts: 7
T
Trax Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2015
Posts: 7
yea, i know, but why should i use that? what does the $!safe do?

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
If you read carefully our posts you wouldn't ask twice the same think the @Wims answered you above with an link, follow him and read the Wiki page that gave you to understand.


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Jul 2006
Posts: 4,144
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,144
$safe isn't necessarily needed here, only if you have unknown content that are going to be evaluated 'twice' like that $rand, except $rand cannot return something dangerous.

timer1 1 1 /timer2 1 1 msg #mirc $!rand(1,20)

when you do that, the timer1 command will gather its parameter, what are the parameter of the /timer1 command here? it's "1" "1" "/timer2" "1" "1" "msg" "#mirc" "$!rand(1,20)"
$!rand(1,20) is an identifier, so it gets evaluated as "$rand(1,20)"

So the parameter of the /timer1 command are "1" "1" "/timer2" "1" "1" "msg" "#mirc" "$rand(1,20)"

And from that point, it will register that its associated command is "/timer2 1 1 msg #mirc $rand(1,20)", when that timer fires, mIRC execute:

/timer2 1 1 msg #mirc $rand(1,20)

Again, the paramater of the /timer2 command are gathered, $rand(1,20) is evaluated to let's say 6, and the associated command of that timer is "msg #mirc 6", you want it to be "msg #mirc $rand(1,20), if you have two nested timer, you want two '!!' : $!!rand(1,20) smile

Last edited by Wims; 03/09/15 06:40 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Sep 2015
Posts: 7
T
Trax Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2015
Posts: 7
Understood. Thank you very much!! grin


Link Copied to Clipboard