How could I find the error line?
#1

Code:
[debug] Run time error 4: "Array index out of bounds"
[debug]  Attempted to read/write array element at index 11 in array of size 11
[debug] AMX backtrace:
[debug] #0 0016c4b0 in ?? (0) in Gamemode.amx
[debug] #1 000b1c78 in public OnDialogResponse (0, 2, 1, -1, 22695856) in Gamemode.amx
This error comes to me in a specific dialogue:

pawn Code:
case DIALOG_LOGIN:
        {
            if(!response) return Kick(playerid);
            if(!strlen(inputtext)) return ShowDialog(playerid, dialogid);
           
            new password[64 + 1];
            SHA256_PassHash(inputtext, ACCOUNT_INFO[playerid][ac_SALT], password, sizeof password);
       
            if(!strcmp(password, ACCOUNT_INFO[playerid][ac_PASS], false))
            {
                LoadCharacterData(playerid);
                LoadPlayerBankAccountData(playerid);
                LoadPlayerToysData(playerid);
                LoadPlayerPocketData(playerid);
                LoadPlayerPhoneData(playerid);
                LoadPlayerGPSData(playerid);
                LoadPlayerObjectsData(playerid);
                LoadPlayerVehicles(playerid);
                LoadPlayerSkills(playerid);
                LoadPlayerWorks(playerid);
                LoadPlayerMisc(playerid);
                LoadPlayerWeaponsData(playerid);
                LoadPlayerCrewInfo(playerid);
               
                SetPlayerScore(playerid, ACCOUNT_INFO[playerid][ac_LEVEL]);
                PLAYER_TEMP[playerid][pt_DOUBT_CHANNEL_TIME] = gettime();
                ResetPlayerWeapons(playerid);
                ResetPlayerMoney(playerid);
                GivePlayerMoney(playerid, CHARACTER_INFO[playerid][ch_CASH]);
                SetPlayerFightingStyle(playerid, CHARACTER_INFO[playerid][ch_FIGHT_STYLE]);
                SetPlayerHealthEx(playerid, CHARACTER_INFO[playerid][ch_HEALTH]);
                SetPlayerArmourEx(playerid, CHARACTER_INFO[playerid][ch_ARMOUR]);
                SetPlayerVirtualWorld(playerid, 0);
                SetPlayerNormalColor(playerid);
                StopAudioStreamForPlayer(playerid);
                SetSpawnInfo(playerid, NO_TEAM, CHARACTER_INFO[playerid][ch_SKIN], CHARACTER_INFO[playerid][ch_POS][0], CHARACTER_INFO[playerid][ch_POS][1], CHARACTER_INFO[playerid][ch_POS][2], CHARACTER_INFO[playerid][ch_ANGLE], 0, 0, 0, 0, 0, 0);
                SetPlayerInterior(playerid, CHARACTER_INFO[playerid][ch_INTERIOR]);
               
                PLAYER_TEMP[playerid][pt_BAD_LOGIN_ATTEMP] = 0;
                TogglePlayerSpectatingEx(playerid, false);
                TogglePlayerControllableEx(playerid, false);
                SendClientMessageEx(playerid, -1,"ЎHello {e53c3c}%s!, {FFFFFF} last connection: %s.", PLAYER_TEMP[playerid][pt_RP_NAME], ACCOUNT_INFO[playerid][ac_LAST_CONNECTION]);
            }
            else
            {
                PLAYER_TEMP[playerid][pt_BAD_LOGIN_ATTEMP] ++;
                if(PLAYER_TEMP[playerid][pt_BAD_LOGIN_ATTEMP] > MAX_BAD_LOGIN_ATTEMPS) return Kick(playerid);
                ShowDialog(playerid, dialogid);
            }
            return 1;
        }
Reply
#2

https://github.com/Zeex/samp-plugin-...ith-debug-info

After compiling the script with -d3 flag, wait for it to happen again. It will log the function name and line.

The error means that there is an array with size 11 and valid bounds are 0 to 10. But script tried to access element with index 11.

Using <= MAX_SOMETHING in loops can also cause this (the correct would be < MAX_SOMETHING).
Reply
#3

Quote:
Originally Posted by Calisthenics
View Post
https://github.com/Zeex/samp-plugin-...ith-debug-info

After compiling the script with -d3 flag, wait for it to happen again. It will log the function name and line.

The error means that there is an array with size 11 and valid bounds are 0 to 10. But script tried to access element with index 11.
It throws me the same as before


Quote:
Originally Posted by Calisthenics
View Post
Using <= MAX_SOMETHING in loops can also cause this (the correct would be < MAX_SOMETHING).
I checked everything, and they're fine.


another way to find it?
Reply
#4

Quote:
Originally Posted by KaliDobrev
View Post
It throws me the same as before
The same run time error but more detailed logs. Unless you did not do the steps correctly or you use another editor (not pawno).

Quote:
Originally Posted by KaliDobrev
View Post
another way to find it?
Yes. Print messages:
pawn Code:
LoadCharacterData(playerid);
print("LoadCharacterData called");
LoadPlayerBankAccountData(playerid);
print("LoadPlayerBankAccountData called");
LoadPlayerToysData(playerid);
print("LoadPlayerToysData called");
LoadPlayerPocketData(playerid);
print("LoadPlayerPocketData called");
...
If the mistake is for example in the second function, it will only print the first message so you know where to search.
Reply
#5

Quote:
Originally Posted by Calisthenics
View Post
The same run time error but more detailed logs. Unless you did not do the steps correctly or you use another editor (not pawno).



Yes. Print messages:
pawn Code:
LoadCharacterData(playerid);
print("LoadCharacterData called");
LoadPlayerBankAccountData(playerid);
print("LoadPlayerBankAccountData called");
LoadPlayerToysData(playerid);
print("LoadPlayerToysData called");
LoadPlayerPocketData(playerid);
print("LoadPlayerPocketData called");
...
If the mistake is for example in the second function, it will only print the first message so you know where to search.
Ready, I found the error, thanks boss
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)