23.07.2016, 18:27
I there any way why how to make players count who is in DM example Sniper DM: 2 players ?
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; }
//@top of the script
new sniperCounter,bool:inSniper[MAX_PLAYERS char];
//If the player enters the sniper Arena
if(!inSniper{playerid})
{
sniperCounter++;
inSniper{playerid} = true;
}
//If the player leaves the sniper
sniperCounter--;
inSniper{playerid} = false;
//If the player disconnects
if(inSniper{playerid})
{
sniperCounter--;
inSniper{playerid} = false;
}
//And the value of sniperCounter = the player amount who are there
Make a global array variable:
Код:
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; } |
Make a global array variable:
Код:
new InDM[MAX_PLAYERS]; Код:
new InDM[playerid] = 1; Код:
new InDM[playerid] = 0; Код:
new InDM[playerid] = 0; Код:
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), "%s Has Joined in Sniper DM Total players %d ",GetName(playerid),count); SendClientMessage(playerid, 0xFFFFFFFF, string); return 1; } |
GetName(playerid) { new pName[24]; GetPlayerName(playerid, pName, 24); return pName; }