Arrays. Im stuck at this one. -_-
#1

Hello guys,

I have this little code. I actually wanted to upgrade my Race System, but this array kinda fails. I just can't get the error away.
pawn Код:
#include <a_samp>
new RaceCheckpoints[10][10][10] =
{
    //Desert Storm
    {
        {228,2504,16,8,0},
        {135,2504,16,8,0},
        {-148,2503,23,8,0},
        {1098,1612,12,8,1}
    },
    //Grand Cheetah
    {
        {-375,1440,60,12,0},
        {-375,1440,60,12,0},
        {-302,1518,74,12,1},
        {-302,1518,74,12,1},
        {-302,1518,74,12,1}
    }
};

public OnFilterScriptInit()
{
    printf("%d", RaceCheckpoints[1][1][1]);
    return 1;
}
Gives me:
Код:
(18) : error 018: initialization data exceeds declared size
I really hope that someone can help me with this, or/and tell me the solution how to fix this.


Regards,
Jeffry
Reply
#2

You are using it wrong dude, from what I see there you either want to remove the middle part:

Код:
},
{
Or you want a seperate array:

Код:
},
Another_Array
{
Also you are best to use "[][5]" from what I can tell after looking at the code, the "[]" method will size the array on it's frist usage (declaration in this case).
Reply
#3

Well, I want this to be the variable of the Race Checkpoints:

RaceCheckpoints[1][1][1]
1.) Race ID
2.) Race CP
3.) X,Y,Z,Size,CP


This should print me:
pawn Код:
printf("%d", RaceCheckpoints[1][1][1]);
=> Would Print: 1440

Wouldn't this work?
Reply
#4

pawn Код:
new RaceCheckpoints[2][4][5] =
{
    //Desert Storm
    {
        {228,2504,16,8,0},
        {135,2504,16,8,0},
        {-148,2503,23,8,0},
        {1098,1612,12,8,1}
    },
    //Grand Cheetah
    {
        {-375,1440,60,12,0},
        {-375,1440,60,12,0},
        {-302,1518,74,12,1},
        {-302,1518,74,12,1},
        {-302,1518,74,12,1}
    }
};
or just
new RaceCheckpoints[][][] = etc..
Reply
#5

Indeed ignore my post above, I read that totally wrong.
Reply
#6

@dice7:

Код:
(16) : error 018: initialization data exceeds declared size
(19) : error 010: invalid function or declaration
Reply
#7

Код:
#include <a_samp>
new RaceCheckpoints[2][5][5] =
{
    //Desert Storm
    {
        {228,2504,16,8,0},
        {135,2504,16,8,0},
        {-148,2503,23,8,0},
        {1098,1612,12,8,1},
        {1098,1612,12,8,1} // must be 5 line
    },
    //Grand Cheetah
    {
        {-375,1440,60,12,0},
        {-375,1440,60,12,0},
        {-302,1518,74,12,1},
        {-302,1518,74,12,1},
        {-302,1518,74,12,1}
    }
};

public OnFilterScriptInit()
{
    printf("%d", RaceCheckpoints[1][1][1]);
    return 1;
}
Better use enum or files
Reply
#8

Awesome, thanks Jefff.
They just have to be the name number. I've tested to make the unneeded ones like: { }
This also works.

Regarding the files, ye maybe I'll do it like this. Dunno.

But Thanks alot.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)