AMX Backtrace help
#1

As the title says, here's the code

Code:
if(dialogid == 10000)
    {
		if(response)
		{
        if(listitem == 0)
        {
            for(new i=0; i < MAX_DROPPED_ITEMS; i++)
            {
                if(DroppedItem[i][dItemAmount] == 0)
                {
					new Float:x, Float:y, Float:z;
					GetPlayerPos(playerid, x, y, z);
					DroppedItem[i][dItemX] = x;
					DroppedItem[i][dItemY] = y;
					DroppedItem[i][dItemZ] = z;
					GetPVarString(playerid, "SelectedItem", DroppedItem[i][dItemName], 32);
					for(new f=0; f < MAX_INVENTORY; f++)
					{
						if(!strcmp(DroppedItem[i][dItemName], PlayerInventory[playerid][f][pItemName]))
						{
							DroppedItem[i][dItemAmount] = PlayerInventory[playerid][f][pItemAmount];
							PlayerInventory[playerid][f][pItemAmount] = 0;
							format(PlayerInventory[playerid][f][pItemName], 32, "");
							new strings[64];
							format(strings, 64, ""COL_LIGHTGREEN"Drop %s, Amount %d", DroppedItem[i][dItemName], DroppedItem[i][dItemAmount]);
							SendClientMessage(playerid, -1, strings);
							SaveDroppedItems();
							return 1;
						}
					}
					return 1;
				}
			}
		}
		}
	}
MAX_DROPPED_ITEMS is 500
MAX_INVENTORY is 15
(The code gets un neat when i pasted it)

Code:
[debug] Run time error 4: "Array index out of bounds"
[debug]  Accessing element at index 50 past array upper bound 49
[debug] AMX backtrace:
[debug] #0 000c7868 in ?? () from NOTGM.amx
[debug] #1 00052000 in ?? (2, 10000, 1, 0, 29539412) from NOTGM.amx
[debug] #2 0000f0f0 in public OnDialogResponse (2, 10000, 1, 0, 29539412) from NOTGM.amx
Reply
#2

You'll find your fix here.

https://sampforum.blast.hk/showthread.php?tid=654036

Also, Try using debug level 3, so it shows you the exact lines that produce the crash.
If you don't know how to do that, here's how:
You should create a file called pawn.cfg in your pawno folder, inside this file write:

PHP Code:
-d3 
Save the file and recompile your script and run it with crashdetect again.

And then show us the exact line that caused the crash. It should be a for loop most of the time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)