06.06.2017, 03:09
how can i get how many player on server ?
new onlinePlayers;
public OnPlayerConnect(playerid)
{
onlinePlayers++;
return 1;
}
public OnPlayerDisconnect(playerid)
{
onlinePlayers--;
return 1;
}
CMD:players(playerid, params[])
{
new string[128];
format(string, sizeof(string), "Online players: %d", onlinePlayers);
SendClientMessage(playerid, -1, string);
return 1;
}
PHP код:
|
GetOnlinePlayers() { new player; for(new i = 0; i <= GetPlayerPoolSize(); i++) { if(IsPlayerConnected(i)) player++; } return player; } CMD:playersonline(playerid, params[]) { new string[22]; format(string, sizeof(string), "Online players: %d", GetOnlinePlayers()); SendClientMessage(playerid, -1, string); return 1; }
Код:
GetOnlinePlayers() { new player; for(new i = 0; i <= GetPlayerPoolSize(); i++) { if(IsPlayerConnected(i)) player++; } return player; } CMD:playersonline(playerid, params[]) { new string[30]; format(string, sizeof(string), "Online players: %d", GetOnlinePlayers()); SendClientMessage(playerid, -1, string); return 1; } |