mIRC Home    About    Download    Register    News    Help

Print Thread
elseif and $rand var not working #139990 20/01/06 11:54 PM
Joined: Jan 2006
Posts: 2
S
SimonB Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
S
Joined: Jan 2006
Posts: 2
It's broke, I'm hoping you tell why. Thank you.


Code:
 on *:action:slaps*:#: {
var %ugs = $rand(1,3)
  if ($2 == $me) && (%ugs == 1){
    /describe $chan slaps $nick with 1111111s
  }
  
    elseif ($2 == $me) && (%ugs == 2){
      /describe $chan slaps $nick with 22222222s
  }
    elseif ($2 == $me) && (%ugs == 3){
      /describe $chan slaps $nick with 333333333s
  }
  else return
} 

Re: elseif and $rand var not working #139991 21/01/06 12:32 AM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
on *:action:slaps*:#: {
var %ugs = $rand(1,3)
if ($2 == $me) {
if (%ugs == 1) { describe $chan slaps $nick with 1111111s }
if (%ugs == 2) { describe $chan slaps $nick with 22222222s }
if (%ugs == 3) { describe $chan slaps $nick with 333333333s }
}
}

Re: elseif and $rand var not working #139992 21/01/06 12:43 AM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
From your original code, you need a space between the ) and { . It would also help to include parenthesis around both conditions.

Re: elseif and $rand var not working #139993 21/01/06 01:23 AM
Joined: Jan 2006
Posts: 2
S
SimonB Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
S
Joined: Jan 2006
Posts: 2
Thank you for help Mike Chat, your modifications worked beautifully. If it's not much trouble I still do not understand why my original code broke, could someone explain to me.

Re: elseif and $rand var not working #139994 21/01/06 01:47 AM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
It's already been explained. See my previous post.

Re: elseif and $rand var not working #139995 22/01/06 09:34 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
Code:
on *:action:slaps*:#:{
  if ($2 != $me) return
  var %ugs = $rand(1,3)
  describe $chan slaps $nick with $str(%ugs,$calc(6 + %ugs)) $+ s
}