Author Topic: Pulling a specific part of a tagged string out  (Read 970 times)

Slayer uses "%1%5%2%3%7: %4" for chat involving team colors, and I get the feeling %5 is a color code. I want to use that alone, but I have no idea how to get just %5.

I'd use word counts and extract it from %fmsg in clientCmdChatMessage, but some servers like to add words to clan tags, and this messes extraction up.
I'd rather not succumb to for loops that check for the presence of a name, in case (for some reason) someone has their name as a clan tag, or their clan tags were modified to contain it somewhere.

EDIT: Looked in Slayer's code, found commandToAll('chatMessage', %client, '', '', %all, %pre, %name, %suf, %msg, %color, %team.name, "<color:ffffff>");
I thought I might be able to just add %color onto the end of the function definition, but %color is just blank?



function clientCmdChatMessage(%a, %b, %c, %fmsg, %clanPrefix, %name, %clanSuffix, %msg, %color) {
   // %color is for slayer
   %soundMode = $Pref::Client::CustomChat::SoundNotificationMode;

   %taggedString = stripMLControlChars(getTaggedString(getWord(%fmsg, 0)));
   switch$(%taggedString) {
      case "%1%2%3: %4" or "%1%2%3%7: %4" or "%1%5%2%3%7: %4" or "%5%1%2%5%3%7: %4" or "[%5%6] %1%2%3%7: %4":
         %isChatMsg = 1;
   }
   if(!%isChatMsg) {
      // isn't a chat message
      return parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %clanPrefix, %name, %clanSuffix, %msg);
   }

   if(%taggedString $= "%1%5%2%3%7: %4") {
      echo(%color); // %color is just blank, even though Slayer must be sending /something/?
      %forcedColor = %color;
      %forceAllowColor = 1;
   }
« Last Edit: March 03, 2016, 11:36:08 PM by TheBlackParrot »

What are you trying to do? Are you working from the client's or the server's perspective?

What are you trying to do? Are you working from the client's or the server's perspective?
client's

echo(%color); // %color is just blank, even though Slayer must be sending /something/?
Printing a color control character by itself will never display any text. What you're doing should be working.

Printing a color control character by itself will never display any text. What you're doing should be working.
It's a <color:hex> tag, it's not a control character

It's a <color:hex> tag, it's not a control character
Same deal


Is that even a good idea to depend on, actually?
What if another client add-on doesn't bother to pass anything after %msg before it gets to what I'm doing?

EDIT: That's what was going on in my case. I had a markov chain bot that wasn't passing anything after %msg, coming in before I was doing chat modifications.
« Last Edit: March 04, 2016, 12:04:37 AM by TheBlackParrot »

I'm definitely not seeing any reason your code isn't working.

It's entirely possible that other client add-ons won't handle that many arguments, and in fact, that's probably what's happening.

Yes, your code looks like it should work.