Using color defines
#1

I got some color defines:
Код:
#define	COLOR_BLACK		0x000000AA
#define	COLOR_WHITE		0xFFFFFFAA
#define	COLOR_GREEN		0x00FF00AA
#define	COLOR_RED		0xFF0000AA
#define	COLOR_BLUE		0x0000FFAA
#define	COLOR_YELLOW	0xFFFF00AA
#define	COLOR_ORANGE	0xFFBB00AA
#define	COLOR_PURPLE	0xFF00FFAA
#define	COLOR_GRAY		0xAFAFAFAA
#define	COLOR_LIGHTBLUE	0x0AFFFFAA
But there is an error on this line:
Код:
format(string, 128, "COLOR_YELLOW"Welcome back "COLOR_LIGHTBLUE"%s "COLOR_WHITE"\nplease type your password below to log in.", GetName(playerid));
This is the error:
Код:
C:\Users\Ruud\Documents\Samp\RP alles in 1\gamemodes\RP.pwn(194) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\Ruud\Documents\Samp\RP alles in 1\gamemodes\RP.pwn(194) : error 017: undefined symbol "Welcome"
C:\Users\Ruud\Documents\Samp\RP alles in 1\gamemodes\RP.pwn(194) : error 017: undefined symbol "back"
C:\Users\Ruud\Documents\Samp\RP alles in 1\gamemodes\RP.pwn(194) : fatal error 107: too many error messages on one line
Reply
#2

I believe you use hex codes for them.

IE:

pawn Код:
#define HEX_COLOR_YELLOW "{FFFF00}"

format(string,128,""HEX_COLOR_YELLOW"Welcome back");
Reply
#3

So, I do have to add the "{}"'s?
I thought I saw a tutorial without having to add that.
Reply
#4

Quote:
Originally Posted by xX4m4zingXx
Посмотреть сообщение
So, I do have to add the "{}"'s?
I thought I saw a tutorial without having to add that.
This way you can.
pawn Код:
#define COLOR_YELLOW    "0xFFFF00AA"

SendClientMessage(playerid,-1,""COLOR_YELLOW"Hi my name x");
Reply
#5

Quote:
Originally Posted by Ironboy
Посмотреть сообщение
This way you can.
pawn Код:
#define COLOR_YELLOW    "0xFFFF00AA"

SendClientMessage(playerid,-1,""COLOR_YELLOW"Hi my name x");
Thank you, but this doesn't fix my errors?
What is wrong?
Reply
#6

You need to use two different definitions one for normal usage and the other for strings

pawn Код:
#define COLOR_BLACK     0x000000AA
#define COLOR_WHITE     0xFFFFFFAA
#define COLOR_GREEN     0x00FF00AA

#define STR_COLOR_BLACK "{000000}"
#define STR_COLOR_WHITE "{FFFFFF}"
#define STR_COLOR_GREEN "{00FF00}"
Reply
#7

I've found out that it wasn't the problem of the colors.
It's because of another line, which is:
Код:
if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        new string[128], playerName[24];
		GetPlayerName(playerid, playerName, sizeof(playerName));
		format(string, sizeof(string), COLOR_YELLOW"Welcome back "COLOR_LIGHTBLUE"%s "COLOR_WHITE"\nplease type your password below to log in.", GetName(playerid));
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, COLOR_WHITE"Login", string, "Login", "Quit");
    }
and this is the error

Код:
C:\Users\Ruud\Documents\Samp\RP alles in 1\gamemodes\RP.pwn(194) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\Ruud\Documents\Samp\RP alles in 1\gamemodes\RP.pwn(194) : warning 215: expression has no effect
C:\Users\Ruud\Documents\Samp\RP alles in 1\gamemodes\RP.pwn(194) : error 001: expected token: ";", but found "-integer value-"
C:\Users\Ruud\Documents\Samp\RP alles in 1\gamemodes\RP.pwn(194) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\Ruud\Documents\Samp\RP alles in 1\gamemodes\RP.pwn(194) : fatal error 107: too many error messages on one line
Reply
#8

PHP код:
#define COLOR_YELLOW "{FFFF00}" 
Reply
#9

You have to give the hex code inside the quotation mark to use it as you wanted.

pawn Код:
#define COLOR_YELLOW "0xFFFF00FF"
pawn Код:
format(string, sizeof(string), ""COLOR_YELLOW"Welcome back "COLOR_LIGHTBLUE"%s\n"COLOR_WHITE"please type your password below to log in.", GetName(playerid));
Reply
#10

Thank you both.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)