PDA

View Full Version : OnDialogResponse error


[S-G]Cypher
10/10/2015, 07:17 PM
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[])
{

Stinged
10/10/2015, 07:22 PM
Post the code of dialogid = 2981

[S-G]Cypher
10/10/2015, 07:25 PM
SendClientMessageEx(playerid, COLOR_WHITE, "{AA3333}HINT:{FFFF00} Position your camera differently to better see where your editing.");

Stinged
10/10/2015, 07:28 PM
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"

[S-G]Cypher
10/10/2015, 07:30 PM
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);
}
}

Stinged
10/10/2015, 07:35 PM
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.

[S-G]Cypher
10/10/2015, 07:42 PM
#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.");
}
}

Unte99
10/10/2015, 08:59 PM
See if this helps:


while(iDialogCount < 50 && iBreak < 499) {