mIRC Home    About    Download    Register    News    Help

Print Thread
#169774 27/01/07 09:03 PM
Joined: Jul 2006
Posts: 242
H
HaleyJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
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
  }
}


Newbie
HaleyJ #169779 27/01/07 10:23 PM
Joined: Dec 2006
Posts: 80
Babel fish
Offline
Babel fish
Joined: Dec 2006
Posts: 80
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.


Scripto ---- Life is about the relationships. The correct code being: $replace($them,$you,$me)
HaleyJ #169781 27/01/07 11:03 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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)



Invision Support
#Invision on irc.irchighway.net
Riamus2 #169785 27/01/07 11:15 PM
Joined: Dec 2006
Posts: 80
Babel fish
Offline
Babel fish
Joined: Dec 2006
Posts: 80
Yes, that is nicer. Well done. I saw the light.. It was so bright that I couldn't put it into words... lol cool


Scripto ---- Life is about the relationships. The correct code being: $replace($them,$you,$me)
Scripto #169787 27/01/07 11:16 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Lol. laugh


Invision Support
#Invision on irc.irchighway.net
Riamus2 #169788 27/01/07 11:31 PM
Joined: Jul 2006
Posts: 242
H
HaleyJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
Thanks to both of you.


Newbie

Link Copied to Clipboard