23.07.2016, 18:47
Make a global array variable:
Set its value to 1 when the player joins the deathmatch
Set its value to 0 when the player leaves the deathmatch
Also set its value to 0 when the layer disconnects so it wont effect the other players who join the server
Now make a loop and count the players in deathmatch
Example command:
Код:
new InDM[MAX_PLAYERS];
Код:
new InDM[playerid] = 1;
Код:
new InDM[playerid] = 0;
Код:
new InDM[playerid] = 0;
Код:
for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(InDM[i] == 1) { count++; } } }
Код:
CMD:playersindm(playerid, params[]) { new count; new string[50]; for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(InDM[i] == 1) { count++; } } } format(string, sizeof(string), "There are %d players in deathmatch", count); SendClientMessage(playerid, 0xFFFFFFFF, string); return 1; }