Raised This Month: $32 Target: $400
 8% 

Inserting Hex code for text color


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dustinandband
Senior Member
Join Date: May 2015
Old 11-13-2018 , 18:47   Inserting Hex code for text color
Reply With Quote #1

What's the correct way to format this? I've tried several combinations of different things and nothing's working. I'm wanting to color the client's name the same color you see in in-game team chat (testing in L4D2). I know the color is 0x99CCFF .

I don't want to make a dependency on an include file - so I'd rather manually do this myself.

Code:
#define BLUE 0x99CCFF
PrintToChatAll("\x01\x07%06x%N \x01 : Test Message", BLUE, client);
Prints this:
99CCFFdustin : Test Message

I've tried inserting a decimal in various places in the '06' and also capitalizing the X after the 06 (Deathreus's suggestion) but I can't seem to get it working.

Edit: this is originally where I got the idea
https://forums.alliedmods.net/showpo...22&postcount=4

Last edited by dustinandband; 11-13-2018 at 18:48.
dustinandband is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 11-13-2018 , 19:40   Re: Inserting Hex code for text color
Reply With Quote #2

If you want literal bytes in the output, you have to use a series of %c. %x prints a 32-bit number as hex (i.e. a string).
Fyren is offline
dustinandband
Senior Member
Join Date: May 2015
Old 11-13-2018 , 20:12   Re: Inserting Hex code for text color
Reply With Quote #3

Would it be beyond you to post an example or some other code that does this... I searched github for .sp files that contain '0x99CCFF' and posted to the discord. This forum post was a last resort..
dustinandband is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 11-13-2018 , 20:33   Re: Inserting Hex code for text color
Reply With Quote #4

The code seems correct to me.

However, as I've just tested, L4D2 doesn't support the multi-byte \x07 and \x08 color codes. It can only use the single-byte \x01-\x04 color codes.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode