SA-MP Forums Archive
help - auto change color message... - 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: help - auto change color message... (/showthread.php?tid=550353)



help - auto change color message... - _Application_ - 12.12.2014

this is not work , help please :


PHP код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
new KillColorChange;
new 
Color[]={
    
"FF0000",
    
"FFFF00",
    
"FF8800",
    
"9F785A",
    
"8A7EA1"
};
public 
OnPlayerConnect(playerid)
{
    
KillColorChange SetTimerEx("ColorChange"1000true"d"playerid);
    return 
1;
}
forward ColorChange(playerid);
public 
ColorChange(playerid)
{
    new 
string[128];
    
format(stringsizeof(string), "{%s}•••••••••{%s}•••••••••{%s}•••••••••"random(sizeof(Color)), random(sizeof(Color)), random(sizeof(Color)));
    
SendClientMessage(playerid, -1string);
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    
KillTimer(KillColorChange);
    return 
1;

I want it to be always different color, example:

{red}•••••••••{blue}•••••••••{yellow}•••••••••

{yellow}•••••••••{red}•••••••••{blue}•••••••••

{blue}•••••••••{yellow}•••••••••{red}•••••••••

Hope you understand me, thanks in advance


Re: help - auto change color message... - M4D - 12.12.2014

test it

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

new KillColorChange[MAX_PLAYERS]; // <-----------------

new Color[]={
    "FF0000",
    "FFFF00",
    "FF8800",
    "9F785A",
    "8A7EA1"
};

public OnPlayerConnect(playerid)
{
    KillColorChange[playerid] = SetTimerEx("ColorChange", 1000, true, "d", playerid);
    return 1;
}

forward ColorChange(playerid);
public ColorChange(playerid)
{
    new string[128];
    format(string, sizeof(string), "{%s}•••••••••{%s}•••••••••{%s}•••••••••", random(sizeof(Color)), random(sizeof(Color)), random(sizeof(Color)));
    SendClientMessage(playerid, -1, string);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    KillTimer(KillColorChange[playerid]);
    return 1;
}



Re: help - auto change color message... - PowerPC603 - 12.12.2014

pawn Код:
format(string, sizeof(string), "{%s}•••••••••{%s}•••••••••{%s}•••••••••", Color[random(sizeof(Color))], Color[random(sizeof(Color))], Color[random(sizeof(Color))]);
"Random" returns an integer value, not a string.
And it certainly wouldn't know where to retrieve the data from.


Re: help - auto change color message... - _Application_ - 12.12.2014

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
pawn Код:
format(string, sizeof(string), "{%s}•••••••••{%s}•••••••••{%s}•••••••••", Color[random(sizeof(Color))], Color[random(sizeof(Color))], Color[random(sizeof(Color))]);
"Random" returns an integer value, not a string.
And it certainly wouldn't know where to retrieve the data from.
There's a bug:


It also sends a message every time

I want it to send one time and then just change the color


Re: help - auto change color message... - Raweresh - 12.12.2014

Try that:
Код:
format(string, sizeof(string), "{%s}•••••••••{%s}•••••••••{%s}•••••••••", Color[random(sizeof(Color))][0], Color[random(sizeof(Color))][0], Color[random(sizeof(Color))][0]);
Change:
Код:
new Color[]={
    "FF0000",
    "FFFF00",
    "FF8800",
    "9F785A",
    "8A7EA1"
};
To:
Код:
new Color[][]={
    "FF0000",
    "FFFF00",
    "FF8800",
    "9F785A",
    "8A7EA1"
};
And for one message change:
Код:
KillColorChange[playerid] = SetTimerEx("ColorChange", 1000, true, "d", playerid);
To:
Код:
KillColorChange[playerid] = SetTimerEx("ColorChange", 1000, false, "d", playerid);



Re: help - auto change color message... - _Application_ - 12.12.2014

Quote:
Originally Posted by Raweresh
Посмотреть сообщение
Try that:
Код:
format(string, sizeof(string), "{%s}•••••••••{%s}•••••••••{%s}•••••••••", Color[random(sizeof(Color))][0], Color[random(sizeof(Color))][0], Color[random(sizeof(Color))][0]);
Change:
Код:
new Color[]={
    "FF0000",
    "FFFF00",
    "FF8800",
    "9F785A",
    "8A7EA1"
};
To:
Код:
new Color[][]={
    "FF0000",
    "FFFF00",
    "FF8800",
    "9F785A",
    "8A7EA1"
};
And for one message change:
Код:
KillColorChange[playerid] = SetTimerEx("ColorChange", 1000, true, "d", playerid);
To:
Код:
KillColorChange[playerid] = SetTimerEx("ColorChange", 1000, false, "d", playerid);
But I want it to change colors randomly every second
Without sending another message and another message, just edit the first post


Re: help - auto change color message... - Vince - 12.12.2014

The chat is sequential. You can't write on a specific line. Once a message has been sent it can't be altered.

Also you should store colors as integers all the time. You can format them into a string later, for example:

pawn Код:
#define COLOR_RED       0xFF0000AA
#define COLOR_ORANGE    0xFF8000AA
#define COLOR_YELLOW    0xFFFF00AA
#define COLOR_GREEN     0x008000AA
#define COLOR_BLUE      0x0000FFAA
#define COLOR_INDIGO    0x4B0082AA
#define COLOR_VIOLET    0x9400D3AA

new Color[] = {
    COLOR_RED,
    COLOR_ORANGE,
    COLOR_YELLOW,
    COLOR_GREEN,
    COLOR_BLUE,
    COLOR_INDIGO,
    COLOR_VIOLET
};

format(string, sizeof(string), "{%06x}•••••••••{%06x}•••••••••{%06x}•••••••••", Color[random(sizeof(Color))] <<< 8, Color[random(sizeof(Color))] <<< 8, Color[random(sizeof(Color))] <<< 8);



Re: help - auto change color message... - _Application_ - 12.12.2014

Quote:
Originally Posted by Vince
Посмотреть сообщение
The chat is sequential. You can't write on a specific line. Once a message has been sent it can't be altered.

Also you should store colors as integers all the time. You can format them into a string later, for example:

pawn Код:
#define COLOR_RED       0xFF0000AA
#define COLOR_ORANGE    0xFF8000AA
#define COLOR_YELLOW    0xFFFF00AA
#define COLOR_GREEN     0x008000AA
#define COLOR_BLUE      0x0000FFAA
#define COLOR_INDIGO    0x4B0082AA
#define COLOR_VIOLET    0x9400D3AA

new Color[] = {
    COLOR_RED,
    COLOR_ORANGE,
    COLOR_YELLOW,
    COLOR_GREEN,
    COLOR_BLUE,
    COLOR_INDIGO,
    COLOR_VIOLET
};

format(string, sizeof(string), "{%06x}•••••••••{%06x}•••••••••{%06x}•••••••••", Color[random(sizeof(Color))] <<< 8, Color[random(sizeof(Color))] <<< 8, Color[random(sizeof(Color))] <<< 8);
Please teach me, what is it, in a simple way ,(please):
<<< 8


Re: help - auto change color message... - PowerPC603 - 12.12.2014

Sending a message using SendClientMessage just adds your line every second to the chatlog.
Once it's been sent, you can't change it later.

If you want one single line to change colors every second, you'll need a textdraw.
But then again, textdraws only support a few pre-defined colors, you can't create new colors for those AFAIK.
Textdraws don't use {FF0088} or something like this, but they use ~r~ for red, ~w~ for white and a few others.

https://sampwiki.blast.hk/wiki/TextDrawCreate