Color Parsing - 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: Color Parsing (
/showthread.php?tid=509214)
Color Parsing -
ProjectGANTON - 25.04.2014
Hi all.
Today i was looking for some new RolePlay features, so i thinked about color parsing on chat.
I mean that, when you write * * in chat, next between the two * * will change color.
Here an example:
"Hello! *Waving*"
Result:
"Hello
*Waving*"
I know i must use strcmp, but i don't exactly know how to detect when it starts and when it finish.
I already see this in many RolePlay servers.
Hope someone will help me!
Re : Color Parsing -
S4t3K - 25.04.2014
PHP код:
public OnPlayerText(playerid, text[])
{
if(strfind(text, "**"))
{
new colour[7], pos[4];
for(new i = 0; i < sizeof(text); i++)
{
if(text[i] == '*')
{
for(new j = 0; j < 4; j++)
{
if(pos[j] == 0) pos[j] = i;
}
}
}
strmid(colour, text, pos[1], pos[2]);
return colour;
Now, you've the colour.
Do the rest.
Re: Re : Color Parsing -
ProjectGANTON - 25.04.2014
Quote:
Originally Posted by S4t3K
PHP код:
public OnPlayerText(playerid, text[])
{
if(strfind(text, "**"))
{
new colour[7], pos[4];
for(new i = 0; i < sizeof(text); i++)
{
if(text[i] == '*')
{
for(new j = 0; j < 4; j++)
{
if(pos[j] == 0) pos[j] = i;
}
}
}
strmid(colour, text, pos[0], pos[3];
return colour;
Now, you've the colour.
Do the rest.
|
This will fetch when there's a * ?
Re : Color Parsing -
S4t3K - 25.04.2014
This will take everything between the bold chars *
*FF0000
* (but it won't take the bold chars) and store it in the colour array.
I mean, if it is not what you wanted, sorry.
I believed that you wanted the player putting the color he wants for chatting.
If you just want to apply the same colour to the whole text at each time, simply remake my code. (I've done the hardest way)
Re: Color Parsing -
ProjectGANTON - 25.04.2014
Uhm i don't think you get what i'm looking for >.<
I want just to colour into purple every text between this tag: *
The idea is to implement an action command into a normal chatting text.