mIRC Homepage
Posted By: Sableye2 script help please - 07/08/06 11:28 PM
I'm making a script for a game. What I want is if a person uses !shootwater twenty times in 25 seconds, they receive a message called "Congratulations, you win!" However, if that person does not type !shootwater twenty times in 25 seconds, then they receive a message called "You lose." Could someone help me with this?
Posted By: RusselB Re: script help please - 07/08/06 11:51 PM
Code amended per updated posting
Code:
 on *:text:!shootwater:#:{
inc $+(%,water,.,$nick)
$+(.timer,$nick) 1 25 shootwater $nick $chan $($+(%,water,.,$nick),2)
}
alias shootwater {
.msg $2 $1 $iif($3 > 19,wins,looses)
unset $+(%,water,.,$1)
}
 
Posted By: Sableye2 Re: script help please - 08/08/06 12:11 AM
I meant to say !shootwater instead of !openegg...sorry smirk
Posted By: RusselB Re: script help please - 08/08/06 12:30 AM
Try the edited code. It should work without any problems.
Posted By: Sableye2 Re: script help please - 08/08/06 01:57 AM
Thank you for the script. Now is there a way to make the message more complex? Instead of <nick> wins or <nick> loses, could I have something like "Good job! You have won the game!"?
Posted By: RusselB Re: script help please - 08/08/06 02:02 AM
Just replace the word wins in the original script with what you want for the winning message, and likewise for looses.

Please note that due to the way I have it coded, you can not use a comma in the message, and multiple line messages have to use pipes or they won't work.

If you want to have one or more commas in the message, I can recode to allow that, likewise for multiple line messages.
Posted By: Sableye2 Re: script help please - 08/08/06 02:25 AM
The messages are fine, but there's something wrong with the timer settings. Whenever I type in !shootwater 20 times it displays the Win message even if it has been more than 25 seconds. It also doesn't display a message immediately after 25 seconds. It's like a minute before I receive a message.
Posted By: RusselB Re: script help please - 08/08/06 03:27 AM
OK, I see the problem, and here's the repaired code
Code:
 on *:text:!shootwater:#:{
  inc $+(%,water,.,$nick)
  if !$timer($nick) {
    $+(.timer,$nick) 1 25 shootwater $nick $chan $($+(%,water,.,$nick),2)
  }
}
alias shootwater {
  .msg $2 $1 $iif($3 &gt; 19,wins,looses)
  unset $+(%,water,.,$1)
}
 
Posted By: Sableye2 Re: script help please - 08/08/06 12:50 PM
Thanks. If I were to change the number of times I say !shootwater, what part would I change? Right now it's set for 20 times. How would I change it to 10 times?
Posted By: KingTomato Re: script help please - 08/08/06 03:20 PM
in the shootwater alias, change the > 19 portion to > 9.
Posted By: Sableye2 Re: script help please - 08/08/06 05:54 PM
The thing says that I lose each time even though I have typed in !shootwater 10 times before 25 seconds. Perhaps it's the few changes I made that made the script stop working.

Code:
on *:text:!shootwater:#:{
  if (%esplay == null) {
    notice $chan This game is currently for %esnick only!
    halt
  }
  if (%seadra == null) {
    notice $chan This game is currently for %esnick only!
    halt
  }
  inc $+(%,water,.,$nick)
  if !$timer($nick) {
    $+(.timer,$nick) 1 25 shootwater $nick $chan $($+(%,water,.,$nick),2)
  }
}
alias shootwater {
  .msg $2 $1 $iif($3 &gt; 9,good job!  You killed Snorlax!  Inside of him was a special Chansey egg Use !openegg to open it.,lose!  You win nothing.)
  unset $+(%,water,.,$1)
}


I really don't know why it won't display the winning message. Only displays the losing message. Help is appreciated.
Posted By: RusselB Re: script help please - 08/08/06 10:40 PM
Code:
 on *:text:!shootwater:#:{
  if !%esplay &amp;&amp; !%seadra {
    notice $chan This game is currently for %esnick only!
  }
  else {
    inc $+(%,water,.,$nick)
    if !$timer($nick) {
      $+(.timer,$nick) 1 25 shootwater $nick $chan
    }
  }
}
alias shootwater {
  .msg $2 $1 $iif($($+(%,water,.,$1),2) &gt; 9,good job!  You killed Snorlax!  Inside of him was a special Chansey egg Use !openegg to open it.,lose!  You win nothing.)
  unset $+(%,water,.,$1)
}
 

For some reason, and I'm not sure why, the 3rd parameter wasn't being passed to the alias properly. The above code works around that problem and has been tested.
© mIRC Discussion Forums