Must be ages ago since i wrote that simple code and still accomplished to miserably fail in using get_players() and checking for teams correctly.
It also appears i still had a code laying around that looks better at first sight. Try this one instead, it should also work for bots.
PHP Code:
/* Sublime AMXX Editor v2.2 */
#pragma semicolon 1
#include <amxmodx>
#define PLUGIN "Show Players"
#define VERSION "1.0"
#define AUTHOR "LadderGoat"
#define MSGID 81045
#if !defined MAX_PLAYERS
const MAX_PLAYERS = 32;
#endif
enum _:ePlayerInfo
{
iTotalPlayers,
iCtPlayers,
iCtAlive,
iTerPlayers,
iTerAlive
};
new iInfo[ePlayerInfo];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
}
public client_putinserver(id)
{
iInfo[iTotalPlayers]++;
if(!task_exists(MSGID))
{
set_task(10.0, "displayMessage", MSGID);
}
}
#if AMXX_VERSION_NUM < 183
public client_disconnect(id)
#else
public client_disconnected(id)
#endif
{
iInfo[iTotalPlayers]--;
if(iInfo[iTotalPlayers] == 0 && task_exists(MSGID))
{
remove_task(MSGID);
}
}
public displayMessage()
{
if(task_exists(MSGID))
{
new iPlayers[MAX_PLAYERS], iNum;
get_players(iPlayers, iNum, "e", "TERRORIST");
iInfo[iTerPlayers] = iNum;
get_players(iPlayers, iNum, "ae", "TERRORIST");
iInfo[iTerAlive] = iNum;
get_players(iPlayers, iNum, "e", "CT");
iInfo[iCtPlayers] = iNum;
get_players(iPlayers, iNum, "ae", "CT");
iInfo[iCtAlive] = iNum;
get_players(iPlayers, iNum);
for(new i; i < iNum; i++)
{
set_hudmessage(random(255), random(255), random(255), -1.0, 0.0, 0, 0.0, 1.1, 0.1, 0.2, -1);
show_hudmessage(iPlayers[i], "Terrorists: %i/%i | Counter-Terrorists: %i/%i",
iInfo[iTerAlive], iInfo[iTerPlayers],
iInfo[iCtAlive], iInfo[iCtPlayers]);
}
set_task(1.0, "displayMessage", MSGID);
}
}
EDIT: I took the time to set up a server and can confirm this plugin works, just didn't test it with bots yet.
__________________