05 Sep, 2012, arholly wrote in the 1st comment:
Votes: 0
Hello:
I've got a problem with colors. :) I want my code to put in a different color text when someone is speaking while emoting (or doing something like that). However, it's not working properly. I'm using KaVir's color system in his protocol snipper as the basis. Any help would be very useful and helpful.

void emote_say_colouring( char *argument, CHAR_DATA *ch )
{
char *letter, *endbit;
char temp[MAX_STRING_LENGTH];
char middle[MAX_STRING_LENGTH];

if ((letter = strstr(argument,"\"")) == NULL)
return;
if ((endbit = strstr(letter + 1,"\"")) == NULL)
return;

endbit++;

strncpy(temp,argument, sizeof(temp));
temp[strlen(argument) - strlen(letter)] = '\0';

strncpy(middle,letter, sizeof(middle));
middle[strlen(letter) - strlen(endbit)] = '\0';

strncat(temp, "\tW", sizeof(temp));

strncat(temp, middle, sizeof(temp));

if(strstr(endbit, "\""))
emote_say_colouring(endbit, ch);
strncat(temp, endbit, sizeof(temp));

/* Removed to try to fix name changes.
argument = str_dup(temp);

return argument;
*/
strncpy(argument, temp, sizeof(argument));

return;
}


Sample of it in use:
void do_dmote( CHAR_DATA *ch, char *argument )
{
if ( !IS_NPC(ch) && IS_SET(ch->comm, COMM_NOEMOTE) )
{
send_to_char( "You can't show your emotions.\n\r", ch );
return;
}

if ( IS_NULLSTR(argument) )
{
send_to_char( "Dmote what?\n\r", ch );
return;
}

emote_say_colouring(argument, ch);

act( "$t$T \tR[\tC$n\tR]\tn", ch, NULL, argument, TO_ROOM, 0 );
act( "$t$T \tR[\tC$n\tR]\tn", ch, NULL, argument, TO_CHAR, 0 );

if(IS_AFFECTED(ch, AFF_HIDE) || IS_AFFECTED(ch, AFF_INVISIBLE) || IS_AFFECTED(ch, AFF_SNEAK))
do_visible(ch,"");

return;
}
0.0/1