new vehNewPlayerChoose[][][] = {
{401, "Bravura"},
{404, "Perenniel"},
{466, "Glendale"},
{526, "Fortune"},
{527, "Cadrona"},
{529, "Willard"},
{542, "Clover"},
{546, "Intruder"},
{549, "Tampa"}
};
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new str[100];
if(isPlayerChoosingVehicle[playerid])
{
DestroyVehicle(playerVeh[playerid]);
if(PRESSED(KEY_ANALOG_LEFT))
{
if(curVeh[playerid] == 0) {
curVeh[playerid] = sizeof vehNewPlayerChoose;
playerVeh[playerid] = CreateVehicle(vehNewPlayerChoose[curVeh[playerid]][0][0], vehPos_X, vehPos_Y, vehPos_Z, 45.0, -1, -1, -1);
}
else if(curVeh[playerid] > 0) playerVeh[playerid] = CreateVehicle(vehNewPlayerChoose[--curVeh[playerid]][0][0], vehPos_X, vehPos_Y, vehPos_Z, 45.0, -1, -1, -1);
format(str, sizeof(str), "Car: %d %s", vehNewPlayerChoose[curVeh[playerid]][0][0], vehNewPlayerChoose[curVeh[playerid]][1]);
SendClientMessage(playerid, COLOR_BLUE, str);
}
else if(PRESSED(KEY_ANALOG_RIGHT))
{
if(curVeh[playerid] == sizeof vehNewPlayerChoose) {
curVeh[playerid] = 0;
playerVeh[playerid] = CreateVehicle(vehNewPlayerChoose[curVeh[playerid]][0][0], vehPos_X, vehPos_Y, vehPos_Z, 45.0, -1, -1, -1);
}
else if(curVeh[playerid] < sizeof vehNewPlayerChoose) playerVeh[playerid] = CreateVehicle(vehNewPlayerChoose[++curVeh[playerid]][0][0], vehPos_X, vehPos_Y, vehPos_Z, 45.0, -1, -1, -1);
format(str, sizeof(str), "Car: %d %s", vehNewPlayerChoose[curVeh[playerid]][0][0], vehNewPlayerChoose[curVeh[playerid]][1]);
SendClientMessage(playerid, COLOR_BLUE, str);
}
}
return 1;
}
Why vehNewPlayerChoose[curVeh[playerid]][0][0]?
To access 404 for example, vehNewPlayerChoose[1][0] would suffice, for example. vehNewPlayerChoose is an array containing arrays containing an integer and an array. |