AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Color Text in print_chat (https://forums.alliedmods.net/showthread.php?t=183046)

Liverwiz 04-16-2012 12:28

Color Text in print_chat
 
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. :cry: 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,:twisted: 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.

Exolent[jNr] 04-16-2012 12:30

Re: Color Text in print_chat
 
That code should work.

However, you might find it eaiser to work with ColorChat.

Liverwiz 04-16-2012 12:52

Re: Color Text in print_chat
 
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.... :up:

Its also peculiar that it has spaces where the special characters are.
http://cloud.steampowered.com/ugc/59...9C8B921877632/

Liverwiz 04-16-2012 15:54

Re: Color Text in print_chat
 
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!

:bacon!:
:bacon!:
one each.


All times are GMT -4. The time now is 07:43.

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