colour for random msg? - 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: colour for random msg? (
/showthread.php?tid=297724)
colour for random msg? -
niels44 - 17.11.2011
hey everyone,
i made this fora random msg:
Код:
#define MINUTES(%1) ((%1)*(60*1000))
new RandomMessages[][] =
{
"MDC_BOT: if u need a car then type /carmenu",
"MDC_BOT: if u want to know the teleports type /teles",
"MDC_BOT: if u want to see all the commands type /cmds",
"MDC_BOT: everyone if u have suggestions to the server type /suggest <suggestion>"
};
public OnGameModeInit()
{
SetTimer("AutomaticMessage", MINUTES(1), true);
return true
}
forward AutomaticMessage();
public AutomaticMessage()
{
new RandomMessage = random(sizeof(RandomMessages));
SendClientMessageToAll(-1, RandomMessages[RandomMessage]); // -1 is a colour for a message.
return true;
}
but how to make it that each one has a different colour? it now has colour white(default) but how to make it other colour?
pls help XD
niels
Re: colour for random msg? - [L3th4l] - 17.11.2011
You can make random colors if you want:
pawn Код:
forward AutomaticMessage();
public AutomaticMessage()
{
new RandomColor[] = {0xFFCC00FF, 0x0099FFFF}; // Orange ( first ) and blue ( second )
new RandomMessage = random(sizeof(RandomMessages));
SendClientMessageToAll(RandomColor[random(sizeof(RandomColor))], RandomMessages[RandomMessage]); // -1 is a colour for a message.
return true;
}
Re: colour for random msg? -
nuriel8833 - 17.11.2011
^^ Or that he can use this code:
pawn Код:
#define MINUTES(%1) ((%1)*(60*1000))
new RandomMessages[][] =
{
"MDC_BOT: if u need a car then type /carmenu",
"MDC_BOT: if u want to know the teleports type /teles",
"MDC_BOT: if u want to see all the commands type /cmds",
"MDC_BOT: everyone if u have suggestions to the server type /suggest <suggestion>"
};
public OnGameModeInit()
{
SetTimer("AutomaticMessage", MINUTES(1), true);
return true
}
forward AutomaticMessage();
public AutomaticMessage()
{
//****Chooses the random color****
new r = random(256),g = random(256),b = random(256);
while(r > 200 && g > 200 && b > 200) { r = random(256),g = random(256),b = random(256); }
//***************************
new RandomMessage = random(sizeof(RandomMessages));
SendClientMessageToAll(SetPlayerColor(playerid,rgba2hex(r,g,b,100));, RandomMessages[RandomMessage]);
return true;
}
//Down in your script (in the buttom)
stock rgba2hex(r,g,b,a) return (r*16777216) + (g*65536) + (b*256) + a;
Not sure whether it works or not,havent been scripting for a long time.
Test it and tell me
Re: colour for random msg? -
MP2 - 17.11.2011
Those messages are really professional - "if u need a car" >.>
Try this
pawn Код:
enum rm_data
{
rm_color, // Hex color
rm_msg[128] // String
}
new randmsg[][rm_data] = {
{0xFF0000FF, "This is a random message, it is red."},
{0x00FF00FF, "This is a random message, it is green."},
{0x0000FFFF, "This is a random message, it is blue."}
};
// To show the random message...
new rand_msg_rand = random(sizeof(randmsg));
SendClientMessageToAll(randmsg[rand_msg_rand][0], randmsg[rand_msg_rand][1]);
Note that this is
un-tested, it should work though there may be an error with the array - I am not currently at my computer so can not compile it.