Author Topic: Help with emoting chat colors  (Read 314 times)

Legacy_ppmateos

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Help with emoting chat colors
« on: June 01, 2014, 01:32:18 am »


               Hi, Im looking a script for emoting chat colors:


If the PC write: (I'm tired)


On the pcchat  appear in red color -> (I'm tired)



If the PC write: (I'm tired)  *close your eyes*


On the pcchat appear in red color (I'm tired) & in green color *close your eyes*


With the parentheses & asterisk and // functions


I've seen it on multiple servers


I supose that the functions must be GetPCChatSpeaker, GetPCChatMessage


I have this code:


// ***************************************************


string sColors = "                                            !!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˠ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ¡¢£¤¥§©©ª«¬­®¯°±²³´µ¶·¸¸º»¼½¾¿ÀÁÂÃÄÅàÇÈÉàËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïñòóôõö÷øùúûüýþþþ";

string ASCII(int iAsciiCode) // 0 - 255
{
    int ASCIIReturn = iAsciiCode;
    if (ASCIIReturn<0) ASCIIReturn = 0;
    else if (ASCIIReturn>255) ASCIIReturn = 255;
    return GetSubString(sColors,iAsciiCode+1,1);
}

int ASCIIToInt(string sLookup)
{
    return FindSubString(sColors, sLookup)-1;
}

string RGB(int iR, int iG, int iB) // 0-255
{
    return "<c"+ASCII(iR)+ASCII(iG)+ASCII(iB)+">";
}

const string TEXT_COLOR_RED    =  "þ  ";
const string TEXT_COLOR_ORANGE =  "þœ ";
const string TEXT_COLOR_YELLOW =  "þþ ";
const string TEXT_COLOR_GREEN  =  " þ ";
const string TEXT_COLOR_BLUE   =  "  Ã¾";
const string TEXT_COLOR_CYAN   =  " þþ";
const string TEXT_COLOR_PURPLE =  "þ þ";
const string TEXT_COLOR_WHITE  =  "þþþ";
const string TEXT_COLOR_GREY   =  "~~~";
const string TEXT_COLOR_CRIMSON = "‘  ";
const string TEXT_COLOR_EMERALD = " ~ ";
const string TEXT_COLOR_BROWN   = "Ç~6";
const string TEXT_COLOR_AZURE   = "~~þ";

string RGBColorText(string RGBCode, string sText)
{
  return "<c"+ RGBCode +">"+ sText +"</c>";
}

string ColorText(string ColorCode, string sText)
{
       if (ColorCode == "crimson")      ColorCode = "<c‘  >";
  else if (ColorCode == "red")          ColorCode = "<cþ  >";
  else if (ColorCode == "plum")         ColorCode = "<cþww>";
  else if (ColorCode == "tangerine")    ColorCode = "<cÇZ >";
  else if (ColorCode == "orange")       ColorCode = "<cþœ >";
  else if (ColorCode == "peach")        ColorCode = "<cþÇ >";
  else if (ColorCode == "amber")        ColorCode = "<cÅ“Å“ >";
  else if (ColorCode == "yellow")       ColorCode = "<cþþ >";
  else if (ColorCode == "lemon")        ColorCode = "<cþþw>";
  else if (ColorCode == "emerald")      ColorCode = "<c ~ >";
  else if (ColorCode == "green")        ColorCode = "<c þ >";
  else if (ColorCode == "lime")         ColorCode = "<cwþw>";
  else if (ColorCode == "midnight")     ColorCode = "<c  t>";
  else if (ColorCode == "navy")         ColorCode = "<c  â€˜>";
  else if (ColorCode == "blue")         ColorCode = "<c  Ã¾>";
  else if (ColorCode == "azure")        ColorCode = "<c~~þ>";
  else if (ColorCode == "skyblue")      ColorCode = "<cÇÇþ>";
  else if (ColorCode == "violet")       ColorCode = "<cÂ¥ Â¥>";
  else if (ColorCode == "purple")       ColorCode = "<cþ þ>";
  else if (ColorCode == "lavender")     ColorCode = "<cþ~þ>";
  else if (ColorCode == "black")        ColorCode = "<c   >";
  else if (ColorCode == "slate")        ColorCode = "<c666>";
  else if (ColorCode == "darkgrey")     ColorCode = "<cZZZ>";
  else if (ColorCode == "grey")         ColorCode = "<c~~~>";
  else if (ColorCode == "lightgrey")    ColorCode = "<c¯¯¯>";
  else if (ColorCode == "white")        ColorCode = "<cþþþ>";
  else if (ColorCode == "turquoise")    ColorCode = "<c ¥¥>";
  else if (ColorCode == "jade")         ColorCode = "<c tt>";
  else if (ColorCode == "cyan")         ColorCode = "<c þþ>";
  else if (ColorCode == "cerulean")     ColorCode = "<cœþþ>";
  else if (ColorCode == "aqua")         ColorCode = "<cZǯ>";
  else if (ColorCode == "silver")       ColorCode = "<c¿¯Ç>";
  else if (ColorCode == "rose")         ColorCode = "<cÃŽFF>";
  else if (ColorCode == "pink")         ColorCode = "<cþV¿>";
  else if (ColorCode == "wood")         ColorCode = "<c‘Z(>";
  else if (ColorCode == "brown")        ColorCode = "<cÇ~6>";
  else if (ColorCode == "tan")          ColorCode = "<cß‘F>";
  else if (ColorCode == "flesh")        ColorCode = "<cû¥Z>";
  else if (ColorCode == "ivory")        ColorCode = "<cþÎ¥>";
  else if (ColorCode == "gold")         ColorCode = "<cþ¿6>";
  else if (ColorCode == "random")
    {
        switch (d3())
        {
            case 1: ColorCode = RGB(Random(128)+128,Random(192)+64,Random(192)+64); break;
            case 2: ColorCode = RGB(Random(192)+64,Random(128)+128,Random(192)+64); break;
            case 3: ColorCode = RGB(Random(192)+64,Random(192)+64,Random(128)+128); break;
        }
    }
    return ColorCode + sText + "</c>";
}

// ***************************************************

Thanks for the help '<img'>
               
               

               
            

Legacy_BelowTheBelt

  • Hero Member
  • *****
  • Posts: 699
  • Karma: +0/-0
Help with emoting chat colors
« Reply #1 on: June 01, 2014, 11:45:29 am »


               Take a look at this guide to colors.  The approach is different if you want to color text from a conversation or if you want to color script via a script.  

http://nwvault.ign.c...r.detail&id=931


That will explain the coloring process.


Are you trying to dynamically capture spoken text wherever and whenever a PC specifically speaks the words or are you doing this in a conversation?


I can post an example of GetPCChatMessage later today if you don't get an answer sooner.


From memory, though, you capture the chat message through GetPCChatMessage, convert it all to lowercase (so the use of capitalization doesn't affect recognition), and then set up an 'if' statement to see if the words 'i'm tired' are equal to the message.  If so, color the text, have the PC speak the new colored text and send the colored emote an any other effects.
               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Help with emoting chat colors
« Reply #2 on: June 01, 2014, 02:32:30 pm »


               Also, 1.69 introduced some functions which are easier to use in many situations.
               
               

               
            

Legacy_ppmateos

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Help with emoting chat colors
« Reply #3 on: June 01, 2014, 03:18:47 pm »


               I need something like this:
 
void main()
{
    // Variables
    object oPC = GetPCChatSpeaker();
    string sText = GetPCChatMessage();
    string sFinal = "";
    int iAmRockstar = TRUE;

    // Find color initiation
                   int iStart = FindSubString(sText, "*", 0);
    if (iStart == -1) {iStart = FindSubString(sText, "(", 0); iAmRockstar = FALSE;}
    if (iStart == -1) return;                                           // :C

    // Find color termination
    int iEnd;
    if (iAmRockstar) iEnd = FindSubString(sText, "*", iStart+1);
    else             iEnd = FindSubString(sText, ")", iStart+1);

    // Reconstruct message
    sFinal += GetSubString(sText, 0, iStart) + "<cÞ·/>";
    if (iEnd>-1) sFinal += GetSubString(sText, iStart, iEnd+1 - iStart) + "</c>";
    else iEnd = iStart -1;
    sFinal += GetSubString(sText, iEnd+1, GetStringLength(sText) - iEnd+1);

    // Send message
    SetPCChatMessage(sFinal);
}
 
But the color text betwen () and ** is the same & need to be diferent.