I've seen this question sorta asked before, but the answer didn't help me. The faq says to change send_to_char to send_to_char_color or whatever. Here's my problem-I want have it add color to who, but its sprintf not send_to_char. And I also want to be able to use colors in room desc. Anyone help?
Color
Posted by Zeno on Fri 17 Jan 2003 01:11 AM — 12 posts, 32,113 views.
do something like this..
declare this at the top of the function.
char buf[MAX_STRING_LENGTH];
then wherever you want color in the function, do something like this:
sprintf(buf, "This name be colored bright RED: &R%s", ch->name);
send_to_char(buf, ch);
Understand? If you need more clarification, post it ;-)
p.s. this assumes you have made teh necessary changes to colorize EVERYTHING sent to send_to_char otherwise, use send_to_char_color(buf, ch);
declare this at the top of the function.
char buf[MAX_STRING_LENGTH];
then wherever you want color in the function, do something like this:
sprintf(buf, "This name be colored bright RED: &R%s", ch->name);
send_to_char(buf, ch);
Understand? If you need more clarification, post it ;-)
p.s. this assumes you have made teh necessary changes to colorize EVERYTHING sent to send_to_char otherwise, use send_to_char_color(buf, ch);
I tried that. The rank is now replaced with
'''
'''
Hmm Maybe you could post a bit of your code so we can check it out.
{
char buf[MAX_STRING_LENGTH];
(Other code stuff)
sprintf(buf, class_text, "[&R%s &Y%s ]", NOT_AUTHED(wch) ? "N" : "", class_table[wch->class]->who_name );
send_to_char_color(buf, ch);
char buf[MAX_STRING_LENGTH];
(Other code stuff)
sprintf(buf, class_text, "[&R%s &Y%s ]", NOT_AUTHED(wch) ? "N" : "", class_table[wch->class]->who_name );
send_to_char_color(buf, ch);
What exactly is class_text? Unless there's an alternate way to using sprintf() that I've never seen (which I don't believe), I would say that you need to remove the 'class_text' var from your sprintf statement, or if you want to *display* class_text too, change it like so:
sprintf(buf, "[%s &R%s &Y%s ]", class_text, NOT_AUTHED(wch) ? "N" : "", class_table[wch->class]->who_name );
Again, this depends on what the value of 'class_text' is, there's only a few instances I can think of, that would make this statement as you posted it, valid.
sprintf(buf, "[%s &R%s &Y%s ]", class_text, NOT_AUTHED(wch) ? "N" : "", class_table[wch->class]->who_name );
Again, this depends on what the value of 'class_text' is, there's only a few instances I can think of, that would make this statement as you posted it, valid.
Quote:
sprintf(buf, "[%s &R%s &Y%s ]", class_text, NOT_AUTHED(wch) ? "N" : "", class_table[wch->class]->who_name );
sprintf(buf, "[%s &R%s &Y%s ]", class_text, NOT_AUTHED(wch) ? "N" : "", class_table[wch->class]->who_name );
That statement can be better replaced by using ch_printf or ch_printf_color in this case. Like so:
ch_printf_color( ch, "[%s &R%s &Y%s ]", class_text, NOT_AUTHED(wch) ? "N" : "", class_table[wch->class]->who_name );
I did that, and now its odd.
65 Warrior
-----------------------------------[ IMMORTALS ]------------------------------
MUD owner (65) Zeno.
1 player.
See how it shows my status even though I'm an Immortal? Anyone help?
65 Warrior
-----------------------------------[ IMMORTALS ]------------------------------
MUD owner (65) Zeno.
1 player.
See how it shows my status even though I'm an Immortal? Anyone help?
Well you need to review your code a bit. Look for things that say IS_IMMORTAL(ch) or something similar. Perhaps you are missing one somewhere.
All I did was change the original code to
ch_printf_color( ch, "&R%s%2d &G%s&W", NOT_AUTHED(wch) ? "N" : " ", wch->level, class_table[wch->class]->who_name );
on 1 line in do_who, and thats what it is now.
ch_printf_color( ch, "&R%s%2d &G%s&W", NOT_AUTHED(wch) ? "N" : " ", wch->level, class_table[wch->class]->who_name );
on 1 line in do_who, and thats what it is now.
By 'status' I would assume you're talking about the line:
65 Warrior
That line is the result of the code you have posted. So, if it did not appear before you started modifing things, it is likely the result of your modifications. One thing you may want to look at, is when you changed 'sprintf' to 'ch_printf_color' you also needed to remove the 'send_to_char' that was right below that line. Negelecting to do so, could cause odd things to display.
65 Warrior
That line is the result of the code you have posted. So, if it did not appear before you started modifing things, it is likely the result of your modifications. One thing you may want to look at, is when you changed 'sprintf' to 'ch_printf_color' you also needed to remove the 'send_to_char' that was right below that line. Negelecting to do so, could cause odd things to display.
I did that before, there is no 'send_to_char' below it.
[EDIT]
I was told to get rid of that class stuff. Thats what screwed it up. So I changed it back to stock. Bah, is there any other way to allow colow everywhere?
[EDIT]
I was told to get rid of that class stuff. Thats what screwed it up. So I changed it back to stock. Bah, is there any other way to allow colow everywhere?