19.02.2011, 19:24
I need to store multiple sets of coordinates in a single array for multiple races, what's the best way to do this?
new Float:RaceCoords[ MAX_RACES ][4]; //X - Y - Z - Rotation Angle
#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}
};
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}
};
pawn Код:
Although 8 coords is a strange number in my opinion :S |
new race_vehicle_list[3][] = {
{411, 560},
{411, 560, 451},
{471, 468}
};
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;
}
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. |
for(new i=1; i<sizeof(race_vehicle_list[listitem]); i++)
new race_vehicle_list[][] = {
{411, 411, 411},
{411, 522, 522},
{520, 520}
};
pawn Код:
That line is: pawn Код:
This is the array: 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;
}