How To Make Random Color On Connect
#1

Fixed Thnx To Faisal_Khan and Shabi_Roxx
Reply
#2

Try this:
pawn Код:
new randomColor[10] = {Color1, color2, color3, color4....};
Then OnPlayerConnect or OnPlayerSpawn:

pawn Код:
SetPlayerColor(playerid, randomColor[random(sizeof(randomColor))]);
Maybe this will help.
Reply
#3

Here you have:

pawn Код:
//creating new array
new Colors[] =
{
    0x0BE3F4FF, // Color1
    0x0D52F2FF, // Color2
    0xFF8000FF, // Color3
    0x0FAAF4FF // Color4
};

public OnPlayerConnect(playerid)
{
    //randoming array
    new randomcolors = random(sizeof(Colors));
    //Now use randomcolors in any codes like
    SendClientMessage(playerid, Colors[randomcolors], "Welcome player" );
    return 1;
}
Reply
#4

Problem This is my Line
Код:
new randomColor[10] = {COLOR_TEAL,COLOR_THISTLE,COLOR_TOMATO,COLOR_TURQUOISE,COLOR_VIOLET,COLOR_WHEAT,COLOR_WHITESMOKE,COLOR_WINDOWFRAME,COLOR_WINDOWTEXT,COLOR_YELLOW,COLOR_WHITE, COLOR_YELLOW, COLOR_RED, COLOR_GREEN,COLOR_YELLOWGREEN};
and i'am getting
Код:
error 018: initialization data exceeds declared size
Reply
#5

Welcome!
Reply
#6

Quote:
Originally Posted by SsHady
Посмотреть сообщение
Problem This is my Line
Код:
new randomColor[10] = {COLOR_TEAL,COLOR_THISTLE,COLOR_TOMATO,COLOR_TURQUOISE,COLOR_VIOLET,COLOR_WHEAT,COLOR_WHITESMOKE,COLOR_WINDOWFRAME,COLOR_WINDOWTEXT,COLOR_YELLOW,COLOR_WHITE, COLOR_YELLOW, COLOR_RED, COLOR_GREEN,COLOR_YELLOWGREEN};
and i'am getting
Код:
error 018: initialization data exceeds declared size
Replace randomColor[10] with randomColor[ ]
Reply
#7

Код:
SetPlayerColor(playerid, (random(0xFFFFFF) << 8) + 0xFF);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)