Array in an array -
MP2 - 19.02.2011
I need to store multiple sets of coordinates in a single array for multiple races, what's the best way to do this?
Re: Array in an array -
Hiddos - 19.02.2011
I'd do it like this:
pawn Код:
new Float:RaceCoords[ MAX_RACES ][4]; //X - Y - Z - Rotation Angle
Respuesta: Array in an array -
anonymousx - 19.02.2011
Yeah, Hiddos is right.
Do somethind like this:
pawn Код:
#define MAX_RACES 5 //define the max races.
new Float:RaceCorrds[MAX_RACES][4] = {
{X,Y,Z,A},
{X,Y,Z,A},
//...
{X,Y,Z,A}
};
Re: Array in an array -
MP2 - 19.02.2011
I have 8 coordinates per race.
AW: Array in an array -
Nero_3D - 20.02.2011
pawn Код:
stock const Float: RaceCoords[][] = {
{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0},
{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0},
//...
{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}
};
Done ? You can use so much numbers how you want if you didnt used any index in the header
Although 8 coords is a strange number in my opinion :S
Re: AW: Array in an array -
Stigg - 20.02.2011
Quote:
Originally Posted by Nero_3D
pawn Код:
stock const Float: RaceCoords[][] = { {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}, {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}, //... {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0} };
Done ? You can use so much numbers how you want if you didnt used any index in the header
Although 8 coords is a strange number in my opinion :S
|
He probably means checkpoints per race. lolz
Peace...
Re: Array in an array -
MP2 - 20.02.2011
I have 8 spawnpoints per race. Anyway i've sorted that bit out, now I need an array to store any number of variables for each race. This is for the vehicles to be used in that race. Example:
Race 1 uses Infernus and Sultan
Race 2 uses Infernus, Sultan and Turismo
Race 3 uses Quad and Sanchez
I need to store that in an array.
pawn Код:
new race_vehicle_list[3][] = {
{411, 560},
{411, 560, 451},
{471, 468}
};
Should that work?
Re: Array in an array -
MP2 - 20.02.2011
pawn Код:
if(dialogid == DIALOG_RACE && response) // Start race
{
format(string, sizeof(string), "%s", VehicleNames2[race_vehicle_list[listitem][0]-400]);
for(new i=1; i<sizeof(race_vehicle_list[listitem]); i++)
{
format(string, sizeof(string), "%s\n%s", string, VehicleNames2[race_vehicle_list[listitem][i]-400]);
}
ShowPlayerDialog(playerid, DIALOG_RACE_VEHICLE, DIALOG_STYLE_LIST, "Start Race - Select Vehicle", string, "Race", "Cancel");
SetPVarInt(playerid, "race_map", listitem+1);
return 1;
}
Gives these errors:
Quote:
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\MS.pwn(7363) : error 001: expected token: "]", but found "-identifier-"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\MS.pwn(7363) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\MS.pwn(7363) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\MS.pwn(7363) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
|
That line is:
pawn Код:
for(new i=1; i<sizeof(race_vehicle_list[listitem]); i++)
and it's refering to the sizeof(race_veh...) part. How can I tell how many vehicles are in the array?
This is the array:
pawn Код:
new race_vehicle_list[][] = {
{411, 411, 411},
{411, 522, 522},
{520, 520}
};
Re: Array in an array - rjjj - 20.02.2011
Quote:
Originally Posted by MP2
pawn Код:
if(dialogid == DIALOG_RACE && response) // Start race { format(string, sizeof(string), "%s", VehicleNames2[race_vehicle_list[listitem][0]-400]); for(new i=1; i<sizeof(race_vehicle_list[listitem]); i++) { format(string, sizeof(string), "%s\n%s", string, VehicleNames2[race_vehicle_list[listitem][i]-400]); } ShowPlayerDialog(playerid, DIALOG_RACE_VEHICLE, DIALOG_STYLE_LIST, "Start Race - Select Vehicle", string, "Race", "Cancel"); SetPVarInt(playerid, "race_map", listitem+1); return 1; }
Gives these errors:
That line is:
pawn Код:
for(new i=1; i<sizeof(race_vehicle_list[listitem]); i++)
and it's refering to the sizeof(race_veh...) part. How can I tell how many vehicles are in the array?
This is the array:
pawn Код:
new race_vehicle_list[][] = { {411, 411, 411}, {411, 522, 522}, {520, 520} };
|
I think that will solve your problem:
pawn Код:
if(dialogid == DIALOG_RACE && response) // Start race
{
format(string, sizeof(string), "%s", VehicleNames2[race_vehicle_list[listitem][0]-400]);
for(new i=1; i <= 15; i++)//Change 15 for the MAX Races coordinates
{
format(string, sizeof(string), "%s\n%s", string, VehicleNames2[race_vehicle_list[listitem][i]-400]);
}
ShowPlayerDialog(playerid, DIALOG_RACE_VEHICLE, DIALOG_STYLE_LIST, "Start Race - Select Vehicle", string, "Race", "Cancel");
SetPVarInt(playerid, "race_map", listitem+1);
return 1;
}
I hope that i have helped
Re: Array in an array -
iMonk3y - 20.02.2011
Quote:
Originally Posted by MP2
pawn Код:
new race_vehicle_list[3][] = { {411, 560}, {411, 560, 451}, {471, 468} };
Should that work?
|
Yes, that should work!