Arrays. Im stuck at this one. -_- -
Jeffry - 11.03.2011
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
Re: Arrays. Im stuck at this one. -_- -
Donny_k - 11.03.2011
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:
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).
Re: Arrays. Im stuck at this one. -_- -
Jeffry - 11.03.2011
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?
Re: Arrays. Im stuck at this one. -_- -
dice7 - 11.03.2011
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..
Re: Arrays. Im stuck at this one. -_- -
Donny_k - 11.03.2011
Indeed ignore my post above, I read that totally wrong.
Re: Arrays. Im stuck at this one. -_- -
Jeffry - 11.03.2011
@dice7:
Код:
(16) : error 018: initialization data exceeds declared size
(19) : error 010: invalid function or declaration
Re: Arrays. Im stuck at this one. -_- -
Jefff - 11.03.2011
Код:
#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
Re: Arrays. Im stuck at this one. -_- -
Jeffry - 11.03.2011
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.