[02:42:48] [debug] Run time error 4: "Array index out of bounds"
[02:42:48] [debug] Accessing element at index 65535 past array upper bound 999
[02:42:48] [debug] AMX backtrace:
[02:42:48] [debug] #0 0004b5e0 in ?? (0x00000000) from deathmatch.amx
[02:42:48] [debug] #1 0006a4f0 in public WC_OnPlayerConnect (0x00000000) from deathmatch.amx
[02:42:48] [debug] #2 00032dc0 in public _y_utils_OnPlayerConnect (0x00000000) from deathmatch.amx
[02:42:48] [debug] #3 0000e2bc in public IPL_OnPlayerConnect (0x00000000) from deathmatch.amx
[02:42:48] [debug] #4 00007cbc in public SSCANF_OnPlayerConnect (0x00000000) from deathmatch.amx
[02:42:48] [debug] #5 000014f0 in ?? (0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, ... <1073741813 arguments>) from deathmatch.amx
[02:42:48] [debug] #6 0000f504 in public OnPlayerConnect (0x00000000) from deathmatch.amx
public OnPlayerConnect(playerid)
{
ResetDuelInfo(playerid);
PlayerInfo[playerid][Admin] = 0;
PlayerInfo[playerid][Money] = 0;
PlayerInfo[playerid][Kills] = 0;
PlayerInfo[playerid][Deaths] = 0;
PlayerInfo[playerid][Skin] = 0;
PlayerInfo[playerid][MutedTime] = 0;
PlayerInfo[playerid][JailedTime] = 0;
new query[1500];
GetPlayerName(playerid, Name[playerid], 24);
GetPlayerIp(playerid, IP[playerid], 16);
mysql_format(Database, query, sizeof(query),"SELECT `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
mysql_tquery(Database, query, "OnAccountCheck", "i", playerid);
new array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
mysql_format(Database, query, sizeof(query), "SELECT * FROM `players` WHERE `IP` LIKE '%e%'", IP[playerid]);
mysql_pquery(Database, query, "CheckIP", "dad", playerid, array, sizeof(array));
return 1;
}
Compiling with -d3 flag will log the line.
The run time error is in a non-public function with one parameter (playerid) which is `ResetDuelInfo` function. It also confirms it because it stops the code execution (account check). |
stock ResetDuelInfo(playerid)
{
for(new i = 0; i < 3; i++)
{
DuelInfo[playerid][Weapon][i] = 0;
}
for(new i = 0; i < 4; i++)
{
DuelerID[DuelInfo[playerid][Team][i]] = NONE;
DuelInfo[playerid][Team][i] = NONE;
DuelInfo[playerid][StatusTeam][i] = 0;
}
for(new i = 0; i < 4; i++)
{
DuelerID[DuelInfo[playerid][Enemy][i]] = NONE;
DuelInfo[playerid][Enemy][i] = NONE;
DuelInfo[playerid][StatusEnemy][i] = 0;
}
DuelInfo[playerid][Team][0] = playerid;
DuelInfo[playerid][StatusTeam][0] = 2;
DuelInfo[playerid][Map] = 0;
DuelInfo[playerid][Health] = 100;
DuelInfo[playerid][Armour] = 0;
DuelInfo[playerid][LineUP] = 0;
DuelerID[playerid] = NONE;
DuelTotalEnemy[playerid] = 0;
DuelTotalTeammate[playerid] = 0;
return 1;
}
DuelerID[DuelInfo[playerid][Team][i]] = NONE;
PHP код:
Maybe NONE is 65535? |
[14:58:34] [join] willbedie has joined the server (0:127.0.0.1)
[14:58:34] [debug] Run time error 4: "Array index out of bounds"
[14:58:34] [debug] Accessing element at index 65535 past array upper bound 999
[14:58:34] [debug] AMX backtrace:
[14:58:34] [debug] #0 0004b5e0 in ?? (0x00000000) from deathmatch.amx
[14:58:34] [debug] #1 0006a784 in public WC_OnPlayerConnect (0x00000000) from deathmatch.amx
[14:58:34] [debug] #2 00032dc0 in public _y_utils_OnPlayerConnect (0x00000000) from deathmatch.amx
[14:58:34] [debug] #3 0000e2bc in public IPL_OnPlayerConnect (0x00000000) from deathmatch.amx
[14:58:34] [debug] #4 00007cbc in public SSCANF_OnPlayerConnect (0x00000000) from deathmatch.amx
[14:58:34] [debug] #5 000014f0 in ?? (0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, ... <1073741813 arguments>) from deathmatch.amx
[14:58:34] [debug] #6 0000f504 in public OnPlayerConnect (0x00000000) from deathmatch.amx
DuelerID[DuelInfo[playerid][Team][i]] = NONE;
https://sampwiki.blast.hk/wiki/Limits
MAX_PLAYERS is 1000, PHP код:
Check NONE value |
for(new i = 0; i < 4; i++)
{
if (DuelInfo[playerid][...][i] != NONE)
{
DuelerID[DuelInfo[playerid][...][i]] = NONE;
DuelInfo[playerid][...][i] = NONE;
DuelInfo[playerid][Status...][i] = 0;
}
}
Does it allow up to 4v4 duels? What if it is a 1v1? The last three indexes will be NONE and access invalid index.
pawn Код:
Resetting the duel variables and then their participants variables separated is better because I believe you call `ResetDuelInfo` function for all participants and if it allows 4v4, then it will reset the teams many times instead of only one. |