Indeed (depending on what approach to collecting valid players is taken). Here's an efficient and simple solution to a simple problem.
Code:
#include <amxmodx>
new bool:isConnected[33];
public client_putinserver(id)
isConnected[id] = true;
public client_disconnect(id)
isConnected[id] = false;
getRandomPlayer()
{
//returns player index or 0 if no players are found
static playerList[32];
new playerCount;
for(new i = 1; i < 33; i++)
{
if(!isConnected[i])
continue;
if(1 < get_user_team(i) < 4)
playerList[playerCount++] = i;
}
return playerCount ? playerList[random_num(0, playerCount - 1)] : 0;
}
Edit: this doesn't meet the request because I was following what the the other three did. :/
__________________