22.05.2016, 23:41
And to print it, I need something simple, just to print statistics about specific faction (for Head of Faction-RP server)
#define MAX_FACTIONS 10 //See GetMemberCountInFaction for information regarding this.
new Ply_FactionID[MAX_PLAYERS]; //Something like this where their Current Faction ID is stored.
stock GetMemberCountInFaction(factionid){
if(factionid > (MAX_FACTIONS - 1) || factionid < 0)
return -1; /*We don't want to even run the loop to get an out of bounds error if the factionid is invalid.
Return -1 so that you'll know the faction ID is invalid and not that the faction is invalid and there just aren't
any players in it.
*/
new mcount;
for(new i = 0, x = GetPlayerPoolSize(); i <= x; i++){ //Loop through all of the players.
if(!IsPlayerConnected(i)) continue; //If they're not connected, skip them.
if(Ply_FactionID[i] == factionid) mcount ++; //If their faction matches the requested, add them to the count.
}
return mcount;
}