mIRC Homepage
Posted By: JB_uk Alias after a timer - 22/10/14 08:53 PM
Hi there, I'm just stuck working out how to start and alias after a timer expires. The alias itself is working fine but I'm trying to get it to start after a timer has finished. Shown below.
Code:
on *:text:!test:#: {
  timer.PlayerNo 1 125 msg # $lines(Name.txt) people are taking part.
  timer.Time 1 150 /howmany
}


alias HowMany {
  if ($lines(Name.txt) == 1) goto oneplayer
  elseif ($lines(Name.txt) == 2) goto twoplayers
  elseif ($lines(Name.txt) == 3) goto threeplayers
  elseif ($lines(Name.txt) == 4) goto fourplayers
  elseif ($lines(Name.txt) == 5) goto fiveplayers
  elseif ($lines(Name.txt) == 6) goto sixplayers
  :oneplayer
  msg # There is One Player in the game.
  :twoplayers
  msg # There are Two Players in the game.
  :threeplayers
  msg # There are Three Players in the game.
  :fourplayers
  msg # There are Four Players in the game.
  :fiveplayers
  msg # There are Five Players in the game.
  :sixplayers
  msg # There are Six Players in the game.
}

I'm just wondering if there is another way for me to put an alias after a short stop ie a timer.

Cheers
Posted By: Belhifet Re: Alias after a timer - 22/10/14 10:38 PM
Originally Posted By: JB_uk
Hi there, I'm just stuck working out how to start and alias after a timer expires. The alias itself is working fine but I'm trying to get it to start after a timer has finished. Shown below.
Code:
on *:text:!test:#: {
  timer.PlayerNo 1 125 msg # $lines(Name.txt) people are taking part.
  timer.Time 1 150 /howmany
}


alias HowMany {
  if ($lines(Name.txt) == 1) goto oneplayer
  elseif ($lines(Name.txt) == 2) goto twoplayers
  elseif ($lines(Name.txt) == 3) goto threeplayers
  elseif ($lines(Name.txt) == 4) goto fourplayers
  elseif ($lines(Name.txt) == 5) goto fiveplayers
  elseif ($lines(Name.txt) == 6) goto sixplayers
  :oneplayer
  msg # There is One Player in the game.
  :twoplayers
  msg # There are Two Players in the game.
  :threeplayers
  msg # There are Three Players in the game.
  :fourplayers
  msg # There are Four Players in the game.
  :fiveplayers
  msg # There are Five Players in the game.
  :sixplayers
  msg # There are Six Players in the game.
}

I'm just wondering if there is another way for me to put an alias after a short stop ie a timer.

Cheers

timer.Time 1 150 howmany CHANNELNAME <--You'll have to pass this information to the alias via $chan or via some other method.


msg $1 There are Six Players in the game. <--we use the 1st source of information passed to the alias which was the channel name.


if ($lines(Name.txt) == 1) { msg $1 There is One Player in the game. } <--No need for gratuitous use of gotos.
Posted By: JB_uk Re: Alias after a timer - 22/10/14 11:28 PM
goto's were there as I had further plans for it.
Such as below:
Code:
on *:text:!test:#: {
  timer.PlayerNo 1 125 msg # $lines(Name.txt) people are taking part.
  timer.Time 1 150 HowMany #JB_uk
}


alias HowMany {
  if ($lines(Name.txt) == 1) goto oneplayer
  elseif ($lines(Name.txt) == 2) goto twoplayers
  elseif ($lines(Name.txt) == 3) goto threeplayers
  elseif ($lines(Name.txt) == 4) goto fourplayers
  elseif ($lines(Name.txt) == 5) goto fiveplayers
  elseif ($lines(Name.txt) == 6) goto sixplayers
  :oneplayer
  OnePlayer
  :twoplayers
  msg # There are Two Players in the game.
  :threeplayers
  msg # There are Three Players in the game.
  :fourplayers
  msg # There are Four Players in the game.
  :fiveplayers
  msg # There are Five Players in the game.
  :sixplayers
  msg # There are Six Players in the game.
}

alias OnePlayer {
  var %rn1 $rand(1,6)
  if (%rn1 == 1) { 
    msg $chan Very good
  }
  if (%rn1 == 2) { 
    msg $chan It went ok I guess.
  }
  if (%rn1 == 3) { 
    msg $chan It went very well for you.
  }
  if (%rn1 == 4) { 
    msg $chan It went well for you
  }
  if (%rn1 == 5) { 
    msg $chan It didn't go as planned.
  }
  if (%rn1 == 6) { 
    msg $chan It didn't go well for you.
  }
}


How would I go about doing it for this. This would be done for other players but not yet. Would the same need to be done for this?
Posted By: Belhifet Re: Alias after a timer - 23/10/14 12:41 AM
Code:
alias HowMany {
  if ($lines(Name.txt) == 1) {
    var %rn1 $rand(1,6)
    if (%rn1 == 1) { 
      var %msg Very good
    }
    elseif (%rn1 == 2) { 
      var %msg It went ok I guess.
    }
    elseif (%rn1 == 3) { 
      var %msg It went very well for you.
    }
    elseif (%rn1 == 4) { 
      var %msg It went well for you
    }
    elseif (%rn1 == 5) { 
      var %msg It didn't go as planned.
    }
    elseif (%rn1 == 6) { 
      var %msg It didn't go well for you.
    }
    msg $1 %msg
  }
  elseif ($lines(Name.txt) == 2)

Using gotos is just kinda bad practice I suppose it works though.

I guess it would probably be better to make those responses into a token and just use the random number to pick which token to use.
Posted By: JB_uk Re: Alias after a timer - 23/10/14 01:52 AM
On a slightly related topic, any idea why the result pull from this $readini won't then work in a $calc, shown simply below.
Code:
on *:text:!attack*:#: {
  writeini -n HeistLoot.ini $nick risk $2
  var %pmoney1 $readini(Points.ini, n, $nick, risk)
  
  msg # $nick $+ , it went well for you, you stole $floor($calc((%pmoney1 * 2.5))) points. 
  %points = $floor($calc((%pmoney1 * 2.5)))
}
Posted By: JB_uk Re: Alias after a timer - 23/10/14 01:22 PM
EDIT: Fixed, JB did a dum dum
© mIRC Discussion Forums