Faction Color.
#1

Hello, I got a command which sets a color of a faction in the colum "Factions" the row is called "Color".

I have this faction chat.

pawn Код:
CMD:f(playerid, params[]) return cmd_faction(playerid, params);
CMD:faction(playerid, params[])
{
    new text[128];
    new color3;
    new factionid;
    Factions[factionid][fColor] = color3;
    if(sscanf(params,"s[128]",text)) return SyntaxMSG(playerid, "(/f)action [ooc chat]");
    if(PlayerInfo[playerid][pFaction] == 0) return SCM(playerid, COLOR_LIGHTRED, "Invalid faction.");
    if(Factions[PlayerInfo[playerid][pFaction]][fChatON] == 0) return SCM(playerid, COLOR_WHITE, "The OOC faction chat has been disabled by the leader.");
    if(strlen(text) > MAXLEN)
    {
        new pos = MAXLEN;
        if(pos < MAXLEN-1) pos = MAXLEN;
        format(msg, sizeof(msg), "**(( %s %s: %.*s ... ))**", GetRankName(playerid), GetNameEx(playerid), pos, text);
        if(PlayerInfo[playerid][pFaction] == LSPD)
            SendFactionMessage(PlayerInfo[playerid][pFaction], COLOR_LSPDNEW, msg);
        if(PlayerInfo[playerid][pFaction] == LSFD)
            SendFactionMessage(PlayerInfo[playerid][pFaction], FACTION_OOC, msg);
        format(msg, sizeof(msg), "**(( %s %s: ... %s ))**", GetRankName(playerid), GetNameEx(playerid), text[pos]);
        if(PlayerInfo[playerid][pFaction] == LSPD)
            SendFactionMessage(PlayerInfo[playerid][pFaction], COLOR_LSPDNEW, msg);
        if(PlayerInfo[playerid][pFaction] == LSFD)
            SendFactionMessage(PlayerInfo[playerid][pFaction], FACTION_OOC, msg);
    }
    else if(PlayerInfo[playerid][pFaction] == 3)
    {
        format(msg, sizeof(msg), "**(( %s %s: %s ))**", GetRankName(playerid), GetNameEx(playerid), text);
        SendFactionMessage(PlayerInfo[playerid][pFaction], color3, msg);
    }
    else
    {
        format(msg, sizeof(msg), "**(( %s %s: %s ))**", GetRankName(playerid), GetNameEx(playerid), text);
        if(PlayerInfo[playerid][pFaction] == LSPD)
            SendFactionMessage(PlayerInfo[playerid][pFaction], COLOR_LSPDNEW, msg);
        if(PlayerInfo[playerid][pFaction] == LSFD)
            SendFactionMessage(PlayerInfo[playerid][pFaction], FACTION_OOC, msg);
    }
    return 1;
}

Is there a way to use the color that is stored in my DB in the SendFactionMessage? And I am talking about faction number 3.
Reply
#2

I got it to work, yet it only shows a black colour in the faction chat no matter what I change it too.

pawn Код:
CMD:factioncolor(playerid, params[])
{
    if(!CheckAdmin(playerid, HIGH_ADMIN_LEVEL)) return NotAuthMSG(playerid);
    new factionid, color;
    if(sscanf(params,"dd", factionid, color)) return SyntaxMSG(playerid, "/factioncolor [factionid] [color]");
    if(!Factions[factionid][fON]) return SCM(playerid, -1, "Invalid faction.");
    Factions[factionid][fColor] = color;
    format(msg, sizeof(msg), "You have changed faction %d color to %d.", factionid, color);
    SCM(playerid, COLOR_GREEN, msg);
    format(query, sizeof(query), "UPDATE `factions` SET `color` = %d WHERE `id` = %d", color, Factions[factionid][fID]);
    mysql_function_query(dbHandle, query, false, "", "");
    return 1;
}
Reply
#3

Try using x instead of d if you expect hexadecimal input.
Reply
#4

Tried it, yet no result.. It still shows a black colour in the faction chat no matter what it's changed too.
Reply
#5

Anyone?
Reply
#6

How do you write the "color" part? when you use /factioncolor
Reply
#7

I am using numbers 0,1,2,3,4,5.. Also tried HEX codes.
Reply
#8

Shoulden't you change your colors to SendFactionMessage(PlayerInfo[playerid][pFaction], Factions[factionid][fColor], msg); ?
Reply
#9

Still can't seem to fix this, the colour remain black. Also should I use hex colours as input or..?
Reply
#10

Try with hex colors but change the intenger to h instead, so it goes if(sscanf(params,"dh", factionid, color))

And then you go like, 0xFFFFFFFF for white.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)