|
Joined: Jun 2013
Posts: 2
Bowl of petunias
|
OP
Bowl of petunias
Joined: Jun 2013
Posts: 2 |
I need help with this script. I have one that someone pasted to me but can't get it to work. If someone can give me a copy of a script that does work or tell me how to get this one to work I'd really appreciate it. on +3:text:!winner:#: { set %nick1 $nick($chan,$rand(0,$nick($chan,0))) if (%nick1 == $me) { set %nick1 $nick($chan,$rand(0,$nick($chan,0))) } else msg $chan Randomly selecting a winner........ timerlawl 1 5 msg $chan The winner is %nick1 $+ ! Congratulations $nick1 You win... %prize. [ $+ [ $network ] $+ ] . [ $+ [ $chan ] ] } on +3:text:!addprize *:#: { set %prize. [ $+ [ $network ] $+ ] . [ $+ [ $chan ] ] $2- msg $chan New prize set! } on +3:text:!clprize:#: { set %prize. [ $+ [ $network ] $+ ] . [ $+ [ $chan ] ] Nothing msg $chan Prize cleared! }
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
It would help if you say what you expect it to be doing and what it is doing instead. Basically, what isn't working? The one thing that stands out is that you are avoiding picking yourself as the nick, but only one time. It's not in a loop, so if you end up randomly selecting yourself twice, you'll be the winner. It won't keep trying for someone else without a loop. Of course, if you have many people in the channel, that's not likely to happen often, but if you're going to avoid your nick, you should avoid it completely. And I'm not sure what's with the ELSE. From looking at it, I'd say that everything after the ELSE should always happen, so you should probably remove that. Oh, and you don't have to do an evaluation when setting a dynamic variable... This works fine when setting the variable: set %var $+ . $+ $network $+ . $+ $chan or: set $+(%var,.,$network,.,$chan) It only needs evaluated (brackets or $eval()/$() ) when being read.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Mar 2010
Posts: 146
Vogon poet
|
Vogon poet
Joined: Mar 2010
Posts: 146 |
set $+(%var,.,$network,.,$chan) Should be: set $+(%,var.,$network,.,$chan)
Nothing...
|
|
|
|
Joined: Oct 2012
Posts: 164
Vogon poet
|
Vogon poet
Joined: Oct 2012
Posts: 164 |
In addition to what Riamus said, the $rand function should be seeking a number between 1 and $nick(#,0) = $nick($chan,$rand( 1,$nick($chan,0))) on +3:text:!winner:#:{
var %nick1 = $nick(#,$rand(1,$nick(#,0)))
while (%nick1 == $me) { %nick1 = $nick(#,$r(1,$nick(#,0))) }
msg # Randomly selected winner is %nick1 $+ ! Congratulations %nick1 you win... $eval($+(%,prize.,$network,.,#),2)
} And the other 2 events. on +3:text:!addprize *:#:{
set $+(%,prize.,$network,.,#) $2-
msg $chan New prize set!
}
on +3:text:!clprize:#: {
unset $+(%,prize.,$network,.,#)
msg $chan Prize cleared!
}
|
|
|
|
Joined: Jul 2006
Posts: 4,145
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,145 |
It only needs evaluated (brackets or $eval()/$() ) when being read. You also need the bracket (only) when using /unset in some situations, because of the 'limit' of /unset.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Oops. Missed my comma. Thanks, Masoud. And thanks, Wims, for mentioning /unset.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
|