rendered paste bodysub getchannelplayerlist
{
#will return a array of array all players with all player infos, parameter is $c_id, $sock
# 0=p_id 1=p_nick 2=sa 3=ca 4=o 5=ao 6=v 7=av 8=cst 9=reg
if(@_ != 2)
{
warn "Calling function getchannelplayerlist without right parameter count, aborting\n";
return 0;
}
my $channel_id = $_[0];
my $sock = $_[1];
my @return_array = ();
my @user_to_push = ();
my $DEBUG = 0;
my $found_start = 0;
print $sock qq(ci $channel_id\n);
while (<$sock>)
{
if($found_start)
{
if(/^(\d+)\s+([^\r\n\f]*)\s+(\d)\s+(\d)\s+(\d)\s+(\d)\s+(\d)\s+(\d)\s+(\d)\s+(\d)\s*$/)
# $1=p_id $2=p_nick $3=sa $4=ca $5=o $6=ao $7=v $8=av $9=cst $10=reg
{
@user_to_push = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);
push @return_array, [ @user_to_push ];
}
elsif(/^OK\s*$/)
{
return @return_array;
}
else
{
warn "We got some weird output, aborting. Output was: \n$_\n";
return @return_array;
}
}
elsif(/^p_id\s+p_nick\s+sa\s+ca\s+o\s+ao\s+v\s+av\s+cst\s+reg\s*$/)
{
$found_start = 1;
}
elsif(/^OK\s*$/)
{
return @return_array;
}
else
{
last if /^error/i;
}
}
warn "We realy shouldnt have gotten here ? Oh well, life is weird :P\n";
return @return_array;
}