mIRC Home    About    Download    Register    News    Help

Topic Options
#248763 - 22/10/14 09:53 PM Alias after a timer
JB_uk Offline
Ameglian cow

Registered: 10/10/14
Posts: 48
Loc: United Kingdom
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

Top
#248765 - 22/10/14 11:38 PM Re: Alias after a timer [Re: JB_uk]
Belhifet Offline
Fjord artisan

Registered: 26/06/14
Posts: 248
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.

Top
#248766 - 23/10/14 12:28 AM Re: Alias after a timer [Re: Belhifet]
JB_uk Offline
Ameglian cow

Registered: 10/10/14
Posts: 48
Loc: United Kingdom
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?

Top
#248767 - 23/10/14 01:41 AM Re: Alias after a timer [Re: JB_uk]
Belhifet Offline
Fjord artisan

Registered: 26/06/14
Posts: 248
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.

Top
#248768 - 23/10/14 02:52 AM Re: Alias after a timer [Re: Belhifet]
JB_uk Offline
Ameglian cow

Registered: 10/10/14
Posts: 48
Loc: United Kingdom
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)))
}


Edited by JB_uk (23/10/14 06:41 AM)
Edit Reason: Previous solved, new problem found

Top
#248773 - 23/10/14 02:22 PM Re: Alias after a timer [Re: JB_uk]
JB_uk Offline
Ameglian cow

Registered: 10/10/14
Posts: 48
Loc: United Kingdom
EDIT: Fixed, JB did a dum dum

Top