SA-MP Forums Archive
What's wrong here? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What's wrong here? (/showthread.php?tid=650759)



What's wrong here? - IdonTmiss - 06.03.2018

Код:
	if(hittedplaya[issuerid] >= 4)
	{
		if(PoliceDuty[playerid] == 1)
		{
			if(PI[issuerid][pWanted] < 1)
			{	
				PI[issuerid][pWanted] += 4;		
				DidACrime(issuerid, 255, "Attack on federal agents");
				lz_SetPlayerWantedLevel(issuerid, PI[issuerid][pWanted]);
				SaveAccount(issuerid);
			}	
		}
		else
		{	
			if(PI[issuerid][pWanted] < 1)
			{	
				PI[issuerid][pWanted] += 4;		
				DidACrime(issuerid, 255, "Attacking People");
				lz_SetPlayerWantedLevel(issuerid, PI[issuerid][pWanted]);
				SaveAccount(issuerid);
			}	
		}				
	}
and i get this error
Код:
[02:57:10] [debug] Run time error 4: "Array index out of bounds"
[02:57:10] [debug]  Accessing element at index 65535 past array upper bound 499
[02:57:10] [debug] AMX backtrace:
[02:57:10] [debug] #0 00790c88 in ?? (0, 65535, 1084122727, 54, 3) from RPG.amx
[02:57:10] [debug] #1 0000dc94 in public OnPlayerTakeDamage (0, 65535, 1084122727, 54, 3) from RPG.amx



Re: What's wrong here? - Sew_Sumi - 06.03.2018

Means you aren't checking if the INVALID_PLAYER_ID is the issuer, and making code to cope with that out of bounds error.


Re: What's wrong here? - X337 - 06.03.2018

Check if issuerid is not INVALID_PLAYER_ID before processing it

Edit: sew_sumi was faster


Re: What's wrong here? - IdonTmiss - 06.03.2018

thanks both of you