SA-MP Forums Archive
[HELP] Dynamic Group Colours - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] Dynamic Group Colours (/showthread.php?tid=557159)



[HELP] Dynamic Group Colours - BornHuman - 12.01.2015

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+


Re: [HELP] Dynamic Group Colours - Abagail - 12.01.2015

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.