Raised This Month: $ Target: $400
 0% 

Color Text in print_chat


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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