OnDialogResponse error
#1

I got this error and I don't know how to fix it, I'm new with it
Код:
[21:10:45] [debug] Run time error 4: "Array index out of bounds"
[21:10:45] [debug]  Accessing element at index 1738042551 past array upper bound 499
[21:10:45] [debug] AMX backtrace:
[21:10:45] [debug] #0 00484648 in public OnDialogResponse (0, 2981, 1, 3, 109609540) from SLRP.amx
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
Reply
#2

Post the code of dialogid = 2981
Reply
#3

Код:
SendClientMessageEx(playerid, COLOR_WHITE, "{AA3333}HINT:{FFFF00} Position your camera differently to better see where your editing.");
Reply
#4

That's it? It doesn't really give us that much information to work on.
If that's the only thing there, could you please post the code of "SendClientMessageEx"
Reply
#5

Sorry, Is this enough?

Код:
if((dialogid == EDITTOYS) && response)
	{
		/*new toycount = GetFreeToySlot(playerid);
		if(toycount >= 10) return SendClientMessageEx(playerid, COLOR_GRAD1, "You currently have 10 objects attached, please deattach an object.");*/
		
		if(listitem >= GetPlayerToySlots(playerid)) 
	    {
	        new szstring[128];
			SetPVarInt(playerid, "MiscShop", 8);
			format(szstring, sizeof(szstring), "Additional Toy Slot\nYour Credits: %s\nCost: {FFD700}%s{A9C4E4}\nCredits Left: %s", number_format(PlayerInfo[playerid][pCredits]), number_format(ShopItems[28][sItemPrice]), number_format(PlayerInfo[playerid][pCredits]-ShopItems[28][sItemPrice]));
			return ShowPlayerDialog(playerid, DIALOG_MISCSHOP2, DIALOG_STYLE_MSGBOX, "Additional Toy Slot", szstring, "Purchase", "Cancel");
		}
		else if(PlayerToyInfo[playerid][listitem][ptModelID] == 0 && listitem < GetPlayerToySlots(playerid))
		{
			ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Edit your toy", "Woops! You don't have anything to edit in that slot.", "Okay", "");
		}
		else
		{
            2981    SendClientMessageEx(playerid, COLOR_WHITE, "{AA3333}HINT:{FFFF00} Position your camera differently to better see where your editing.");
		    SetPVarInt(playerid, "ToySlot", listitem);
		    ShowEditMenu(playerid);
		}
	}
Reply
#6

I think you misunderstood me. What I needed was the code of dialog = 2981, and not the line number.
It seems that your script has defined dialog ids, so search between your defines for a
#define [some name here] 2981
And then post the code of that dialog.
Reply
#7

Код:
#define			DIALOG_ADCATEGORY			(2981)
Код:
case DIALOG_ADCATEGORY: if(response) switch(listitem) {
			case 0: {

				new
					szDialog[2256],
					szBuffer[32],
					arrAdverts[MAX_PLAYERS] = INVALID_PLAYER_ID,
					iDialogCount,
					iCount,
					iBreak,
					iRand;

				for(new x; x < 50; ++x) ListItemTrackId[playerid][x] = -1;
				foreach(new i: Player)
				{ if(!isnull(szAdvert[i])) arrAdverts[iCount++] = i; }

				while(iDialogCount < 50 && iBreak < 500) {
					iRand = random(iCount);
					if(arrAdverts[iRand] != INVALID_PLAYER_ID) {
						if(AdvertType[arrAdverts[iRand]] == 1) //Real Estate
						{
							strcpy(szBuffer, szAdvert[arrAdverts[iRand]], sizeof(szBuffer));
							if(PlayerInfo[playerid][pAdmin] <= 1) format(szDialog, sizeof(szDialog), "%s%s... (%i)\r\n", szDialog, szBuffer, PlayerInfo[arrAdverts[iRand]][pPnumber]);
							else format(szDialog, sizeof(szDialog), "%s%s... (%s)\r\n", szDialog, szBuffer, GetPlayerNameEx(arrAdverts[iRand]));
							ListItemTrackId[playerid][iDialogCount++] = arrAdverts[iRand];
							arrAdverts[iRand] = INVALID_PLAYER_ID;	
						}
					}
					++iBreak;
				}
				if(!isnull(szDialog)) return ShowPlayerDialog(playerid, DIALOG_ADLIST, DIALOG_STYLE_LIST, "Advertisements - List", szDialog, "Select", "Return");
				ShowPlayerDialog(playerid, DIALOG_ADCATEGORY, DIALOG_STYLE_LIST, "Advertisements Categories", "Real Estate\nAutomobile\nBuying\nSelling\nMiscellaneous", "Select", "Cancel");
				SendClientMessage(playerid, COLOR_GREY, "No advertisements have been posted.");
			}
			case 1: {

				new
					szDialog[2256],
					szBuffer[32],
					arrAdverts[MAX_PLAYERS] = INVALID_PLAYER_ID,
					iDialogCount,
					iCount,
					iBreak,
					iRand;

				for(new x; x < 50; ++x) ListItemTrackId[playerid][x] = -1;
				foreach(new i: Player)
				{ if(!isnull(szAdvert[i])) arrAdverts[iCount++] = i; }

				while(iDialogCount < 50 && iBreak < 500) {
					iRand = random(iCount);
					if(arrAdverts[iRand] != INVALID_PLAYER_ID) {
						if(AdvertType[arrAdverts[iRand]] == 2) //Automobile
						{
							strcpy(szBuffer, szAdvert[arrAdverts[iRand]], sizeof(szBuffer));
							if(PlayerInfo[playerid][pAdmin] <= 1) format(szDialog, sizeof(szDialog), "%s%s... (%i)\r\n", szDialog, szBuffer, PlayerInfo[arrAdverts[iRand]][pPnumber]);
							else format(szDialog, sizeof(szDialog), "%s%s... (%s)\r\n", szDialog, szBuffer, GetPlayerNameEx(arrAdverts[iRand]));
							ListItemTrackId[playerid][iDialogCount++] = arrAdverts[iRand];
							arrAdverts[iRand] = INVALID_PLAYER_ID;
						}
					}
					++iBreak;
				}
				if(!isnull(szDialog)) return ShowPlayerDialog(playerid, DIALOG_ADLIST, DIALOG_STYLE_LIST, "Advertisements - List", szDialog, "Select", "Return");
				ShowPlayerDialog(playerid, DIALOG_ADCATEGORY, DIALOG_STYLE_LIST, "Advertisements Categories", "Real Estate\nAutomobile\nBuying\nSelling\nMiscellaneous", "Select", "Cancel");
				SendClientMessage(playerid, COLOR_GREY, "No advertisements have been posted.");
			}
			case 2: {

				new
					szDialog[2256],
					szBuffer[32],
					arrAdverts[MAX_PLAYERS] = INVALID_PLAYER_ID,
					iDialogCount,
					iCount,
					iBreak,
					iRand;

				for(new x; x < 50; ++x) ListItemTrackId[playerid][x] = -1;
				foreach(new i: Player)
				{ if(!isnull(szAdvert[i])) arrAdverts[iCount++] = i; }

				while(iDialogCount < 50 && iBreak < 500) {
					iRand = random(iCount);
					if(arrAdverts[iRand] != INVALID_PLAYER_ID) {
						if(AdvertType[arrAdverts[iRand]] == 3) //Buying
						{
							strcpy(szBuffer, szAdvert[arrAdverts[iRand]], sizeof(szBuffer));
							if(PlayerInfo[playerid][pAdmin] <= 1) format(szDialog, sizeof(szDialog), "%s%s... (%i)\r\n", szDialog, szBuffer, PlayerInfo[arrAdverts[iRand]][pPnumber]);
							else format(szDialog, sizeof(szDialog), "%s%s... (%s)\r\n", szDialog, szBuffer, GetPlayerNameEx(arrAdverts[iRand]));
							ListItemTrackId[playerid][iDialogCount++] = arrAdverts[iRand];
							arrAdverts[iRand] = INVALID_PLAYER_ID;
						}
					}
					++iBreak;
				}
				if(!isnull(szDialog)) return ShowPlayerDialog(playerid, DIALOG_ADLIST, DIALOG_STYLE_LIST, "Advertisements - List", szDialog, "Select", "Return");
				ShowPlayerDialog(playerid, DIALOG_ADCATEGORY, DIALOG_STYLE_LIST, "Advertisements Categories", "Real Estate\nAutomobile\nBuying\nSelling\nMiscellaneous", "Select", "Cancel");
				SendClientMessage(playerid, COLOR_GREY, "No advertisements have been posted.");
			}
			case 3: {

				new
					szDialog[2256],
					szBuffer[32],
					arrAdverts[MAX_PLAYERS] = INVALID_PLAYER_ID,
					iDialogCount,
					iCount,
					iBreak,
					iRand;

				for(new x; x < 50; ++x) ListItemTrackId[playerid][x] = -1;
				foreach(new i: Player)
				{ if(!isnull(szAdvert[i])) arrAdverts[iCount++] = i; }

				while(iDialogCount < 50 && iBreak < 500) {
					iRand = random(iCount);
					if(arrAdverts[iRand] != INVALID_PLAYER_ID) {
						if(AdvertType[arrAdverts[iRand]] == 4) //Selling
						{
							strcpy(szBuffer, szAdvert[arrAdverts[iRand]], sizeof(szBuffer));
							if(PlayerInfo[playerid][pAdmin] <= 1) format(szDialog, sizeof(szDialog), "%s%s... (%i)\r\n", szDialog, szBuffer, PlayerInfo[arrAdverts[iRand]][pPnumber]);
							else format(szDialog, sizeof(szDialog), "%s%s... (%s)\r\n", szDialog, szBuffer, GetPlayerNameEx(arrAdverts[iRand]));
							ListItemTrackId[playerid][iDialogCount++] = arrAdverts[iRand];
							arrAdverts[iRand] = INVALID_PLAYER_ID;	
						}
					}
					++iBreak;
				}
				if(!isnull(szDialog)) return ShowPlayerDialog(playerid, DIALOG_ADLIST, DIALOG_STYLE_LIST, "Advertisements - List", szDialog, "Select", "Return");
				ShowPlayerDialog(playerid, DIALOG_ADCATEGORY, DIALOG_STYLE_LIST, "Advertisements Categories", "Real Estate\nAutomobile\nBuying\nSelling\nMiscellaneous", "Select", "Cancel");
				SendClientMessage(playerid, COLOR_GREY, "No advertisements have been posted.");
			}
			case 4: {

				new
					szDialog[2256],
					szBuffer[32],
					arrAdverts[MAX_PLAYERS] = INVALID_PLAYER_ID,
					iDialogCount,
					iCount,
					iBreak,
					iRand;

				for(new x; x < 50; ++x) ListItemTrackId[playerid][x] = -1;
				foreach(new i: Player)
				{ if(!isnull(szAdvert[i])) arrAdverts[iCount++] = i; }

				while(iDialogCount < 50 && iBreak < 500) {
					iRand = random(iCount);
					if(arrAdverts[iRand] != INVALID_PLAYER_ID) {
						if(AdvertType[arrAdverts[iRand]] == 5) //Miscellaneous
						{
							strcpy(szBuffer, szAdvert[arrAdverts[iRand]], sizeof(szBuffer));
							if(PlayerInfo[playerid][pAdmin] <= 1) format(szDialog, sizeof(szDialog), "%s%s... (%i)\r\n", szDialog, szBuffer, PlayerInfo[arrAdverts[iRand]][pPnumber]);
							else format(szDialog, sizeof(szDialog), "%s%s... (%s)\r\n", szDialog, szBuffer, GetPlayerNameEx(arrAdverts[iRand]));
							ListItemTrackId[playerid][iDialogCount++] = arrAdverts[iRand];
							arrAdverts[iRand] = INVALID_PLAYER_ID;
						}	
					}
					++iBreak;
				}
				if(!isnull(szDialog)) return ShowPlayerDialog(playerid, DIALOG_ADLIST, DIALOG_STYLE_LIST, "Advertisements - List", szDialog, "Select", "Return");
				ShowPlayerDialog(playerid, DIALOG_ADCATEGORY, DIALOG_STYLE_LIST, "Advertisements Categories", "Real Estate\nAutomobile\nBuying\nSelling\nMiscellaneous", "Select", "Cancel");
				SendClientMessage(playerid, COLOR_GREY, "No advertisements have been posted.");
			}
		}
Reply
#8

See if this helps:

Код:
while(iDialogCount < 50 && iBreak < 499) {
Reply


Forum Jump:


Users browsing this thread: