mIRC Home    About    Download    Register    News    Help

Print Thread
#242360 08/07/13 12:18 AM
T
tupen
tupen
T
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 smile 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!
}

#242363 08/07/13 10:18 AM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
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:
Code:
set %var $+ . $+ $network $+ . $+ $chan


or:

Code:
set $+(%var,.,$network,.,$chan)


It only needs evaluated (brackets or $eval()/$() ) when being read.

Joined: Mar 2010
Posts: 144
Vogon poet
Vogon poet
Joined: Mar 2010
Posts: 144
Originally Posted By: Riamus2

Code:
set $+(%var,.,$network,.,$chan)



Should be:
Code:
set $+(%,var.,$network,.,$chan)




Nothing...
#242365 08/07/13 02:58 PM
D
Deega
Deega
D
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)))

Code:
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.
Code:
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,062
W
Hoopy frood
Hoopy frood
W
Joined: Jul 2006
Posts: 4,062
Originally Posted By: Riamus2
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,061
R
Hoopy frood
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Oops. Missed my comma. Thanks, Masoud. And thanks, Wims, for mentioning /unset.


Link Copied to Clipboard