mIRC Homepage
Posted By: HaleyJ alias help - 27/01/07 09:03 PM
Greetings
I put this together to return a random nick, but i added the r parameter that it should return only regular nicks on a channel, but for some reason its returning ops on a channel aswell, i dont want to add a bunch of if statements as it will make the code a little messy. Any help would be appreciated.
Thankyou

Code:
/randnick {
  var %randname = $nick($chan,$rand(1,$nick($chan,0,r)))
  if (%randname != $me) {
    return %randname
  }
}
Posted By: Scripto Re: alias help - 27/01/07 10:23 PM
Yes, it would... you have your $rand statement to retrieve a number. Then your $nick($chan(this is now the random number to mIRC))...wont re-identify only the "regular" nicks.

It sets a random number here ~~> $rand(1,$nick($chan,0,r))) then when mIRC sees the statement as a whole like this ~~> $nick($chan,$rand(1,$nick($chan,0,r))) it is referring to that random number that was made from only the total number of registered names on the channel, then finds that line number in the full nicklist, and returns that name. If that random number happened to be a 1 then it would return the top name in the full list... i.e. an op.


Try this:

Code:
/randnick {
  :start
  if ($nick($chan,0,r) > 0) {
    var %a = $rand(1,$nick($chan,0))
    if ($nick($chan,%a) isreg $chan) return $nick($chan,%a) 
    else goto start
  }
}
 


Then where you have your call to $randnick you will want to write it so that it states...

Code:

if ($randnick) { then do this }

 


Otherwise, if there are no regular nicks in the channel, $randnick will be an empty string, and you will get an error.
Posted By: Riamus2 Re: alias help - 27/01/07 11:03 PM
As Scripto mentioned, you needed to have it just looking at regular users in both places. However, you don't need to do a loop. Just use this:

Code:
var %randname = $nick($chan,$rand(1,$nick($chan,0,r)),r)

Posted By: Scripto Re: alias help - 27/01/07 11:15 PM
Yes, that is nicer. Well done. I saw the light.. It was so bright that I couldn't put it into words... lol cool
Posted By: Riamus2 Re: alias help - 27/01/07 11:16 PM
Lol. laugh
Posted By: HaleyJ Re: alias help - 27/01/07 11:31 PM
Thanks to both of you.
© mIRC Discussion Forums