[HELP] Dynamic Group Colours
#1

I have a command that allows the executer to change the colour of a group in game. And then whenever a person who is in that group does /gov, the chatline is supposed to match that colour. However, whenever I do this, the chatline is usually just BLACK.

pawn Код:
command(gov, playerid, params[])
{
    new message[128], string[128];
    if(sscanf(params, "z", message))
    {
        SendClientMessage(playerid, WHITE, "SYNTAX: /gov [message]");
    }
    else
    {
        if(Groups[Player[playerid][Group]][CommandTypes] == 1 && Player[playerid][Group] != 0 || Groups[Player[playerid][Group]][CommandTypes] == 4 && Player[playerid][Group] != 0)
        {
            if(Player[playerid][GroupRank] >= 8)
            {
                SendClientMessageToAll(GREY, "----------------------------- [Government Notice] ----------------------------- ");
                format(string, sizeof(string), "%s: %s says: %s", Groups[Player[playerid][Group]][GroupName], GetNameWithUnderscore(playerid), message);
                SendClientMessageToAll(Groups[Player[playerid][Group]][GroupColour], string);
            }
        }
        else
        {
            SendClientMessage(playerid, WHITE, "You're not a LEO.");
        }
    }
    return 1;
}
The colour saved for the group is FFFFFF which is supposed to be white. And obviously it is in HTML format. Why is the chat black?

(For reference here is the command you use to change the group colour)

pawn Код:
command(changegroupcolour, playerid, params[])
{
    new string[128], id, name[8];
    if(sscanf(params, "dz", id, name))
    {
        if(Player[playerid][AdminLevel] >= 5)
        {
            SendClientMessage(playerid, WHITE, "SYNTAX: /changegroupcolour [id] [new colour]");
            SendClientMessage(playerid, GREY, "Note: Colours are in HTML formate, usually containing 6-8 letters. (eg: ffffff)");
        }
    }
    else
    {
        if(Player[playerid][AdminLevel] >= 5)
        {
            format(string, sizeof(string), "Groups/Group_%d.ini", id);

            if(fexist(string))
            {
                format(Groups[id][GroupColour], 8, "%s", name);
                dini_Set(string, "GroupColour", Groups[id][GroupColour]);
                format(string, sizeof(string), "Group colour changed to '%s'.", name);
                SendClientMessage(playerid, WHITE, string);
            }
            else
            {
                SendClientMessage(playerid, WHITE, "Invalid Group ID.");
            }
        }
    }
    return 1;
}
REP+
Reply
#2

You're using the wrong color format. The SendClientMessage function doesn't use HTML type colors.

NOTE: There are methods for converting a HTML code to a usable hexadecimal format.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)