29.11.2014, 23:35
I don't really know whats happening seen as this is working in one of my other scripts. It seems to be the loop what is causing the problem as stated in the LOG
Note: the area what is causing the code as been marked. The Log has also been provided.
Note: the area what is causing the code as been marked. The Log has also been provided.
Код:
[00:14:35] [debug] Run time error 4: "Array index out of bounds" [00:14:35] [debug] Accessing element at index 12 past array upper bound 11 [00:14:35] [debug] AMX backtrace: [00:14:35] [debug] #0 00029f04 in ?? (0, 0) from rp.amx [00:14:35] [debug] #1 00029c14 in public OpenInventory (0) from rp.amx [00:14:35] [debug] #2 0002a4ac in public cmd_inv (0, 4417524) from rp.amx [00:14:35] [debug] #3 native CallLocalFunction () from samp-server.exe [00:14:35] [debug] #4 00008838 in public OnPlayerCommandText (0, 4417504) from rp.amx
pawn Код:
enum e_PreviewOffsets {
e_PreviewModel,
Float:e_PreviewX,
Float:e_PreviewY,
Float:e_PreviewZ
};
static const g_aPreviewOffsets[][e_PreviewOffsets] =
{
{18875, 90.0, 180.0, 0.0},
{2703, -105.0, 0.0, -15.0},
{2702, 90.0, 90.0, 0.0},
{2814, -90.0, 0.0, -90.0},
{2768, -15.0, 0.0, -160.0},
{19142, -20.0, -90.0, 0.0},
{19166, -90.0, 0.0, -90.0},
{1581, 0.0, 0.0, 180.0},
{2958, -10.0, -15.0, 0.0},
{18634, 90.0, 90.0, 0.0},
{2043, 0.0, 0.0, 90.0},
{1484, -15.0, 30.0, 0.0},
{2226, 0.0, 0.0, 180.0}
};
stock Inventory_Open(playerid, targetid = INVALID_PLAYER_ID)
{
printf("STARTING INVENTORY OPEN");
if (targetid == INVALID_PLAYER_ID)
targetid = playerid;
for(new i = 0; i < 12; i ++)
{
if(InventoryData[targetid][i][itemExists])
{
PlayerTextDrawSetPreviewModel(playerid, CharacterInventory[playerid][i], InventoryData[targetid][i][itemModel]);
} else {
PlayerTextDrawSetPreviewModel(playerid, CharacterInventory[playerid][i], 19300);
}
/* THIS AREA CAUSES THE AMX ERROR
for (new oj = 0; oj < sizeof(g_aPreviewOffsets); oj ++)
{
if (g_aPreviewOffsets[oj][e_PreviewModel] == InventoryData[targetid][oj][itemModel])
{
PlayerTextDrawSetPreviewRot(playerid, CharacterInventory[playerid][i], g_aPreviewOffsets[oj][e_PreviewX], g_aPreviewOffsets[oj][e_PreviewY], g_aPreviewOffsets[oj][e_PreviewZ]);
}
}
*/
}
printf("SETTING STRINGS");
if (targetid == playerid)
{
PlayerTextDrawSetString(playerid, CharacterInventory[playerid][1], "My Inventory");
}
else
{
PlayerTextDrawSetString(playerid, CharacterInventory[playerid][1], "Player Inventory");
}
printf("SETTING PREVIEW MODELS");
PlayerTextDrawSetPreviewModel(playerid, CharacterInventory[playerid][17], CharacterInformation[targetid][CHAR(targetid)][CharacterSkin]);
PlayerTextDrawSetPreviewModel(playerid, CharacterInventory[playerid][17], 19300);
/*
if (2 <= GetPlayerWeapon(targetid) <= 46)
PlayerTextDrawSetPreviewModel(playerid, CharacterInterface[playerid][CharacterInventory][], GetWeaponModelID(GetPlayerWeapon(targetid)));
*/
printf("SHOWING TEXTDRAWS");
for (new i = 0; i < 19; i ++) {
PlayerTextDrawShow(playerid, CharacterInventory[playerid][i]);
}
printf("STOPPING SELECTION");
SelectTextDraw(playerid, -1);
printf("FINISHED");
return true;
}