Beware that Relaxing's method is non-deterministic and can freeze your server for an amount of time. It will also be an infinite loop if all players have free day (which will look like your server freezes permanently).
Here is a version that has a maximum execution time (32 iterations) and therefore will never cause an infinite loop. If no player no player is found, it will return zero.
PHP Code:
public random_nonfreeday_player()
{
new iPlayers[32], iPlayersNum, index
get_players(iPlayers, iPlayersNum)
new iRandomIndex = random(iPlayersNum)
for( new i = 0; i < iPlayersNum; i++ )
{
index = (iRandomIndex + i) % iPlayersNum
if( !is_user_freeday(iPlayers[index]) )
{
return iPlayers[index]
}
}
return 0
}
__________________