04.12.2012, 14:35
How to check the amount of players online? I want to make my command work when it's higher than an x number of players.
stock GetOnlinePlayers()
{
new amount;
foreach(Player, i)
{
//if(IsPlayerConnected(i))
amount++;
}
return amount;
}
if(GetOnlinePlayers() < 20) return SendClientMessage(playerid, -1, "There are not enough players online to do this!");
stock GetOnlinePlayers()
{
new amount;
for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
amount++;
}
return amount;
}
stock GetOnlinePlayers()
{
new count;
for(new i; i != GetMaxPlayers(); ++i)
{
if(!IsPlayerConnected(i)) continue;
count++;
}
return count;
}
new gConnectedPlayers = 0;
public OnPlayerConnect(playerid)
{
++gConnectedPlayers;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
--gConnectedPlayers;
return 1;
}