10.12.2016, 00:46
I have this command:
Which displays your owned vehicles on the server.
Now whenever I use that command, the dialog works fine, but when I click on the vehicle, I get the error "Array index out of bounds".
This is the dialog response code:
That is where I get that error.
This is the GrabVID stock:
Код:
new SelVeh[MAX_PLAYERS][10];
CMD:myvehicles(playerid)
{
new string[256], count = 0;
if(CountUserVehicle(playerid) == 0) return SS(playerid, COOL_GREEN, "You don't own any vehicles.", "Nu detii nici o masina.");
DeletePVar(playerid, "selected_vehicle");
format(string, sizeof(string), "Name\tStatus\tCarplate\tPrice\n");
for(new i = 0; i < sizeof(vehicleVariables); i++)
{
if(vehicleVariables[i][vVehicleOwnerID] == playerVariables[playerid][pInternalID])
{
SelVeh[playerid][count] = vehicleVariables[i][vVehicleID];
if(vehicleVariables[i][vVehicleStatus] == 0) format(string, sizeof(string), "%s%s\t{%s}[ despawned ]\t%s\t$%s\n", string, VehicleNames[vehicleVariables[i][vVehicleModelID] - 400], selColor[175], vehicleVariables[i][vVehicleNumber], NumberFormat(vehPrice[vehicleVariables[i][vVehicleModelID]]));
else format(string, sizeof(string), "%s%s\t{%s}[ spawned ]\t%s\t$%s\n", string, VehicleNames[vehicleVariables[i][vVehicleModelID] - 400], selColor[226], vehicleVariables[i][vVehicleNumber], NumberFormat(vehPrice[vehicleVariables[i][vVehicleModelID]]));
count++;
}
}
ShowPlayerDialog(playerid, DIALOG_DISPLAY_VEHICLES, DIALOG_STYLE_TABLIST_HEADERS, "SERVER: Your Vehicles", string, "Select", "Cancel");
return 1;
}
Now whenever I use that command, the dialog works fine, but when I click on the vehicle, I get the error "Array index out of bounds".
This is the dialog response code:
Код:
if(dialogid == DIALOG_DISPLAY_VEHICLES)
{
if(response)
{
new x = SelVeh[playerid][listitem];
SpawnVehicleIfDespawned(x);
SetPVarInt(playerid, "selected_vehicle", GrabVID(x));
printf("GrabVID: %d", GrabVID(x));
format(szMessage, sizeof(szMessage), "%s (%d)", VehicleNames[vehicleVariables[GrabVID(x)][vVehicleModelID] - 400], x);
ShowPlayerDialog(playerid, DIALOG_VEHICLE_INFO, DIALOG_STYLE_LIST, "test", "Respawn Vehicle\nFind Vehicle\nSet Carplate\nPay Insurance\nSet Price\nUnstuck Vehicle\n{FFD738}Upgrade to VIP{FFFFFF}", "Select", "Cancel");
}
}
This is the GrabVID stock:
Код:
stock GrabVID(x)
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(vehicleVariables[i][vVehicleID] == x) return i;
}
return INVALID_VEHICLE_ID;
}


