Posts: 1,219
Threads: 51
Joined: Jul 2012
Quote:
Originally Posted by Eoussama
Suppose you have 3 gangs G1 G2 G3,
you can put it this way
PHP код:
new Count1, //This will store the number of connected players in gang number 1
Count2, //This will store the number of connected players in gang number 2
Count3; //This will store the number of connected players in gang number 3
//Now loop through all players
for(new i=0;i<GetPlayerPoolSize();i++){
if(!IsPlayerConnected(i)) continue; //If the player is not connected, the following lines won't be executed for that specific player id, so the seleced id will increment
if(PlayerGang[i] == G1) Gcount1++; //if a player is in gang 1 the GCount1 variable will increment
if(PlayerGang[i] == G2) GCount2++; //if a player is in gang 2 the GCount2 variable will increment
if(PlayerGang[i] == G3) GCount3++; //if a player is in gang 3 the GCount3 variable will increment
}
//Now display the results
printf("Connected Members from gang 1: %d",GCount1);
printf("Connected Members from gang 2: %d",GCount2);
printf("Connected Members from gang 3: %d",GCount3);
//Replace the PlayerGang[MAX_PLAYERS] array with your own
|
A little criticism of mine, if you give examples, you might want to consider doing it properly :P
Posts: 1,046
Threads: 250
Joined: Nov 2014
Reputation:
0
Maybe also tell him where to put this code, I don't think he knows.
Posts: 1,219
Threads: 51
Joined: Jul 2012
Quote:
Originally Posted by Eoussama
Thanks for the advice, I would like to know tho, what did I do wrong?
Tnx in advance
|
unnecessary ifs (use else ifs or switch), calling GetPlayerPoolSize every time instead of once , called the variables at the top: Count(Number), but used GCount(Number)
Posts: 51
Threads: 19
Joined: Jul 2014
Reputation:
0
I don't want it to be a seperate command though? I just want it like i've set it out to be.
I just want it to be a command doing /families and it tells you the following about the families:
Gang name:
Leader:
Members:
Members online:
Posts: 244
Threads: 4
Joined: Apr 2010
Reputation:
0
create a new variable called "FamilyInfo[i][FamilyOnline]" (for example).
if a player is connecting set the variable + 1 for his family.
set it minus 1 when he is disconnecting.
easiest solution.
and why do you need the scanff there?
the player is typing a ID but you anyways show him the information of all families.