[Plugin] [REL] Console Colored Text 0.2 (New version)
#1

Console Useful Functions 0.3 by Cosmy

This plugin basically is same as Console Colored Text with some additions

Installation:
1) You need put "CUF.dll" in your plugin folder.
2) Open "server.cfg" and add this string: "plugins CUF".

Changelog:
v0.3
- SetConsoleTextColor() & GetConsoleTextColor() renamed to SetConsoleTextColors() & GetConsoleTextColors()
- Added printc(), printfc(), GetConsoleForegroundColor(), GetConsoleBackGroundColor(), SetConsoleTextColors()
- Name changed from CCT to CUF (Console Useful Functions)
- All code rewritten from scratch.
- Visual C++ 2010 Express project file.
- Now whole code is licensed under MIT.
- Added SetConsoleCursorPos(), GetConsoleCursorPos()

v0.2
- Added GetConsoleTextColor()

v0.1
- Initial version

post here comments, bugs etc...
Reply
#2

AWESOME!!!!
Great to notice the owner if something has to be fixed immedietaly like in a debug script
Reply
#3

Quote:
Originally Posted by Michael Sund
AWESOME!!!!
Great to notice the owner if something has to be fixed immedietaly like in a debug script
yeah
Reply
#4

printc(#consolecolour, string);
printfc(#consolecolour, string, arguments);
Reply
#5

hehe nice work cosmy ^^ i'll try it
Reply
#6

awesome man :P
Reply
#7

Quote:
Originally Posted by ssǝן‾ʎ
This looks cool but the dl limit has been reached. Could you upload it somewhere else like one of the custom SA:MP hosts:

http://www.zezombia.com/mirrors/
http://www.uploadffs.com/
http://up.mavehost.de/

Edit: Does this support both Windows and Linux?
What would be the point? You can't see the server console in Linux anyway.
Reply
#8

Cool, same suggestion as Contador

Also, not possible to make background AND text colors? Like..
pawn Код:
printc(bg_color, txt_color, string[]);

printc(0x0000FF, 0xFFFFFF, "Some white text on blue background");
Could be awesome
Reply
#9

Quote:
Originally Posted by 0rb
Cool, same suggestion as Contador

Also, not possible to make background AND text colors? Like..
pawn Код:
printc(bg_color, txt_color, string[]);

printc(0x0000FF, 0xFFFFFF, "Some white text on blue background");
Could be awesome
in the next version ^^

EDIT:
isn't possible
Reply
#10

Quote:
Originally Posted by ssǝן‾ʎ
Edit: Does this support both Windows and Linux?
nope. support only windows
Reply
#11

Don't triple post.

Also i thought this would colour all text, but i have to write text for it
Reply
#12

Ohh, you should say in first post that we can do this also, for setting text and background colors:
pawn Код:
SetConsoleTextColor(CONSOLE_WHITE | BACKGROUND_BLUE);
Or maybe make some other #define like
pawn Код:
#define WHITE_AND_BLUE  (CONSOLE_WHITE | BACKGROUND_BLUE)
EDIT: Even default cmd color codes are working!
pawn Код:
SetConsoleTextColor(0x1F);
That is still white text on blue background!

Color attributes are specified by two hex digits.
The first corresponds to the background color, the second to the foreground (text) color.
Each digit can be any of the following values:
Код:
0 = Black	 	
1 = Blue
2 = Green	
3 = Aqua
4 = Red
5 = Purple
6 = Yellow
7 = White
8 = Gray
9 = Light Blue
A = Light Green
B = Light Aqua
C = Light Red
D = Light Purple
E = Light Yellow
F = Bright White

Now is missing a function GetDefaultConsoleColors() in your plugin! (because it has bug actually, when console's default color isn't black/white). Can't wait

Last thing, can you please make it so we can choose where the background color will start and end (on the x axis). So this can maybe allow multiple colors in a single line. Because actually it starts at 0 (and ends at end of string, which make me think it's probably possible to set where it will start and where it will end too)
Reply
#13

Quote:
Originally Posted by 0rb
Ohh, you should say in first post that we can do this also, for setting text and background colors:
pawn Код:
SetConsoleTextColor(CONSOLE_WHITE | BACKGROUND_BLUE);
Or maybe make some other #define like
pawn Код:
#define WHITE_AND_BLUE  (CONSOLE_WHITE | BACKGROUND_BLUE)
EDIT: Even default cmd color codes are working!
pawn Код:
SetConsoleTextColor(0x1F);
That is still white text on blue background!

Color attributes are specified by two hex digits.
The first corresponds to the background color, the second to the foreground (text) color.
Each digit can be any of the following values:
Код:
0 = Black	 	
1 = Blue
2 = Green	
3 = Aqua
4 = Red
5 = Purple
6 = Yellow
7 = White
8 = Gray
9 = Light Blue
A = Light Green
B = Light Aqua
C = Light Red
D = Light Purple
E = Light Yellow
F = Bright White

Now is missing a function GetDefaultConsoleColors() in your plugin! (because it has bug actually, when console's default color isn't black/white). Can't wait

Last thing, can you please make it so we can choose where the background color will start and end (on the x axis). So this can maybe allow multiple colors in a single line. Because actually it starts at 0 (and ends at end of string, which make me think it's probably possible to set where it will start and where it will end too)
Quote:

Because actually it starts at 0 (and ends at end of string, which make me think it's probably possible to set where it will start and where it will end too)

the function "logprintf" do a new line... i can't do this feature

Quote:

Now is missing a function GetDefaultConsoleColors() in your plugin! (because it has bug actually, when console's default color isn't black/white). Can't wait
you can use "0x0000 | 0x0007" for default color.
Reply
#14

Quote:
Originally Posted by cosmy
you can use "0x0000 | 0x0007" for default color.
But that ISN'T my default color! My default color is blue/white not black/white.
Reply
#15

Quote:
Originally Posted by 0rb
Quote:
Originally Posted by cosmy
you can use "0x0000 | 0x0007" for default color.
But that ISN'T my default color! My default color is blue/white not black/white.
:O what os you have?
Reply
#16

Quote:
Originally Posted by cosmy
Quote:
Originally Posted by 0rb
Quote:
Originally Posted by cosmy
you can use "0x0000 | 0x0007" for default color.
But that ISN'T my default color! My default color is blue/white not black/white.
:O what os you have?
The only things you can run an SAMP server is linux / windows.
The default console colours on every MS os is White on Black. And I'm assuming it's the same for linux.
Reply
#17

Well i have XP, but i changed the default colors, now my default colors are blue background/white text, for every console window.

I think that it is possible to script a GetDefaultConsoleColors() (not in Pawn, obviously).
Of course i can also make my own define for my own default colors: #define MY_DEFAULT_COLORS 0x1F

Still, really nice work, looked the source, so simple

Reply
#18

Released new version. Added GetConsoleTextColor();
Reply
#19

Thanks, that fixed it

I suggest you change functions names
pawn Код:
SetConsoleColors(colors);
GetConsoleColors();
Reply
#20

Quote:
Originally Posted by 0rb
Thanks, that fixed it
pawn Код:
new default_colors = GetConsoleTextColor();

SetConsoleTextColor(0x04);
printf("test");

SetConsoleTextColor(default_colors);
I suggest you change functions names
pawn Код:
SetConsoleColors(colors);
GetConsoleColors();
you can do this with pawn :P

pawn Код:
#define SetConsoleTextColors(%1) SetConsoleTextColor(%1)
#define GetConsoleTextColors(%1) GetConsoleTextColor(%1)
but thank's i will fix in the next version :P
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)