mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2007
Posts: 21
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2007
Posts: 21
Now, for those who read my thread from yesterday, know I'm a beginner with not much knowledge towards this scripting language. The code I'm trying to create is activated when the user types !set event <world> <team1> <team2> <team3> <delay until first game>
For example, the following would have the bot set the world to 103, the first team to zammy, the second team to sara, and the third team to zammy. The delay to the first game would be 5 minutes.
!set event 103 zammy sara zammy 5
Here's the code that the bot has.

Code:
on *:TEXT:!set *:#: {
  if (($nick isop $chan) || ($nick ishop $chan)) {
    if ($2 == event) {
      /set %world $3
      /set %team1 $4
      /set %team2 $5
      /set %team3 $6
      /set %wait $7
      /set %wait $calc(%wait * 60)
      /notice $nick Event set to start in %wait seconds. World to be played in will be %world . The first team will be %team1 , the second team will be %team2 , and the third team will be %team3 .
      /msg $chan 9UBG Castle Wars event!14WORLD:6 %world 1. 14TEAM:6 %team1 1. Game starts in $calc(%wait / 60) minutes.
      :first
      .timer 1 60 goto wait
      halt
      .timer 1 60 /msg $chan 9UBG Castle Wars event!14WORLD:6 %world1. 14TEAM:6 %team11. Game starts in $calc(%wait / 60) minutes.
      /set %wait $calc(%wait - 60)
      if (%wait <= 59) {
        goto game1
      }
      goto first
      /set %wait $calc(20 * 60)
      /msg $chan 9UBG Castle Wars event started in 14World6 %world , 14Team6 %team1 . It's time to pwn!
      :game1 
      /msg $chan 9UBG Castle Wars event!14WORLD:6 %world 1. 14TEAM:6 %team1 1. Time left: $calc(%wait / 60) minutes.
      /set %wait $calc(%wait - 60)
      if (%wait <= 59) {
        goto inter1
      }
      .timer 1 60 goto game1
      halt
      :inter1
      /set %wait $calc(20 * 60)
      /msg $chan 9UBG castle wars event intermission (5 minutes)! 14World6 %world, 14Team6 %team21. Prepare yourself.
      .timer 1 300 goto game2
      goto veryend
      :game2 
      .timer 1 60 /msg $chan 9UBG Castle Wars event!14WORLD:6 %world1. 14TEAM:6 %team21. Time left: %wait seconds.
      /set %wait $calc(%wait - 60)
      if (%wait <= 59) {
        goto inter2
      }
      .timer 1 60 goto game2
      goto veryend
      :inter2
      /set %wait $calc(20 * 60)
      /msg $chan 9UBG castle wars event intermission (5 minutes)! 14World6 %world, 14Team6 %team31. Prepare yourself.
      .timer 1 300 goto game3
      goto veryend
      :game3
      .timer 1 60 /msg $chan 9UBG Castle Wars event!14WORLD:6 %world1. 14TEAM: 6%team31. Time left: %wait seconds.
      /set %wait $calc(%wait - 60)
      if (%wait <= 59) {
        goto end
      }

      .timer 1 60 goto game3
      goto veryend
      :end
      /msg $chan Good games UBG, can't wait for the next one :D
      :veryend
    }
    if ($2 == link1) {
      /set %link1 $3
    }
    if ($2 == link2) {
      /set %link2 $3
    }
    if ($2 == link3) {
      /set %link3 $3
    }
  }
}


By the way, ignore anything about links in that code it's unimportant.
Thanks for reading my thread, hopefully you can help smile

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok, let's clean this up for you...

Code:
on *:TEXT:!set *:#: {
  if (($nick isop $chan) || ($nick ishop $chan)) {
    if ($2 == event) {
      set %world $3
      set %team1 $4
      set %team2 $5
      set %team3 $6
      set %wait $calc($7 * 60)
      notice $nick Event set to start in %wait seconds. World to be played in will be %world $+ . The first team will be %team1 $+ , the second team will be %team2 $+ , and the third team will be %team3 $+ .
      msg $chan 9UBG Castle Wars event!14WORLD:6 %world $+ 1. 14TEAM:6 %team1 $+ 1. Game starts in $calc(%wait / 60) minutes.
      .timerUBGAD 0 60 msg $chan 9UBG Castle Wars event!14WORLD:6 %world $+ 1. 14TEAM:6 %team1 $+ 1. Game starts in $calc(%wait / 60) minutes.
      set %UBGcnt 1
      .timer 1 %wait StartGame
    }
    elseif ($2 == link1) {
      set %link1 $3
    }
    elseif ($2 == link2) {
      set %link2 $3
    }
    elseif ($2 == link3) {
      set %link3 $3
    }
  }
}

alias StartGame {
  .timerUBGAD Off
  set %wait 1200
  msg $chan 9UBG Castle Wars event started in 14World6 %world $+ , 14Team6 $($+(%,team,%UBGcnt),2) $+ . It's time to pwn!
  :game1 
  .timerUBGTimeLeft $calc(%wait / 60) 60 msg $chan 9UBG Castle Wars event!14WORLD:6 %world $+ 1. 14TEAM:6 $($+(%,team,%UBGcnt),2) $+ 1. Time left: $calc(%wait / 60) minutes.
  .timerUBGInter 1 %wait GameInter
}

alias GameInter {
  if (%UBGcnt == 3) { GameEnd | return }
  msg $chan 9UBG castle wars event intermission (5 minutes)! 14World6 %world $+ , 14Team6 $($+(%,team,%UBGcnt),2) $+ 1. Prepare yourself.
  inc %UBGcnt
  .timerUBGInter 1 300 StartGame
}

alias GameEnd {
  msg $chan Good games UBG, can't wait for the next one :D
  unset %world, %team1, %team2, %team3, %wait, %UBG*
}


Note that this handles all 3 teams without repeating all of the code and without any use of GOTO. If you have questions, feel free to ask.


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2007
Posts: 21
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2007
Posts: 21
tyvm Riamus! I'll replace the old code with this grin
Although, what's an alias? I don't think I've worked with them before.
Edit: oh I see they're replacements for something like /gamestart or etc. Very nice, this is extremely helpful ^^
Edit2: hmm it seams that the times don't change (like it will always say 20 minutes left in current game even though time has passed). Is there a way to fix that? I'm trying to use something like
timerUBGwaitdec 19 60 set %wait $calc(%wait - 60)
but that isn't changing it unforunately =\

Last edited by Ash44455666; 31/08/07 06:13 PM.
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
From a quick lookover of the code, try...

Replace "set %wait $calc($7 * 60)" with set -z %wait $7 * 60
(Same in the StartGame alias: set -z %wait 1200)

Replace all the$calc(%wait /60) in the timers with $[color:red]!duration(%wait)[/color]


The ! delays evaluation of identifiers until the timer fires, instead of when they are set.

Joined: Aug 2007
Posts: 21
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2007
Posts: 21
When I changed the code you said to change, I got this from the bot's view:

Code:
<%UBG_Bot> 9UBG Castle Wars event!14WORLD:6 1031. 14TEAM:6 sara1. Game starts in $duration(%wait) minutes.
<@Ash44455666> ...
<%UBG_Bot> 9UBG Castle Wars event started in 14World6 103, 14Team6 sara. It's time to pwn!
* /timerubgtimeleft: invalid parameters (line 187, remote.ini)

btw line 187 has:
$!duration(%wait)
in it...

Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
I should have been more specific I guess...
Replace $calc(%wait /60) in the message section of the timers with $!duration(%wait)
Code:
  .timerUBGTimeLeft $calc(%wait /60) 60 msg $chan 9UBG Castle Wars event!14WORLD:6 %world $+ 1. 14TEAM:6 $($+(%,team,%UBGcnt),2) $+ 1. Time left: $!duration(%wait) 


Same applies to the other timer(s)

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Oops. I forgot to delay the evaluation for the timer. Too many changes to do all at once to remember everything. blush


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard