random user

Back to Module Development

Page: 1  
From User Message Body
ahref
Post #578
Member
Date: 9:49 pm, Jul 23 2007
Posts: 20


hi im trying to get the nick of a random user from a channel ive tried everything with this code and it wont work :(:
Code

$channelData = $this->ircClass->getChannelData($this->chan);
$users = $channelData->memberList;
$ru = rand(0,count($users));
$user = $users[$ru]->nick;

what am i doing wrong?

thanks


Your friendly neighborhood bug magnet - ahref
ahref
Post #600
Member
Date: 1:52 pm, Aug 14 2007
Posts: 20


thanks to mad_clog ive found a solution. For further reference:

Code

$channelData = $this->ircClass->getChannelData(channel);
$users = $channelData->memberList;
sort($users);
$randU = $users[rand(0,count($users)-1)]->realNick;


will give a random user

Your friendly neighborhood bug magnet - ahref
   

Back to Module Development