I wanna add chat colors to this plugin.
Right now it is like this:
I want it to be like this
*GREEN*
[Admins]
[Moderadores]
[VIPs]
[Patrocinadores]
*YELLOW*
Player1, Player2
Player 3
Player 4
I also wanna remove the space behind the word
[ Admin] (and all outhers) if possible
Here is the code of the plugin:
PHP Code:
#include <amxmodx>
#define ADMIN_CHECK ADMIN_LEVEL_A
#define MOD_CHECK ADMIN_LEVEL_B
#define VIP_CHECK ADMIN_LEVEL_C
#define PATROCINADOR_CHECK ADMIN_LEVEL_D
static const COLOR[] = "^x04";
static const CONTACT[] = "";
new maxplayers;
new gmsgSayText;
new sv_contactinfo;
public plugin_init() {
register_plugin("BSGD", "1.2", "PoLiCe");
gmsgSayText = get_user_msgid("SayText");
register_clcmd("say /admin", "print_list");
sv_contactinfo = register_cvar("sv_contactinfo", CONTACT, FCVAR_SERVER);
}
public print_list(user) {
set_task(0.1, "task_print_list", user);
}
public task_print_list(user) {
new players[32], pnum;
get_players(players, pnum);
new player;
new flags[32];
static names[32][32];
for(new i = 0; i < pnum; i++) {
player = players[i];
flags[i] = get_user_flags(player);
get_user_name(player, names[i], charsmax(names[]));
}
static const admin_flags[] = {ADMIN_CHECK, MOD_CHECK, VIP_CHECK, PATROCINADOR_CHECK};
static const admin_names[][] = {"Admins", "Moderadores", "VIPs", "Patrocinadores"};
static message[256];
new len;
new admin_flag;
new admins[32];
new count;
for(new i = 0, j; i < sizeof(admin_flags); i++) {
len = formatex(message, charsmax(message), "[%s%s] ", COLOR, admin_names[i]);
admin_flag = admin_flags[i];
count = 0;
for(j = 0; j < pnum; j++) {
if(flags[j] & admin_flag) {
admins[count++] = j;
}
}
if(count > 0) {
for(j = 0; j < count; j++) {
len += formatex(message[len], charsmax(message) - len, "%s%s", names[admins[j]], (j < (count - 1)) ? ", " : "");
if(len > 96 && (j < (count - 1))) {
print_message(user, message);
len = formatex(message, charsmax(message), "%s ", COLOR);
}
}
} else {
len += formatex(message[len], charsmax(message) - len, "Nao ha nenhum online.", admin_names[i]);
}
print_message(user, message);
}
static contact[64];
get_pcvar_string(sv_contactinfo, contact, charsmax(contact));
if(contact[0]) {
static contactinfo[256];
formatex(contactinfo, 111, "", COLOR, contact);
print_message(user, contactinfo);
}
}
print_message(id, msg[]) {
message_begin(MSG_ONE, gmsgSayText, {0,0,0}, id);
write_byte(id);
write_string(msg);
message_end();
}