mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2006
Posts: 6
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2006
Posts: 6
I have a timer that runs an alias where it then does a /msg $chan <text> function. It seems to be ignoring the $chan and trying to msg the first word of the text. /msg chan works in other areas of my script.

Code:
 alias distroles {
  if (%plyrs == 3) {
    set %game 2
    msg $chan |MAFIABOT|Mafia game starting, %plyrs playing, distributing roles.
  }
  else {
    msg $chan |MAFIABOT|Mafia game cancelled, not enough players signed up.
    set %game 0
  }
}
on *:TEXT:!mmafia start:#:{
  if (%game == 0) {
    msg $chan 0,1|MAFIABOT|Starting a game of mafia, type !mmafia in to join.
    set %game 1
    timer1 1 15 [ distroles ]
  }
  else if (%game &gt; 0) /msg $chan 0,1|MAFIABOT|Game of mafia already in progress
}
 

the starting game line works just fine, but after the timer i get this:

* Timer 1 activated
-
-> *|MAFIABOT|Mafia* game cancelled, not enough players signed up.
-
* Timer 1 halted
-
|MAFIABOT|Mafia No such nick
-

so I'm confused

Joined: Dec 2002
Posts: 1,541
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Dec 2002
Posts: 1,541
It's because you're not telling it which channel to do it in. Nowhere in the TIMER command are you designating it. Try something like (for example and may not work):

timer1 1 15 [ distroles ] #

and then in the alias, maybe something like this:

msg $1 the rest of it here

This way, the timer fills the alias with the channel and it can be used......... The coding might be off, but Im sure this gets the general idea across.


Those who fail history are doomed to repeat it
Joined: Jun 2006
Posts: 6
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Jun 2006
Posts: 6
ty it works fine now

Joined: Dec 2002
Posts: 1,541
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Dec 2002
Posts: 1,541
anytime, glad to be of help smile


Those who fail history are doomed to repeat it
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
As already explained to you the $chan value doesnt survive into the timer, so u must pass it to the timer, now while in your case it likely is ok to pass it as $1 it can infact cause problems as expressed to me not long ago. because a channel like #$me well convert to your nick, thus u been pming yourself. (pretty od i know but still there)

also you should NEVER name a timer a number Doubly so the number 1 since that timer is amost always going to already exist.

heres a fix for this
Code:
alias distroles {
  var %chan = $iif($ctimer,$mid($v1,19),$chan)
  if (%plyrs == 3) {
    set %game 2
    msg %chan |MAFIABOT|Mafia game starting, %plyrs playing, distributing roles.
  }
  else {
    msg %chan |MAFIABOT|Mafia game cancelled, not enough players signed up.
    set %game 0
  }
}
on *:TEXT:!mmafia start:#:{
  if (%game == 0) {
    msg $chan 0,1|MAFIABOT|Starting a game of mafia, type !mmafia in to join.
    set %game 1
    timer.!mmafia.start.on. $+ $chan 1 15 distroles
  }
  else if (%game &gt; 0) /msg $chan 0,1|MAFIABOT|Game of mafia already in progress
}


I insert the name of the channel into the timer name at character 19, so when the alias is called it has the $ctimer value and you pull the channel name out of it, if the $ctimer doesnt exist u likely ran the alias your self, so it uses $chan, from there the alias uses the now set %chan value.


Link Copied to Clipboard