colour for random msg?
#1

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)