openmultiplayer / open.mp

Open Multiplayer, a multiplayer mod fully backwards compatible with SA-MP
https://open.mp
Mozilla Public License 2.0
452 stars 90 forks source link

Colors in console text #815

Open adib-yg opened 8 months ago

adib-yg commented 8 months ago

I just got this idea, I don't know if it is possible or not. but it's kinda cool.

Foreground

#define RESET "\033[0m"
#define FORE_GREEN "\033[32m"

printf(""FORE_GREEN"This is green"RESET"");

Background

#define RESET "\033[0m"
#define BACK_GREEN "\033[42m"

printf(""BACK_GREEN"Green background"RESET"");

Example output in omp-server console: image

BigETI commented 8 months ago

To begin with I would recommend prefixing them with the CONSOLE_ or CONSOLE_COLOUR_ keywords.

There are multiple types of console color escape sequences and there is no guarantee that a console supports all types of color escape sequences.

This thread explains them well: https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences