About colors..
#1

Hi, how do i make that it will show the family number with the family color?

i tried this

pawn Код:
for(new i = 0; i < sizeof(FamilyInfo); i++)
                {
                    number ++;
                    format(string, sizeof(string), ""FamilyInfo[i][FamilyColor]"Family %d"COL_WHITE"| Name: %s | Leader: %s | Members: %d | Warnings: %d/3.",number,FamilyInfo[i][FamilyName],FamilyInfo[i][FamilyLeader],FamilyInfo[i][FamilyMembers],FamilyInfo[i][FStrikes]);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                }
Reply
#2

If you want to use a " inside a string you should escape it with a \. See this page for more information.

For the color, try this:
Код:
format(string, sizeof(string), "Sometext {%06x}othertext {%06x}moretext.", FamilyInfo[i][FamilyColor] >>> 8, COL_WHITE >>> 8);
SendClientMessage(playerid, COL_WHITE, string);
Say the family color is red, this will look like this: Sometext othertext moretext.
The first part of the string is white, because we use COL_WHITE in SendClientMessage.
Reply
#3

Quote:
Originally Posted by Freaksken
Посмотреть сообщение
If you want to use a " inside a string you should escape it with a \. See this page for more information.

For the color, try this:
Код:
format(string, sizeof(string), " Sometext {%06x}othertext {%06x}moretext.", FamilyInfo[i][FamilyColor] >>> 8, COL_WHITE >>> 8);
SendClientMessage(playerid, COL_WHITE, string);
Say the family color is red, this will look like this: Sometext othertext moretext.
I dont really think i understand what you mean
Reply
#4

Ok, say you have this at the top of your script:
Код:
#define COLOR_WHITE 0xFFFFFFFF
See the 0x part? That tells the compiler that FFFFFFFF is a hexadecimal number.

Now, when we look at the string formatting page, you can see that to display a hexadecimal number in a string, you need to use %x. The 6 makes sure that it will always be 6 characters long (instead of the 8 F's we only use the first 6 F's, so FFFFFFFF will become FFFFFF) and the 0 adds zeros if it is less than 6 characters long (FFFF will become 00FFFF). The {} is used to embed a color in a string.

So if we have:
Код:
#define COLOR_BLUE 0x0000FFFF
#define COLOR_RED 0xFF0000FF
new myNumber = 4;
format(string, sizeof(string), "Sometext {%06x}%d.", COLOR_RED, myNumber);
SendClientMessage(playerid, COLOR_BLUE, string);
It will display as: Sometext 5.
Reply
#5

Also, this is for my /families command, i want it to show the family number, with the same color as the Familys color

original code:
pawn Код:
if(strcmp(cmd, "/families", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                new number = 0;
                for(new i = 0; i < sizeof(FamilyInfo); i++)
                {
                    number ++;
                    format(string, sizeof(string), "Family %d| Name: %s | Leader: %s | Members: %d | Warnings: %d/3.",number,FamilyInfo[i][FamilyName],FamilyInfo[i][FamilyLeader],FamilyInfo[i][FamilyMembers],FamilyInfo[i][FStrikes]);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                }
                format(string, sizeof(string), "Family 11| Name: Yakuza | Leader: none");
                SendClientMessage(playerid, COLOR_WHITE, string);
                format(string, sizeof(string), "Family 12| Name: Mafia | Leader: none");
                SendClientMessage(playerid, COLOR_WHITE, string);
                format(string, sizeof(string), ""COL_BALLAS"13 Public Gang"COL_WHITE"| Name: Ballas | Leader: none");
                SendClientMessage(playerid, COLOR_WHITE, string);
                format(string, sizeof(string), ""COL_VAGOS"14 Public Gang"COL_WHITE"| Name: Vagos | Leader: none");
                SendClientMessage(playerid, COLOR_WHITE, string);
                format(string, sizeof(string), ""COL_HOMELESS"16 Public Gang"COL_WHITE"| Name: Homeless | Leader: none");
                SendClientMessage(playerid, COLOR_WHITE, string);
                return 1;
            }
            new family = strval(tmp);
            if(family < 1 || family > 20) { SendClientMessage(playerid, COLOR_GREY, "Enter a family number between 1 and 16"); return 1; }
            family -= 1;
            if(family < 10)
            {
                if(FamilyInfo[family][FamilyTaken] != 1)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   That family number hasn't been taken yet!");
                    return 1;
                }
            }
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    if(family == 10)
                    {
                        if(PlayerInfo[i][pMember] == 6) // Yakuza
                        {
                            format(string, sizeof(string), "* Yakuza: %s %s | Rank: %d.",GetPlayerRank(i),RemoveUnderScore(i),PlayerInfo[i][pRank]);
                            SendClientMessage(playerid, COLOR_GREY, string);
                        }
                    }
                    else if(family == 11)
                    {
                        if(PlayerInfo[i][pMember] == 5) // Mafia
                        {
                            format(string, sizeof(string), "* Mafia: %s %s | Rank: %d.",GetPlayerRank(i),RemoveUnderScore(i),PlayerInfo[i][pRank]);
                            SendClientMessage(playerid, COLOR_GREY, string);
                        }
                    }
                    else if(family == 12)
                    {
                        if(PlayerInfo[i][pMember] == 15) // ballas
                        {
                            format(string, sizeof(string), "* Ballas: %s %s | Rank: %d.",GetPlayerRank(i),RemoveUnderScore(i),PlayerInfo[i][pRank]);
                            SendClientMessage(playerid, COLOR_GREY, string);
                        }
                    }
                    else if(family == 13)
                    {
                        if(PlayerInfo[i][pMember] == 16) // vagos
                        {
                            format(string, sizeof(string), "* Vagos: %s %s | Rank: %d.",GetPlayerRank(i),RemoveUnderScore(i),PlayerInfo[i][pRank]);
                            SendClientMessage(playerid, COLOR_GREY, string);
                        }
                    }
                    else if(family == 14)
                    {
                        if(PlayerInfo[i][pMember] == 12) // hell's rebels
                        {
                            format(string, sizeof(string), "* Hell's Rebels: %s %s | Rank: %d.",GetPlayerRank(i),RemoveUnderScore(i),PlayerInfo[i][pRank]);
                            SendClientMessage(playerid, COLOR_GREY, string);
                        }
                    }
                    else
                    {
                        if(PlayerInfo[i][pFMember] == family)
                        {
                            format(string, sizeof(string), "* %s: %s %s | Rank: %d.",FamilyInfo[family][FamilyName],GetPlayerRank(i),RemoveUnderScore(i),PlayerInfo[i][pRank]);
                            SendClientMessage(playerid, COLOR_GREY, string);
                        }
                    }
                }
            }
        }
        return 1;
    }
Reply
#6

  • Show me the lines where you want the number and color to appear.
  • Show me where the family number and color are stored.
Reply
#7

Quote:
Originally Posted by Freaksken
Посмотреть сообщение
  • Show me the lines where you want the number and color to appear.
  • Show me where the family number and color are stored.
This is the line in /families
pawn Код:
for(new i = 0; i < sizeof(FamilyInfo); i++)
                {
                    number ++;
                    format(string, sizeof(string), "Family %d| Name: %s | Leader: %s | Members: %d | Warnings: %d/3.",number,FamilyInfo[i][FamilyName],FamilyInfo[i][FamilyLeader],FamilyInfo[i][FamilyMembers],FamilyInfo[i][FStrikes]);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                }
pawn Код:
enum fInfo
{
    FamilyTaken,
    FamilyName[20],
    FamilyMOTD[128],
    FamilyColor[20],
    FamilyLeader[MAX_PLAYER_NAME],
    FamilyMembers,
    Float:FamilySpawn[4],
    FamilyInterior,
    Float:FamilySafePos[3],
    FamilyPot,
    FamilyCrack,
    FamilyMats,
    FamilyMatsb,
    FamilyMatsc,
    FamilyMatsd,
    PickupID,
    FamilySafe,
    FamilyBank,
    FamilyCash,
    FStrikes,
};
new FamilyInfo[10][fInfo];
Reply
#8

the colors are saved in families.cfg
Reply
#9

I don't see why FamilyColor[20] is an array/string, colors are numbers...
If FamilyColor is an integer, FamilyInfo[i][FamilyColor] = 0xFFFFFFFF; works...

But anyway.
Код:
format(string, sizeof(string), "Family {%06x}%d{%06x} | Name: %s | Leader: %s | Members: %d | Warnings: %d/3.", FamilyInfo[i][FamilyColor] >>> 8, number, COLOR_WHITE >>> 8, FamilyInfo[i][FamilyName], FamilyInfo[i][FamilyLeader], FamilyInfo[i][FamilyMembers], FamilyInfo[i][FStrikes]);
SendClientMessage(playerid, COLOR_WHITE, string);
Say the family color of family 1 is red, this will appear as: Family 1 | Name: ...
Keep in mind that embedding colors takes up characters in the string. SenClientMessage can display a max of 144 characters.
If you use a color, you will be able to use 144 - 8 = 136 characters. If you use 2 colors 128, and so on...
In this case we use 2 colors.
Reply
#10

Quote:
Originally Posted by Freaksken
Посмотреть сообщение
I don't see why FamilyColor[20] is an array/string, colors are numbers...
If FamilyColor is an integer, FamilyInfo[i][FamilyColor] = 0xFFFFFFFF; works...

But anyway.
Код:
format(string, sizeof(string), "Family {%06x}%d{%06x} | Name: %s | Leader: %s | Members: %d | Warnings: %d/3.", FamilyInfo[i][FamilyColor] >>> 8, number, COLOR_WHITE >>> 8, FamilyInfo[i][FamilyName], FamilyInfo[i][FamilyLeader], FamilyInfo[i][FamilyMembers], FamilyInfo[i][FStrikes]);
SendClientMessage(playerid, COLOR_WHITE, string);
Say the family color of family 1 is red, this will appear as: Family 1 | Name: ...
Keep in mind that embedding colors takes up characters in the string. SenClientMessage can display a max of 144 characters.
If you use a color, you will be able to use 144 - 8 = 136 characters. If you use 2 colors 128, and so on...
In this case we use 2 colors.
I put that, but now they are just all black
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)