Accessing element at index 65535 past array upper bound 1999
#1

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] [debugRun 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] [debugAMX 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(modelFloat:XFloat:YFloat:ZFloat:Acolor1color2spawntime)
{
    
// FuncLog("CreateVehicleEx");
    
new car CreateVehicle(modelXYZAcolor1color2spawntime);
    
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(car1000000);
    }
    else
    {
        
SetVehicleParamsEx(car0000000);
    }
    for(new 
ss<MAX_TRUNK_SLOTSs++)
    {
        
TrunkInfo[car][s][tItemAmount] = 0;
        
TrunkInfo[car][s][tItemID] = 0;
        
TrunkInfo[car][s][tItemType] = 0;
        
format(TrunkInfo[car][s][tItemTitle], 30"Empty");
        
UpdateVehicleTrunk(cars);
    }
    return 
car;

dialogid == 2569
PHP код:
if(dialogid == 2569) { // Character Menu
        
if(!responseKickEx(playerid);
        else {
            new 
charQuery[128];
            
format(charQuerysizeof(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(MySQLDataMySQLField'|');
            switch(
listitem) {
                case 
0: {
                    if(
strval(MySQLField[13]) > 0OnCharacterLogin(playeridstrval(MySQLField[13]));
                    else { 
                        
ShowPlayerDialog(playerid2570DIALOG_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]) > 0OnCharacterLogin(playeridstrval(MySQLField[14]));
                    else { 
                        
ShowPlayerDialog(playerid2570DIALOG_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]) > 0OnCharacterLogin(playeridstrval(MySQLField[15]));
                    else { 
                        
ShowPlayerDialog(playerid2570DIALOG_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]) > 0OnCharacterLogin(playeridstrval(MySQLField[16]));
                    else { 
                        
ShowPlayerDialog(playerid2570DIALOG_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]) > 0OnCharacterLogin(playeridstrval(MySQLField[17]));
                    else { 
                        
ShowPlayerDialog(playerid2570DIALOG_STYLE_INPUT"Character Creation""Please Input a name for your character.\n{FF0000}Example: John_Smith""Create""Cancel");
                        
CreatingChar[playerid] = 5;
                    }
                }
            }
        }
        return 
1;
    } 
Reply
#2

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;
}
Reply
#3

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.
Reply
#4

Show hou you load info for CreateVehicleEx in OnCharacterLogin

2. Its short version instead of yours
Reply
#5

I'll give you the mySQL table too just incase you need it. Thank you for your help so far.

PHP код:
format(querysizeof(query), "SELECT * FROM `uservehicles` WHERE `id` = %d LIMIT 1;"charid);
                
mysql_query(query);
                
mysql_store_result();
                
mysql_fetch_row(MySQLData"|");
                
split2(MySQLDataMySQLField'|');
                for(new 
0MAX_PLAYERVEHICLESv++)
                { 
// 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 
0MAX_MODSm++)
                    {
                        
PlayerVehicleInfo[playerid][v][pvMods][m] = strval(MySQLFieldv*37+1+11+]); // 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] != && 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],11, -1);
                            
PlayerVehicleInfo[playerid][v][pvId] = carcreated;
                            
VehOwner[carcreated] = playerid;
                            if(
PlayerVehicleInfo[playerid][v][pvLocked] > 0)
                            {
                                
LockCar(carcreated);
                            }
                            new 
tmpstore[4][31];
                            for(new 
0t<MAX_TRUNK_SLOTSt++)
                            {
                                
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.
Reply
#6

Bump because I'm still having trouble finding the problem
Reply
#7

My god! That is absolutely horrible and cringe worthy. Please read my tutorials on database normalization.
Reply
#8

So problem is here
pawn Код:
PlayerVehicleInfo[playerid][v][pvModelId] = strval(MySQLField[v*39+6]);
2. Show errors
Reply
#9

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 219local variable "ID" shadows a variable at a preceding level
C
:\Users\Jordan\Desktop\ModernLife Gaming\NEW\gamemodes\MLRPv4.3.3d.pwn(14004) : warning 213tag mismatch
C
:\Users\Jordan\Desktop\ModernLife Gaming\NEW\gamemodes\MLRPv4.3.3d.pwn(13999) : warning 204symbol is assigned a value that is never used"ID"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
3 Warnings

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)