Accessing element at index 65535 past array upper bound 1999 -
JordanZaundd - 20.08.2015
Hey, when I tried updating my script from 0.3z to 0.3.7 I encountered these errors. Before, it worked without a problem. I've tried using the search but I've still not picked up on the problem, so I apologize in advanced for making another thread.
[debug] from server_log.txt
PHP код:
[19:47:48] [debug] Run time error 4: "Array index out of bounds"
[19:47:48] [debug] Accessing element at index 65535 past array upper bound 1999
[19:47:48] [debug] AMX backtrace:
[19:47:48] [debug] #0 001e8d90 in public CreateVehicleEx (1, 0, 0, 0, 0, 1, 1, -1) from MLRPv4.3.3d.amx
[19:47:48] [debug] #1 000daf80 in public OnCharacterLogin (0, 354) from MLRPv4.3.3d.amx
[19:47:48] [debug] #2 0007c540 in public OnDialogResponse (0, 2569, 1, 0, 12324896) from MLRPv4.3.3d.amx
OnCharacterLogin is a big function so I will leave it out and try to solve that on my own.
Any and all help is appreciated, thank you.
CreateVehicleEx() function
PHP код:
public CreateVehicleEx(model, Float:X, Float:Y, Float:Z, Float:A, color1, color2, spawntime)
{
// FuncLog("CreateVehicleEx");
new car = CreateVehicle(model, X, Y, Z, A, color1, color2, spawntime);
VehApproved[car] = 1;
VehLocked[car] = 0;
DeleteList[car] = 0;
if(IsLicensePlate(model))
{
SetVehicleNumberPlate(car, "MLRP");
}
// RespawnCar(car);
PlayerHaul[car][pCapasity] = VehicleCapasity(model);
PlayerHaul[car][pLoad] = 0;
Gas[car] = 100;
VehNeon[car][0] = 0;
VehNeon[car][1] = 0;
if(!IsACar(model))
{
SetVehicleParamsEx(car, 1, 0, 0, 0, 0, 0, 0);
}
else
{
SetVehicleParamsEx(car, 0, 0, 0, 0, 0, 0, 0);
}
for(new s; s<MAX_TRUNK_SLOTS; s++)
{
TrunkInfo[car][s][tItemAmount] = 0;
TrunkInfo[car][s][tItemID] = 0;
TrunkInfo[car][s][tItemType] = 0;
format(TrunkInfo[car][s][tItemTitle], 30, "Empty");
UpdateVehicleTrunk(car, s);
}
return car;
}
dialogid == 2569
PHP код:
if(dialogid == 2569) { // Character Menu
if(!response) KickEx(playerid);
else {
new charQuery[128];
format(charQuery, sizeof(charQuery), "SELECT * FROM `accounts` WHERE `Username`='%s' LIMIT 1;", GPN(playerid));
mysql_query(charQuery);
mysql_store_result();
mysql_fetch_row(MySQLData, "|");
mysql_free_result();
split2(MySQLData, MySQLField, '|');
switch(listitem) {
case 0: {
if(strval(MySQLField[13]) > 0) OnCharacterLogin(playerid, strval(MySQLField[13]));
else {
ShowPlayerDialog(playerid, 2570, DIALOG_STYLE_INPUT, "Character Creation", "Please Input a name for your character.\n{FF0000}Example: John_Smith", "Create", "Cancel");
CreatingChar[playerid] = 1;
}
} case 1: {
if(strval(MySQLField[14]) > 0) OnCharacterLogin(playerid, strval(MySQLField[14]));
else {
ShowPlayerDialog(playerid, 2570, DIALOG_STYLE_INPUT, "Character Creation", "Please Input a name for your character.\n{FF0000}Example: John_Smith", "Create", "Cancel");
CreatingChar[playerid] = 2;
}
} case 2: {
if(strval(MySQLField[15]) > 0) OnCharacterLogin(playerid, strval(MySQLField[15]));
else {
ShowPlayerDialog(playerid, 2570, DIALOG_STYLE_INPUT, "Character Creation", "Please Input a name for your character.\n{FF0000}Example: John_Smith", "Create", "Cancel");
CreatingChar[playerid] = 3;
}
} case 3: {
if(strval(MySQLField[16]) > 0) OnCharacterLogin(playerid, strval(MySQLField[16]));
else {
ShowPlayerDialog(playerid, 2570, DIALOG_STYLE_INPUT, "Character Creation", "Please Input a name for your character.\n{FF0000}Example: John_Smith", "Create", "Cancel");
CreatingChar[playerid] = 4;
}
} case 4: {
if(strval(MySQLField[17]) > 0) OnCharacterLogin(playerid, strval(MySQLField[17]));
else {
ShowPlayerDialog(playerid, 2570, DIALOG_STYLE_INPUT, "Character Creation", "Please Input a name for your character.\n{FF0000}Example: John_Smith", "Create", "Cancel");
CreatingChar[playerid] = 5;
}
}
}
}
return 1;
}
Re: Accessing element at index 65535 past array upper bound 1999 -
Jefff - 20.08.2015
pawn Код:
[debug] #0 001e8d90 in public CreateVehicleEx (1, 0, 0, 0, 0, 1, 1, -1)
modelid is 1 so read 'Return Values'
https://sampwiki.blast.hk/wiki/CreateVehicle
2. Why you use same thing many times?
pawn Код:
if(dialogid == 2569) // Character Menu
{
if(!response) KickEx(playerid);
else
{
new charQuery[128];
format(charQuery, sizeof(charQuery), "SELECT * FROM `accounts` WHERE `Username`='%s' LIMIT 1;", GPN(playerid));
mysql_query(charQuery);
mysql_store_result();
mysql_fetch_row(MySQLData);
mysql_free_result();
split2(MySQLData, MySQLField, '|');
if(-1 < listitem < 5)
{
new ID = listitem + 13;
if(strval(MySQLField[ID]) > 0) OnCharacterLogin(playerid, strval(MySQLField[ID]));
else
{
ShowPlayerDialog(playerid, 2570, DIALOG_STYLE_INPUT, "Character Creation", "Please Input a name for your character.\n{FF0000}Example: John_Smith", "Create", "Cancel");
CreatingChar[playerid] = ID - 12;
}
}
}
return 1;
}
Re: Accessing element at index 65535 past array upper bound 1999 -
JordanZaundd - 20.08.2015
1. Yes but I'm having trouble finding what the error is referencing. I mean, obviously '1' is an invalid modelid. When I delete my mysql column containing my vehicle's information, it doesn't give me anymore errors. So I'm going to look at that.
2. I have 5 character slots available.
Re: Accessing element at index 65535 past array upper bound 1999 -
Jefff - 20.08.2015
Show hou you load info for CreateVehicleEx in OnCharacterLogin
2. Its short version instead of yours
Re: Accessing element at index 65535 past array upper bound 1999 -
JordanZaundd - 20.08.2015
I'll give you the mySQL table too just incase you need it. Thank you for your help so far.
PHP код:
format(query, sizeof(query), "SELECT * FROM `uservehicles` WHERE `id` = %d LIMIT 1;", charid);
mysql_query(query);
mysql_store_result();
mysql_fetch_row(MySQLData, "|");
split2(MySQLData, MySQLField, '|');
for(new v = 0; v < MAX_PLAYERVEHICLES; v++)
{ // 0, 1 useless cuz its the ID & username
PlayerVehicleInfo[playerid][v][pvPosX] = floatstr(MySQLField[v*39+2]); // This formula is to calculate WHICH car to load from
PlayerVehicleInfo[playerid][v][pvPosY] = floatstr(MySQLField[v*39+3]); // The first car is MySQLField 2 here but if its the 2nd Car its MySQLField 12
PlayerVehicleInfo[playerid][v][pvPosZ] = floatstr(MySQLField[v*39+4]);
PlayerVehicleInfo[playerid][v][pvPosAngle] = floatstr(MySQLField[v*39+5]);
PlayerVehicleInfo[playerid][v][pvModelId] = strval(MySQLField[v*39+6]);
PlayerVehicleInfo[playerid][v][pvLock] = strval(MySQLField[v*39+7]);
PlayerVehicleInfo[playerid][v][pvLocked] = strval(MySQLField[v*39+8]);
PlayerVehicleInfo[playerid][v][pvPaintJob] = strval(MySQLField[v*39+9]);
PlayerVehicleInfo[playerid][v][pvColor1] = strval(MySQLField[v*39+10]);
PlayerVehicleInfo[playerid][v][pvColor2] = strval(MySQLField[v*39+11]);
for(new m = 0; m < MAX_MODS; m++)
{
PlayerVehicleInfo[playerid][v][pvMods][m] = strval(MySQLField[ v*37+1+11+m ]); // same as above but fits to the Mod Loop
}
PlayerVehicleInfo[playerid][v][pvDamage] = floatstr(MySQLField[v*39+13+13]); // 25
PlayerVehicleInfo[playerid][v][pvDamageStatus][0] = strval(MySQLField[v*39+13+14]); //
PlayerVehicleInfo[playerid][v][pvDamageStatus][1] = strval(MySQLField[v*39+13+15]); //
PlayerVehicleInfo[playerid][v][pvDamageStatus][2] = strval(MySQLField[v*39+13+16]); //
PlayerVehicleInfo[playerid][v][pvDamageStatus][3] = strval(MySQLField[v*39+13+17]); //
PlayerVehicleInfo[playerid][v][pvNeon] = strval(MySQLField[v*39+13+18]); //
PlayerVehicleInfo[playerid][v][pvFuel] = strval(MySQLField[v*39+13+19]); //
format(PlayerVehicleInfo[playerid][v][pvPlate], 33, "%s", MySQLField[v*39+13+20]); //
PlayerVehicleInfo[playerid][v][pvInInsurance] = strval(MySQLField[v*39+13+26]);
PlayerVehicleInfo[playerid][v][pvLockType] = strval(MySQLField[v*39+13+27]);
// Gotta spawn the car early so the trunk can load into it
if(PlayerVehicleInfo[playerid][v][pvModelId] != 0 && PlayerVehicleInfo[playerid][v][pvInInsurance] == 0)
{
new carcreated = CreateVehicleEx(PlayerVehicleInfo[playerid][v][pvModelId], PlayerVehicleInfo[playerid][v][pvPosX], PlayerVehicleInfo[playerid][v][pvPosY], PlayerVehicleInfo[playerid][v][pvPosZ], PlayerVehicleInfo[playerid][v][pvPosAngle],1, 1, -1);
PlayerVehicleInfo[playerid][v][pvId] = carcreated;
VehOwner[carcreated] = playerid;
if(PlayerVehicleInfo[playerid][v][pvLocked] > 0)
{
LockCar(carcreated);
}
new tmpstore[4][31];
for(new t = 0; t<MAX_TRUNK_SLOTS; t++)
{
split2(MySQLField[v*39+13+21+t], tmpstore, '-');
TrunkInfo[PlayerVehicleInfo[playerid][v][pvId]][t][tItemType] = strval(tmpstore[0]);
TrunkInfo[PlayerVehicleInfo[playerid][v][pvId]][t][tItemID] = strval(tmpstore[1]);
TrunkItnfo[PlayerVehicleInfo[playerid][v][pvId]][t][tItemAmount] = strval(tmpstore[2]);
format(TrunkInfo[PlayerVehicleInfo[playerid][v][pvId]][t][tItemTitle], 30, "%s", tmpstore[3]);
}
}
}
Here is an image of the mysql table
And The information that is default filled in the table when an account is created.
2. Short version gave me warnings when compiling and gave me errors when trying to load my character.
Re: Accessing element at index 65535 past array upper bound 1999 -
JordanZaundd - 20.08.2015
Bump because I'm still having trouble finding the problem
Re: Accessing element at index 65535 past array upper bound 1999 -
Vince - 20.08.2015
My god! That is absolutely
horrible and cringe worthy. Please read my tutorials on database normalization.
Re: Accessing element at index 65535 past array upper bound 1999 -
Jefff - 20.08.2015
So problem is here
pawn Код:
PlayerVehicleInfo[playerid][v][pvModelId] = strval(MySQLField[v*39+6]);
2. Show errors
Re: Accessing element at index 65535 past array upper bound 1999 -
JordanZaundd - 21.08.2015
Thank you! I was able to fix my problem! My database was missing 2 columns per vehicle, I feel stupid for not noticing it sooner...
2. Here is the pawno compile warnings and ingame login error.
PHP код:
C:\Users\Jordan\Desktop\ModernLife Gaming\NEW\gamemodes\MLRPv4.3.3d.pwn(13999) : warning 219: local variable "ID" shadows a variable at a preceding level
C:\Users\Jordan\Desktop\ModernLife Gaming\NEW\gamemodes\MLRPv4.3.3d.pwn(14004) : warning 213: tag mismatch
C:\Users\Jordan\Desktop\ModernLife Gaming\NEW\gamemodes\MLRPv4.3.3d.pwn(13999) : warning 204: symbol is assigned a value that is never used: "ID"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
3 Warnings.