SA-MP Forums Archive
How To Make Random Color On Connect - 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: How To Make Random Color On Connect (/showthread.php?tid=324587)



Solved - SsHady - 10.03.2012

Fixed Thnx To Faisal_Khan and Shabi_Roxx



Re: How To Make Random Color On Connect - Faisal_khan - 10.03.2012

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.


Re: How To Make Random Color On Connect - Shabi RoxX - 10.03.2012

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;
}



Re: How To Make Random Color On Connect - SsHady - 10.03.2012

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



Re: How To Make Random Color On Connect - Faisal_khan - 10.03.2012

Welcome!


Re: How To Make Random Color On Connect - vinigas - 23.10.2014

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[ ]


Re: How To Make Random Color On Connect - joevega12 - 23.10.2014

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