new APlanes[] = { {"Andromada", 592}, {"AT400", 577}, {"Beagle", 511}, {"Cargobob", 548}, // ID 0, 1, 2, 3 {"Cropduster", 512}, {"Dodo", 593}, {"Hunter", 425}, {"Hydra", 520}, // ID 4, 5, 6, 7 {"Leviathan", 417}, {"Maverick", 487}, {"Nevada", 553}, {"Police Maverick", 497}, // ID 8, 9, 10, 11 {"Raindance", 563}, {"Rustler", 476}, {"SAN News Maverick", 488}, {"Seasparrow", 447}, // ID 12, 13, 14, 15 {"Shamal", 519}, {"Skimmer", 460}, {"Sparrow", 469}, {"Stuntplane", 513} // ID 16, 17, 18, 19 };
(201) : error 008: must be a constant expression; assumed zero
#define DIALOG_PLANE 1 //============================================================================== CMD:vplane(playerid, params[]) { // Check if the player's admin-level is at least 1 if(PlayerInfo[playerid][pVIP] >= 2) { // Make sure the player isn't inside a vehicle if (GetPlayerVehicleID(playerid) == 0) { // Ask which motorcycle the player wants to have ShowPlayerDialog(playerid, DIALOG_PLANE, DIALOG_STYLE_LIST, "Choose a plane:", APlanes, "Spawn", "Cancel"); // Let the server know that this was a valid command return 1; } } else return 0; // Let the server know that this was a valid command return 1; }
new APlanes[][] =
{ // start 1. dim
// 0 - APlanes[0][x]
{ // start 2. dim
// 0 - APlanes[0][0]
"Andromada",
// 10 - APlanes[0][10] - because "Andromada" is 10 cells long
592
}, // end 2. dim
// 1 - APlanes[1][x]
{ // start 2. dim
// 0 - APlanes[1][0]
"AT400",
// 6 - APlanes[1][6]
577
}, // end 2. dim
}; // end 1 dim
Well your array got two dimensions so you need to define it like that
pawn Код:
You need to format a string with your array or you use another global array with only one dimension |
#define DIALOG_PLANE 1
enum APlaneInfo
{
PlaneName[20],
PlaneID
}
new APlanes[20][APlaneInfo] =
{
{"Andromada", 592}, {"AT400", 577}, {"Beagle", 511}, {"Cargobob", 548}, // ID 0, 1, 2, 3
{"Cropduster", 512}, {"Dodo", 593}, {"Hunter", 425}, {"Hydra", 520}, // ID 4, 5, 6, 7
{"Leviathan", 417}, {"Maverick", 487}, {"Nevada", 553}, {"Police Maverick", 497}, // ID 8, 9, 10, 11
{"Raindance", 563}, {"Rustler", 476}, {"SAN News Maverick", 488}, {"Seasparrow", 447}, // ID 12, 13, 14, 15
{"Shamal", 519}, {"Skimmer", 460}, {"Sparrow", 469}, {"Stuntplane", 513} // ID 16, 17, 18, 19
};
//==============================================================================
CMD:vplane(playerid, params[])
{
// Check if the player's admin-level is at least 1
if(PlayerInfo[playerid][pVIP] >= 2)
{
// Make sure the player isn't inside a vehicle
if (GetPlayerVehicleID(playerid) == 0)
{
// Ask which PLANE the player wants to have
new PMSG[1000];
for(new i=0; i<20; i++)
{
format(PMSG, sizeof(PMSG), "%s%s - %i\n",PMSG,APlanes[i][PlaneName], APlanes[i][PlaneID]);
}
ShowPlayerDialog(playerid, DIALOG_PLANE, DIALOG_STYLE_LIST, "Choose a plane:", PMSG, "Spawn", "Cancel");
// Let the server know that this was a valid command
return 1;
}
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_PLANE)
{
if(!response) // Pressed ESC or clicked cancel
{
//SendClientMessage(playerid, COLOR_GREEN, "Closed Dialog Message");
}
else
{
//Pressed Spawn
new PMSG[128];
format(PMSG, sizeof(PMSG), "You have spawned %s", APlanes[listitem][PlaneName]);
SendClientMessage(playerid, -1 /*W/e Color*/, PMSG);
new Float:PlayerPos[4];
GetPlayerPos(playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
GetPlayerFacingAngle(playerid, PlayerPos[3]);
new VID = CreateVehicle(APlanes[listitem][PlaneID], PlayerPos[0], PlayerPos[1], PlayerPos[2], PlayerPos[3], random(254), random(254), 0);
PutPlayerInVehicle(playerid, VID, 0);
}
return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
}
return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}