2 debugs - +rep Array Problem
#1

Код:
[23:58:26] [debug] Run time error 4: "Array index out of bounds"
[23:58:26] [debug]  Accessing element at negative index -1
[23:58:26] [debug] AMX backtrace:
[23:58:26] [debug] #0 00013ab0 in Dialog_GetCarSelectHouse (playerid=10, response=1, listitem=2) at C:\Users\MaHdy\Desktop\HouseSystem.pwn:2214
Код:
[23:58:26] [debug] #1 000083c8 in public OnDialogResponse (playerid=10, dialogid=5010, response=1, listitem=2, inputtext[]=@0x001a3f84 "Musilm ") at C:\Users\MaHdy\Desktop\HouseSystem.pwn:742
[23:58:26] [chat] [RetroweR]: tm :SAFD
[23:58:31] [debug] Run time error 4: "Array index out of bounds"
[23:58:31] [debug]  Accessing element at negative index -1
[23:58:31] [debug] AMX backtrace:
Pawno Code Line 2214 (In Red Line):
Код:
// This dialog processes the selected house from which to get a vehicle using /getcar
Dialog_GetCarSelectHouse(playerid, response, listitem)
{
	// Just close the dialog if the player clicked "Cancel"
	if(!response) return 1;

	// Get the houseid based on the chosen listitem
	new HouseID = APlayerData[playerid][Houses][listitem];

	// Check if it was a valid house
	if (HouseID != 0)
	{
		// Setup local variables
	    new BuyableCarIndex, VehicleList[500], bool:HouseHasCars = false, CarSlot;

		// Store the HouseID, otherwise the next dialog won't be able to get a car from the chosen house
		APlayerData[playerid][DialogGetCarHouseID] = HouseID;

		// Check if the house has any cars assigned to it
		for (CarSlot = 0; CarSlot < AHouseData[HouseID][CarSlots]; CarSlot++)
			if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
			    HouseHasCars = true;

		// Check if the house has any cars assigned to it
		if (HouseHasCars == true)
		{
			// Add all vehicles to the list
			for (CarSlot = 0; CarSlot < AHouseData[HouseID][CarSlots]; CarSlot++)
			{
				// Check if the carslot has a vehicle in it
				if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
				{
				    // Get the index where the first vehicle is found in the ABuyableVehicles array
				    BuyableCarIndex = VehicleBuyable_GetIndex(GetVehicleModel(AHouseData[HouseID][VehicleIDs][CarSlot]));
				    // Add the name of the vehicle to the list
				    format(VehicleList, 500, "%s{00FF00}%s\n", VehicleList, ABuyableVehicles[BuyableCarIndex][CarName]);
				}
				else
					format(VehicleList, 500, "%s{FFFFFF}Empty car-slot{FFFFFF}\n", VehicleList);
			}

			// Ask which vehicle the player wants to teleport to his location
			ShowPlayerDialog(playerid, DialogGetCarSelectCar, DIALOG_STYLE_LIST, "Select vehicle to port to your location:", VehicleList, "Select", "Cancel");
		}
		else
		    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This house has no vehicles assigned to it");
	}
	else
	    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You don't have a house in this house-slot");

	return 1;
}
Code Line: 742 (In Red Line)
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	// Select the proper dialog to process
	switch (dialogid)
	{
		case DialogHouseMenu: Dialog_HouseMenu(playerid, response, listitem); // Process the main housemenu
		case DialogUpgradeHouse: Dialog_UpgradeHouse(playerid, response, listitem); // Process the house-upgrade menu
		case DialogGoHome: Dialog_GoHome(playerid, response, listitem); // Port to one of your houses
		case DialogHouseNameChange: Dialog_ChangeHouseName(playerid, response, inputtext); // Change the name of your house
		case DialogSellHouse: Dialog_SellHouse(playerid, response); // Sell the house
		case DialogBuyCarClass: Dialog_BuyCarClass(playerid, response, listitem); // The player chose a vehicleclass from where he can buy a vehicle
		case DialogBuyCar: Dialog_BuyCar(playerid, response, listitem); // The player chose a vehicle from the list of vehicles from the vehicleclass he chose before
		case DialogSellCar: Dialog_SellCar(playerid, response, listitem);
		case DialogBuyInsurance: Dialog_BuyInsurance(playerid, response);
		case DialogGetCarSelectHouse: Dialog_GetCarSelectHouse(playerid, response, listitem);
		case DialogGetCarSelectCar: Dialog_GetCarSelectCar(playerid, response, listitem);
	}

    return 0;
}
Reply
#2

Array infex out of bounds and trying to acces index -1 means you are trying to get info from for example:

Playerinfo[-1][house], which is not possible.
Try to find this issue in your script
Reply
#3

Isnt must to be for(i=0;i<=something;i++)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)