Need some small help with spawning
#1

Well, I created about 17 colors I want people to spawn randomly with. I don't really understand how to do this but i tried this.

pawn Код:
#define ssColors 17
This is for the 17 colors i made
pawn Код:
new sColor[ssColors][] = {
    {0x8A2BE2FF},
    {0x483D8BFF},
    {0x00CED1FF},
    {0x0000CDFF},
    {0x002266FF},
    {0xCD7F32FF},
    {0xFFC1C1FF},
    {0xBC8F8FFF},
    {0xFF1493FF},
    {0x8B4513FF},
    {0xA52A2AFF},
    {0xFF7F24FF},
    {0x006400FF},
    {0xCAFF70FF},
    {0x00FF00FF},
    {0xFF0000FF},
    {0xFFFF00FF}
}
Then I did this above. I was thinks sColor would stand for Spawn Color and [ssColor] are all the 17 colors i defined.

pawn Код:
new rColor = random(sizeof(sColor));
    SetPlayerColor(playerid, sColor[rColor][1]);
Then I get errors..
Код:
(103) : error 001: expected token: ";", but found "-identifier-"
(351) : error 032: array index out of bounds (variable "sColor")
Line 103 is
pawn Код:
main()
and line 351 is
pawn Код:
SetPlayerColor(playerid, sColor[rColor][1]);
Help with this would greatly be appreciated as I am trying to script a server for my clan! Thanks ffor your time.
Reply
#2

SetPlayerColor(playerid, sColor[rColor]);

?
Reply
#3

You do not need a 2D array, one dimension is enough, because a color hex number is nothing else but a integer.

pawn Код:
new sColor[ssColors] = {
    0x8A2BE2FF,
    0x483D8BFF,
    ...
(Also you forgot the ; after the last bracket of the array)
Reply
#4

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
You do not need a 2D array, one dimension is enough, because a color hex number is nothing else but a integer.

pawn Код:
new sColor[ssColors] = {
    0x8A2BE2FF,
    0x483D8BFF,
    ...
(Also you forgot the ; after the last bracket of the array)
thanks alot man.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)