mIRC Home    About    Download    Register    News    Help

Print Thread
Timer problem + script alias (problem with "%"?) #249692 11/12/14 06:48 PM
Joined: Aug 2014
Posts: 42
K
Krawalli Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
Hey,
i have a little game script and want that the game is automatically active (when i have written !on) every 10min WITHOUT a user have to type anything, everything in the game script works great when i do it with the "on *:text:!test:#:" command but that isnt what i want.

So i tried to make timers and a game alias:

Code:
on *:text:!on:#: {
  .timer.game 0 600 %gamealias
}
on *:text:!off:#: {
  .timer.game off
}

alias %gamealias {
  set -n %word $read(wordlist.txt,n)
  msg # Game: %word
}



That is just a example, but it dont work, mirc dont even setting up the timer! When i remove the "%" at the alias mirc loads the timer but dont give any message!

Its just really odd - someone can explain me what i do wrong?


Tldr:
Timers dont working for me when i use "%" in the script / alias title.


Last edited by Krawalli; 11/12/14 06:49 PM.
Re: Timer problem + script alias (problem with "%"?) [Re: Krawalli] #249693 11/12/14 07:36 PM
Joined: Mar 2014
Posts: 52
P
patrickplays Offline
Babel fish
Offline
Babel fish
P
Joined: Mar 2014
Posts: 52
timer.game 0 600 /msg #channel %gamealias

Last edited by patrickplays; 11/12/14 07:39 PM.
Re: Timer problem + script alias (problem with "%"?) [Re: patrickplays] #249694 11/12/14 07:53 PM
Joined: Aug 2014
Posts: 42
K
Krawalli Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
Hey,
that is not working for me:

Code:
on *:text:!on:#: {
  .timer.game 0 5 /msg # %gamealias
}
on *:text:!off:#: {
  .timer.game off
}

alias %gamealias {
  set -n %word $read(wordlist.txt,n)
  msg # Game: %word
}



Not even the timer is created when i check it on the bot with /timers

Re: Timer problem + script alias (problem with "%"?) [Re: Krawalli] #249697 11/12/14 08:35 PM
Joined: Jun 2014
Posts: 248
B
Belhifet Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Code:
on *:text:!on:#: {
  .timer.game 0 5 gamealias $chan
}
on *:text:!off:#: {
  .timer.game off
}

alias gamealias {
  set -n %word $read(wordlist.txt,n)
  msg $1 Game: %word
}


How about a simple solution.

Last edited by Belhifet; 11/12/14 08:37 PM.
Re: Timer problem + script alias (problem with "%"?) [Re: Belhifet] #249698 11/12/14 08:43 PM
Joined: Aug 2014
Posts: 42
K
Krawalli Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
Thank you Belhifet, that helps me alot!
I was able to fix my script smile

Re: Timer problem + script alias (problem with "%"?) [Re: Krawalli] #249718 12/12/14 04:35 PM
Joined: Aug 2014
Posts: 42
K
Krawalli Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
Okay perhaps someone can help me again, i have now 2 Games - i want them to choosen random.

When i change the 10min timer to this:
Code:
.timer.game 0 5 $+(game,$rand(1,2)) $chan


It is chooseing the game random the first time, but stay then on that game. The timer isnt changeing!



So i thought about another alias and tried it this way:

Code:
on *:text:!on:#: {
  .timer.gameselecter 0 5 selected $chan
}

alias selected {
  .timer.random 1 0 $+(game,$rand(1,2)) $chan
}

alias game1 {
  set -n %word $read(wordlist.txt,n)
  /echo -a GAME1
  msg $1 Game: GAME1: %word
}

alias game2 {
  set -n %word $read(wordlist.txt,n)
  /echo -a GAME2  
  msg $1 Game: GAME2 %word
}



The strange thing is now:
The "echo" is working but there is NO message - when i execute game1 or game2 with the first timer without the random thing - its working perfect.

Please someone? laugh

Last edited by Krawalli; 12/12/14 04:37 PM.
Re: Timer problem + script alias (problem with "%"?) [Re: Krawalli] #249719 12/12/14 05:07 PM
Joined: Jun 2014
Posts: 248
B
Belhifet Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
in
Code:
alias selected {
  .timer.random 1 0 $+(game,$rand(1,2)) $chan
}

The alias is not on a channel. You've passed $chan on to the alias via the on text !on. That value($chan) is $1 for that alias.
Code:
alias selected {
  .timer.random 1 0 $+(game,$rand(1,2)) $1
}

Re: Timer problem + script alias (problem with "%"?) [Re: Belhifet] #249720 12/12/14 05:22 PM
Joined: Aug 2014
Posts: 42
K
Krawalli Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
Wuh... its working like charme lol!
Thank you much.

Re: Timer problem + script alias (problem with "%"?) [Re: Belhifet] #249721 12/12/14 08:33 PM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
Using unknown content inside /timer is dangerous, you should sanitize the unknown parameters passed to /timer as part of its command (here, $1) with $safe()


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Timer problem + script alias (problem with "%"?) [Re: Wims] #249723 12/12/14 09:14 PM
Joined: Jun 2014
Posts: 248
B
Belhifet Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Thats a fair point, I only use mirc for twitch so this doesnt come up for me frown