Raised This Month: $ Target: $400
 0% 

Color Text in print_chat


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 04-16-2012 , 12:28   Color Text in print_chat
Reply With Quote #1

I've been going through a few different plugins that i'm working on, as well as reading source for a number of other plugins as an example and i just can't figure out how to print colored messages to clients via the chat box. I know using escape characters of ^x01 ^x03 and ^x04 for normal, team, and green, but i just can't seem to get it to work. I originally though it was because i wasn't importing the proper (header files?) -whatever #include imports- but none of them have worked. I'll put in my code to see if i did something wrong. PLEASE HELP! I've been trying for about 2 months now and i can't find it on the forums either. This is quite blowing my life, and i have a few mods that i'm holding off full release till i can get this functionality included.

mind you this is just a snippet of a much larger program (actually using file and string) but i tend to put a bit of vulgarity in my code, so i deleted the rest to bring it down to G rating. But this is stand alone code.

Code:
#include <amxmodx>
#include <amxmisc>
#include <file>
#include <string>

#define PLUGIN	"ColorChat"
#define AUTHOR	"Liverwiz"
#define VERSION	"0.7"

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_clcmd("colorchat", "cmd_clrChat")  
}

public cmd_clrChat(id)
{
	new msg[42] = "^x01"
	new saytxt = get_user_msgid("SayText")
	/*
	* COLOR ESCAPE CHARACTERS
	* 	Team - ^x03
	* 	Normal - ^x01
	* 	Green - ^x04
	*/
	format(msg, 41, "[^x01Normal^x01] [^x03Team^x01] [^x04Green^x01]")
	message_begin(MSG_ONE, saytxt, {0,0,0}, id)
	write_byte(id)
	write_string(msg)
	message_end()
	return PLUGIN_HANDLED
}
I am compiling using the amxmodx.org webcompiler running on a server running amxmodx 1.8.x
winner will receive bacon.
Liverwiz is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-16-2012 , 12:30   Re: Color Text in print_chat
Reply With Quote #2

That code should work.

However, you might find it eaiser to work with ColorChat.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 04-16-2012 , 12:52   Re: Color Text in print_chat
Reply With Quote #3

Much thanks for the quick response! I'll post a screenshot of what it currently displays at the execution of "colorchat"

Then i'll integrate ConnorMcLeod's ways and report back.
Thumbs up suffice instead of bacon? As per the problem hasn't been solved YET....

Its also peculiar that it has spaces where the special characters are.

Last edited by Liverwiz; 04-16-2012 at 13:02. Reason: Not spamming the thread with meaningless posts just for a picture
Liverwiz is offline
Old 04-16-2012, 13:01
hleV
This message has been deleted by hleV.
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 04-16-2012 , 15:54   Re: Color Text in print_chat
Reply With Quote #4

VICTORY!! Using ConnorMcLeod's include file <colorchat> and compile locally i finally was able to get that color to work!! Many thankyou's Exolent. You and ConnorMcLeod have both earned bacon!



one each.
Liverwiz is offline
Reply


Thread Tools
Display Modes

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 07:43.


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