"Index Out of bouds", but i don't see line errors
#1

Hello, i've got a problem with a simple RP script than i dowloaded to begin:

It launched the debug, and say some things when i connect:

Код:
[14:34:29] [debug] Run time error 4: "Array index out of bounds"
[14:34:29] [debug]  Accessing element at index 4 past array upper bound 3
[14:34:29] [debug] AMX backtrace:
[14:34:29] [debug] #0 000229fc in ?? (0) from igrp.amx
[14:34:29] [debug] #1 00012104 in public inc_Ven_OnPlayerConnect (0) from igrp.amx
[14:34:29] [debug] #2 0000bfa8 in public SSCANF_OnPlayerConnect (0) from igrp.amx
[14:34:29] [debug] #3 0000509c in public Iter_OnPlayerConnect (0) from igrp.amx
[14:34:29] [debug] #4 native CallLocalFunction () from samp-server.exe
[14:34:29] [debug] #5 00002f18 in public f3_KBROnPlayerConnect (0) from igrp.amx
[14:34:29] [debug] #6 000023fc in public AB_OnPlayerConnect (0) from igrp.amx
[14:34:29] [debug] #7 00000684 in public OnPlayerConnect (0) from igrp.amx
And at #0... It don't tell me which callback is called

So can someone help me ? (Download from here: https://mega.nz/#!ndcUQJZC!Zmt6A1lFU...ARhAY_0ai-Aij8)
Reply
#2

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

Do what the link guides you and re-compile. Start the server and connect, if you get the logs from crashdetect again, post them here. It'll be more detailed (will contain the exact line and normal (not public or native) functions will be displayed instead of ??
Reply
#3

Ok... I did this and now i have this:

Код:
[15:02:33] [debug] Run time error 4: "Array index out of bounds"
[15:02:33] [debug]  Accessing element at index 4 past array upper bound 3
[15:02:33] [debug] AMX backtrace:
[15:02:33] [debug] #0 0002bb18 in ResetPlayerVariables (playerid=0) at C:\Users\Protocole\Documents\samp\gamemodes\igrp.pwn:2038
[15:02:33] [debug] #1 0001690c in public inc_Ven_OnPlayerConnect (playerid=0) at C:\Users\Protocole\Documents\samp\gamemodes\igrp.pwn:501
[15:02:33] [debug] #2 0000e7bc in public SSCANF_OnPlayerConnect (playerid=0) at C:\Users\Protocole\Documents\samp\pawno\include\vending.inc:537
[15:02:33] [debug] #3 000066d0 in public Iter_OnPlayerConnect (playerid=0) at C:\Users\Protocole\Documents\samp\pawno\include\sscanf2.inc:236
[15:02:33] [debug] #4 native CallLocalFunction () from samp-server.exe
[15:02:33] [debug] #5 00003c7c in public f3_KBROnPlayerConnect (playerid=0) at C:\Users\Protocole\Documents\samp\pawno\include\foreach.inc:601
[15:02:33] [debug] #6 00002dec in public AB_OnPlayerConnect (playerid=0) at C:\Users\Protocole\Documents\samp\pawno\include\DelayKickBan.inc:139
[15:02:33] [debug] #7 00000804 in public OnPlayerConnect (playerid=0) at C:\Users\Protocole\Documents\samp\pawno\include\antiairbreak.inc:80
And resetPlayerVariable is this:

Код:
ResetPlayerVariables(playerid)
{
	pData[playerid][pID] = 0;
	format(pData[playerid][pName], 1, "");
	pData[playerid][pLevel] = 0;
	format(pData[playerid][pPass], 1, "");
	format(pData[playerid][pRegisterIP], 1, "");
	pData[playerid][pAdmin] = 0;
	pData[playerid][pMoney] = 0;
	pData[playerid][pHoursPlayed] = 0;
	pData[playerid][pSkin] = 0;
	pData[playerid][pGender] = 0;
	pData[playerid][pInterior] = 0;
	pData[playerid][pVirtualWorld] = 0;
	pData[playerid][pMask] = 0;
	pData[playerid][pVIP] = 0;
	pData[playerid][pRadioChannel] = 0;
	pData[playerid][pRadio] = 0;
	pData[playerid][pHelper] = 0;
	pData[playerid][pHospital] = 0;
	pData[playerid][pHospitalLevel] = 0;
	pData[playerid][pPhNumber] = 0;
	pData[playerid][pPhCase] = 0;
	pData[playerid][pHasBankCard] = 0;
	pData[playerid][pBankMoney] = 0;
	pData[playerid][pBanned] = 0;
	pData[playerid][pBanAppealable] = 0;
	format(pData[playerid][pBanReason], 1, "");
	pData[playerid][pBannedBy] = 0;
	format(pData[playerid][pBanDate], 1, "");
	pData[playerid][pWarnings] = 0;
	pData[playerid][pMuted] = 0;
	pData[playerid][pFrozen] = 0;
	pData[playerid][pTutorialFinished] = 0;
	pData[playerid][pPassport] = 0;
	pData[playerid][pDriversLicense] = 0;
	pData[playerid][pFlyingLicense] = 0;
	pData[playerid][pTaxiLicense] = 0;
	pData[playerid][pWeaponLicense] = 0;
	pData[playerid][pBoatLicense] = 0;
	format(pData[playerid][pRegisterDate], 1, "");
	format(pData[playerid][pLastLoginDate], 1, "");
	pData[playerid][pUpgradesLeft] = 0;
	pData[playerid][pStrengthUpgrade] = 0;
	pData[playerid][pHealthUpgrade] = 0;
	pData[playerid][pWalkStyle] = 0;
	pData[playerid][pChatStyle] = 0;
	pData[playerid][pFaction] = 0;
	pData[playerid][pFactionRank] = 0;
	pData[playerid][pFactionSkin] = 0;
	pData[playerid][pUsingFactionSkin] = 0;
	pData[playerid][pCanManageFaction] = 0;
	pData[playerid][pBadge] = 0;
	pData[playerid][pWearsBadge] = 0;
	pData[playerid][pPosX] = 0;
	pData[playerid][pPosY] = 0;
	pData[playerid][pPosZ] = 0;
	pData[playerid][pPosA] = 0;

	tutorialSkinSelected[playerid] = 0;
    moneytimer[playerid] = -1;


	if(TutorialActor[playerid][0] != INVALID_ACTOR_ID)
	{
		DestroyActor(TutorialActor[playerid][0]);
		TutorialActor[playerid][0] = INVALID_ACTOR_ID;
	}
	if(TutorialActor[playerid][1] != INVALID_ACTOR_ID)
	{
		DestroyActor(TutorialActor[playerid][1]);
		TutorialActor[playerid][1] = INVALID_ACTOR_ID;
	}
	if(TutorialActor[playerid][2] != INVALID_ACTOR_ID)
	{
		DestroyActor(TutorialActor[playerid][2]);
		TutorialActor[playerid][2] = INVALID_ACTOR_ID;
	}
    
    paccsavetimr[playerid] = -1;
    
	gPlayerFirstSpawn[playerid] = 0;
	gPlayerLogged[playerid] = 0;
	gPlayerUsingLoopingAnim[playerid] = 0;
	tutcityhallcp[playerid] = -1;
	mayexitbinco[playerid] = 0;
	displayingText[playerid] = 0;
	hideCenterHUDTimerID[playerid] = -1;
	tutorialtimer[playerid] = -1;
	MaskID[playerid] = 0;
	for(new i = 0; i < 5; i++)
	{
		heditinside[playerid][i] = 0;
		heditoutside[playerid][i] = 0;
	}
    heditingoutside[playerid] = 0;
    heditinginside[playerid] = 0;
	hprice[playerid] = 0;
	hMaxFurn[playerid] = 0;
	houtsideinterior[playerid] = 0;
	houtsidevirtualworld[playerid] = 0;
	hinsideinterior[playerid] = 0;
	
	for(new i = 0; i < 10; i++)
	{
		TutorialCP[playerid][i] = -1;
	}
}
Reply
#4

Which line is 2038? I see two main suspects

pawn Код:
for(new i = 0; i < 5; i++)
{
    heditinside[playerid][i] = 0;
    heditoutside[playerid][i] = 0;
}
//and  
for(new i = 0; i < 10; i++)
{
    TutorialCP[playerid][i] = -1;
}
Using "magic numbers" (your 5 and 10 respectively) is major cause of such problems. Use sizeof or constant for those.
Reply
#5

Line 2038 I'll assume is one with the loops. The best way to avoid such errors (specifically in loops and arrays) is to use sizeof operator.

This
pawn Код:
for (new i = 0; i < 5; i++)
{
    heditinside[playerid][i] = 0;
    heditoutside[playerid][i] = 0;
}
becomes:
pawn Код:
for (new i = 0; i < sizeof heditinside[]; i++)
{
    heditinside[playerid][i] = 0;
    heditoutside[playerid][i] = 0;
}
and this:
pawn Код:
for (new i = 0; i < 10; i++)
{
    TutorialCP[playerid][i] = -1;
}
becomes:
pawn Код:
for (new i = 0; i < sizeof TutorialCP[]; i++)
{
    TutorialCP[playerid][i] = -1;
}
When using "sizeof array_name[]" gets the size of the second dimension while without square brackets gets the first.
Reply
#6

Ok, thank you guys! For your help! +1 REp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)