How to change color in text?
#1

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
Reply
#2

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

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.
Reply
#4

How pleasee
Reply
#5

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
Reply
#6

I KNOW THAT.

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

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

Thanks mate
Reply
#9

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;
}
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)