mIRC Homepage
Posted By: LMN Russian Roulette - 05/01/11 04:37 PM
I want to change the script so it isn't random deciding your destiny but random deciding who's destiny it is (so $nick1 or $nick2) but I don't know what code to use.

Php Code:
on *:TEXT:!rr*:#: {
  var %rr = $rand(1,3)
  msg $chan $2 draait het wapen en schiet!
  if (%rr == 1) .timer 1 3 msg $chan CLICK! $2 got lucky.
  if (%rr == 2) .timer 1 3 msg $chan BANG! $nick watches $2 $+ 's brain splatter all over the wall.
  if (%rr == 3) .timer 1 3 msg $chan The gun jammed, $2 got lucky.
} 

Posted By: Darwin_Koala Re: Russian Roulette - 05/01/11 08:39 PM
try $nick e.g.
Code:
%rr2 = $rand(1, $nick(0))
if (%rr = 1/2/3) .timer 1 3 msg $chan <...> $nick(%rr2) <...> 


There is a race condition here - if someone leaves the channel within the 3 seconds the timer is set for, the above modifications will either give the wrong name, or an error.

One way around it is to set the nick as soon as the alias is triggered.
Code:
 
var %targetnick = $nick($rand(1, $nick(0)))

and use %targetnick instead of $2

Cheers,
DK
Posted By: LMN Re: Russian Roulette - 06/01/11 05:10 PM
But how should I make it then sorry I'm just a beginner with scripts. I'm now puzzling but It doesn't work. I just want
Code:
BANG! $nick watches $2 $+ 's brain splatter all over the wall.

to use at a random nick.
Posted By: Wims Re: Russian Roulette - 06/01/11 05:46 PM
I'm not sure if this is what you want but try :
Code:
on *:TEXT:!rr &:#:.timer 1 3 msg $safe($chan) BANG! $nick($chan,$r(1,$nick($chan,0))) watches $safe($2) $!+ 's brain splatter all over the wall
alias safe bset -ct &a 1 $1 | return $!regsubex(safe, $bvar(&a,1-) ,/(\d+)(?: |$)/g,$chr(\1))

Posted By: LMN Re: Russian Roulette - 06/01/11 06:33 PM
I'm sorry it doesn't work.
Posted By: Wims Re: Russian Roulette - 06/01/11 06:44 PM
what doesn't work exactly ? how are you triggering it ? I edited the code in my previous post, you can try it again
Posted By: LMN Re: Russian Roulette - 06/01/11 07:00 PM
It doesn't react. It's just like a normal message. Even nothing at status.
Posted By: Wims Re: Russian Roulette - 06/01/11 07:26 PM
It works for me, should works for you too, try putting that code in a new file and be sure that you don't have your old on text event
Posted By: Darwin_Koala Re: Russian Roulette - 06/01/11 08:41 PM
Untested:

Code:
on *:TEXT:!rr*:#: {
  var %tgtnick = $nick($rand(1,$nick(0))
  var %rr = $rand(1,3)
  msg $chan %tgtnick  draait het wapen en schiet!
  if (%rr == 1) .timer 1 3 msg $chan CLICK! %tgtnick got lucky.
  if (%rr == 2) .timer 1 3 msg $chan BANG! $nick watches %tgtnick $+ 's brain splatter all over the wall.
  if (%rr == 3) .timer 1 3 msg $chan The gun jammed, %tgtnick got lucky.
} 
Posted By: RusselB Re: Russian Roulette - 07/01/11 12:08 AM
Optional suggestion
Code:
on *:text:*:#:{
  tokenize 32 $strip($1-)
  if ($1 == !rr) {
    var %tgtnick = $nick(#,$r(1,$nick(#,0))), %shot = $r(1,3)
    msg $chan %tgtnick  draait het wapen en schiet!
    if (%shot == 2) {      %shot = BANG! $nick watches %tgtnick $+ 's brain splatter all over the wall.    }
    else %shot = $iif(%shot == 1,CLICK! %tgtnick got lucky.,The gun jammed, %tgtnick got lucky.)
    .timer 1 3 msg $chan %shot
  }
}

P.S.: Normally in Russian Roulette, a 6 shooter is used, thus the odds of getting shot are 1 in 6, not 1 in 3.
© mIRC Discussion Forums