SA-MP Forums Archive
How to change color in text? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to change color in text? (/showthread.php?tid=528401)



How to change color in text? - alanhutch - 27.07.2014

Hi!
I wanted to know how to change color in determined texts...
Like "Hi guys! *-Moving my hand-*
How can I change the color of the text that is into the * * ?
Thanks


Re: How to change color in text? - Jefff - 27.07.2014

https://sampwiki.blast.hk/wiki/Colors#Color_embedding


Re: How to change color in text? - alanhutch - 27.07.2014

I know how to do that...
But I want to do when a player send a message like "Hello *-Raising the hand-*" and the text in ** in purple! I don't know how to do that.


Re: How to change color in text? - alanhutch - 27.07.2014

How pleasee


Re: How to change color in text? - Cannary2048 - 27.07.2014

An example:
pawn Code:
SendClientMessage(playerid, 0xFFFFFFFF, "Hello, {FF0000}I'm a guy{FFFFFF}");
That code will make:
Code:
Hello, I'm a guy!
remember, it's RGB format


Re: How to change color in text? - alanhutch - 27.07.2014

I KNOW THAT.

I want to Know if someone write something into ** THAT becomes purple!!
This on OnPlayerChat!!!


Re: How to change color in text? - Dubya - 27.07.2014

Hmm.. I'll make something and post in a few minutes, will not test it though.


Re: How to change color in text? - alanhutch - 27.07.2014

Thanks mate


Re: How to change color in text? - Dubya - 27.07.2014

try this? not sure

pawn Code:
public OnPlayerChat(playerid, chat[]) {
    new finalstring[128];
    finalstring = ColorText(chat);
    SendClientMessage(playerid, -1, finalstring);
    return 0;
}

stock ColorText(chat[]) {
    new text[128] = chat, i = 0, cur = 0;
    while(i < sizeof(text)) {
        if(text[i] == '*') {
            if(cur == 0) strins(text, "{C2A2DA}",i-1);
            else if(cur == 0) strins(text, "{FFFFFF}",i+1);
        }
        i++;
    }
    return text;
}



Re: How to change color in text? - Virtual1ty - 27.07.2014

Well yours *untested* function gave me cryptic crashdetect errors,
anyways here alanhutch, try this:
pawn Code:
stock FilterAsterisk(msg[], msglen = sizeof(msg))
{
    new i = 0, asteriskPair = 0;
    while (msg[i] != '\0')
    {
        if (msg[i] == '*')
        {
            if (asteriskPair == 0)
            {
                asteriskPair++;
                strdel(msg, i, i+1);
                strins(msg, "{800080}", i, msglen);
            }
            else
            {
                asteriskPair = 0;
                strdel(msg, i, i+1);
                strins(msg, "{FFFFFF}", i, msglen);
            }
        }
        i++;
    }
}
Use it like "FilterAsterisk(text)" though I suggest create a new array under OnPlayerText 144 cells long to hold this new formatted text.