mIRC Home    About    Download    Register    News    Help

Print Thread
#270346 07/06/22 08:17 PM
Joined: Sep 2013
Posts: 61
E
Babel fish
OP Offline
Babel fish
E
Joined: Sep 2013
Posts: 61
Hey Chaps

I know you can't use goto within a timer, as it can't find the command whilst in the timer, however, I need a way of being able to trigger a goto after 120 seconds for a minigame I've coded in the bot. Does anyone have any ideas on how to do it in a way that works within mIRC?

Code:

Code
on *:TEXT:!battle*:#: {
  if ($2 = easy) && ($nick == eggfriedcheese) {
    set %easybosson on
    set %easyboss $read(C:\Users\danie\AppData\Roaming\mIRC\bosseasy.txt)
    .msg # ! A fight has been started against %easyboss $+ . Type "!battle join" to enter
    set %chatattack 0
    ;   .timerfighteasycountdown1 1 30 .msg # ! 90 seconds to enter the fight! Type "!battle join" to enter
    ;   .timerfighteasycountdown2 1 60 .msg # ! 60 seconds to enter the fight! Type "!battle join" to enter
    ;   .timerfighteasycountdown3 1 90 .msg # ! 30 seconds to enter the fight! Type "!battle join" to enter
    ;   .timerfighteasycountdown4 1 110 .msg # ! 10 seconds to enter the fight! Type "!battle join" to enter
    ;   .timerstarteasyfight 1 120 .msg # ! Easy Fight Starting
    .timerstartbattle 1 9 set %startbattle on
    ;    goto battle
    return
  }
  if ($2 = join) {
    if (%easybosson) {
      if (%inbattle. [ $+ [ $nick ] ]) { return }
      else {
        set %inbattle. [ $+ [ $nick ] ] on
        .msg # $displayname has joined the fight with $read(C:\Users\danie\AppData\Roaming\mIRC\battleweapons.txt) $+ . Good Luck!
        inc %chatattack $rand(10,50)
        return
      }
    }
  }
  :battle
  if (%startbattle) {
    if (%easyboss == An Angry Cow (HP: 30)) { var %bosshealth 30 }
    if (%easyboss == A Spider (HP: 40)) { var %bosshealth 40 }
    if (%easyboss == A Goblin (HP: 50)) { var %bosshealth 50 }
    .msg # The Damage from chat is %chatattack $+ . The boss has %bosshealth HP 
    if (%damage >= %bosshealth) { .msg # You killed the boss! | return }
    if (%damage < %bosshealth) { .msg # The boss wiped out the chat! | return }
  }
  else { return }
}


Twitch Live-Streamer:
Synth Riders
Beat Saber
www.twitch.tv/eggfriedcheese
Joined: Jan 2012
Posts: 317
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 317
You can try to use aliases as separate blocks of your code that can be run after the desired time using a timer.

For example:
Code
on *:TEXT:!battle*:#:{
...
  .timerBattle 1 120 battle
...
}

alias -l battle {
  if (%startbattle) {
    if (%easyboss == An Angry Cow (HP: 30)) { var %bosshealth 30 }
    if (%easyboss == A Spider (HP: 40)) { var %bosshealth 40 }
    if (%easyboss == A Goblin (HP: 50)) { var %bosshealth 50 }
    .msg # The Damage from chat is %chatattack $+ . The boss has %bosshealth HP 
    if (%damage >= %bosshealth) { .msg # You killed the boss! | return }
    if (%damage < %bosshealth) { .msg # The boss wiped out the chat! | return }
  }
  else { return }
}


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Sep 2013
Posts: 61
E
Babel fish
OP Offline
Babel fish
E
Joined: Sep 2013
Posts: 61
Ooh, that's a good idea! Thank you!


Twitch Live-Streamer:
Synth Riders
Beat Saber
www.twitch.tv/eggfriedcheese
Joined: Sep 2013
Posts: 61
E
Babel fish
OP Offline
Babel fish
E
Joined: Sep 2013
Posts: 61
Okay, this isn't working.

If it's within the block of code, I'm getting:

[09:08:28] BATTLE Unknown command

If it's outside the block of code, I'm getting:

[09:11:22] -tmi.twitch.tv- This channel does not exist or has been suspended.


Twitch Live-Streamer:
Synth Riders
Beat Saber
www.twitch.tv/eggfriedcheese
Joined: Jan 2012
Posts: 317
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 317
All aliases should always be single blocks only. This is useful for separating code functions that can be accessed at the right time.

To determine the name of the channel, it is correct to use the identifier $chan, instead of using the # sign:
Code
alias -l battle {
  if (%startbattle) {
    if (%easyboss == An Angry Cow (HP: 30)) { var %bosshealth 30 }
    if (%easyboss == A Spider (HP: 40)) { var %bosshealth 40 }
    if (%easyboss == A Goblin (HP: 50)) { var %bosshealth 50 }
    .msg $chan The Damage from chat is %chatattack $+ . The boss has %bosshealth HP 
    if (%damage >= %bosshealth) { .msg $chan You killed the boss! | return }
    if (%damage < %bosshealth) { .msg $chan The boss wiped out the chat! | return }
  }
  else { return }
}

You can also, if necessary, pass any parameters to the alias you need:
Code
on *:TEXT:!battle*:#:{
...
  .timerBattle 1 120 battle $chan
...
}

alias -l battle {
  if (%startbattle) {
    if (%easyboss == An Angry Cow (HP: 30)) { var %bosshealth 30 }
    if (%easyboss == A Spider (HP: 40)) { var %bosshealth 40 }
    if (%easyboss == A Goblin (HP: 50)) { var %bosshealth 50 }
    .msg $1 The Damage from chat is %chatattack $+ . The boss has %bosshealth HP 
    if (%damage >= %bosshealth) { .msg $1 You killed the boss! | return }
    if (%damage < %bosshealth) { .msg $1 The boss wiped out the chat! | return }
  }
  else { return }
}

In this case, the first parameter $1 will be the name of the channel that was passed through the "battle $chan" alias command.


🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Sep 2013
Posts: 61
E
Babel fish
OP Offline
Babel fish
E
Joined: Sep 2013
Posts: 61
EDIT: Figured out that commands don't like # or $chan in aliases outside of a command

Fixed with the below:

Code
on *:TEXT:!battle*:#: {
  if ($2 = easy) && ($nick == eggfriedcheese) {
    set %easybosson on
    set %easyboss $read(C:\Users\danie\AppData\Roaming\mIRC\bosseasy.txt)
    if (%easyboss == An Angry Cow (HP: 30)) { set %bosshealth 30 }
    if (%easyboss == A Spider (HP: 40)) { set %bosshealth 40 }
    if (%easyboss == A Goblin (HP: 50)) { set %bosshealth 50 }
    .msg # ! A fight has been started against %easyboss $+ . Type "!battle join" to enter
    set %chatattack 0
    ;   .timerfighteasycountdown1 1 30 .msg # ! 90 seconds to enter the fight! Type "!battle join" to enter
    ;   .timerfighteasycountdown2 1 60 .msg # ! 60 seconds to enter the fight! Type "!battle join" to enter
    .timerfighteasycountdown3 1 30 .msg # ! 30 seconds to enter the fight! Type "!battle join" to enter
    .timerfighteasycountdown4 1 50 .msg # ! 10 seconds to enter the fight! Type "!battle join" to enter
    .timerstarteasyfight 1 60 .msg # ! Easy Fight Starting
    .timerstartbattle 1 59 set %startbattle on
    .timersetchannel 1 59 set %channel $chan
    .timerBattle 1 60 battle
    return
  }
  if ($2 = join) {
    if (%easybosson) {
      if (%inbattle. [ $+ [ $nick ] ]) { return }
      else {
        set %inbattle. [ $+ [ $nick ] ] on
        .msg # $displayname has joined the fight with $read(C:\Users\danie\AppData\Roaming\mIRC\battleweapons.txt) $+ . Good Luck!
        inc %chatattack $rand(10,50)
        return
      }
    }
  }
}

alias battle {
  if (%startbattle) {
    .msg %channel The Damage from chat is %chatattack $+ . The boss has %bosshealth HP 
    if (%chatattack >= %bosshealth) { .timer 1 2 .msg %channel You killed the boss! | return }
    if (%chatattack < %bosshealth) { .timer 1 2 .msg %channel %easyboss wiped out the chat! | return }
  }
  else { return }
}


Twitch Live-Streamer:
Synth Riders
Beat Saber
www.twitch.tv/eggfriedcheese

Link Copied to Clipboard