PHP Code:
stock ActivePlayers(team /*1 = TR | 2 = CT*/, bool:alive = false) {
static players[32], num;
get_players(players, num, alive ? "aceh" : "bce", team == 1 ? "TERRORIST" : "CT");
return num;
}
Example plugin:
PHP Code:
#include <amxmodx>
new all_tt, all_ct;
new alive_tt, alive_ct;
public plugin_init() register_clcmd("say /test", "TestCommand");
public TestCommand(id) {
UpdatePlayers();
client_print(id, 3, "On the server is:");
client_print(id, 3, "%i terrorists (%i alive), %i cts (%i alive)", all_tt, alive_tt, all_ct, alive_ct);
}
stock UpdatePlayers() {
all_tt = ActivePlayers(1);
all_ct = ActivePlayers(2);
alive_tt = ActivePlayers(1, true);
alive_ct = ActivePlayers(2, true);
}
stock ActivePlayers(team, bool:alive = false) {
static players[32], num;
get_players(players, num, alive ? "aceh" : "bce", team == 1 ? "TERRORIST" : "CT");
return num;
}
Can also like this:
PHP Code:
stock ActivePlayers(CsTeams:team, bool:alive = false) {
static gracze[32], ile, i, active;
get_players(gracze, ile, alive ? "ach" : "bc");
active = 0;
for(i = 0; i < ile; ++i)
if(cs_get_user_team(gracze[i]) == team) active++;
return active;
}
Example plugin:
PHP Code:
#include <amxmodx>
#include <cstrike>
new all_tt, all_ct;
new alive_tt, alive_ct;
public plugin_init() register_clcmd("say /test", "TestCommand");
public TestCommand(id) {
UpdatePlayers();
client_print(id, 3, "On the server is:");
client_print(id, 3, "%i terrorists (%i alive), %i cts (%i alive)", all_tt, alive_tt, all_ct, alive_ct);
}
stock UpdatePlayers() {
all_tt = ActivePlayers(CS_TEAM_T);
all_ct = ActivePlayers(CS_TEAM_CT);
alive_tt = ActivePlayers(CS_TEAM_T, true);
alive_ct = ActivePlayers(CS_TEAM_CT, true);
}
stock ActivePlayers(CsTeams:team, bool:alive = false) {
static players[32], num, i, active;
get_players(players, num, alive ? "ach" : "bc");
active = 0;
for(i = 0; i < num; i++)
if(cs_get_user_team(players[i]) == team) active++;
return active;
}