Run time error 4: "Array index out of bounds"
#1

error
It Gives Me This In Server Log


Code:
[18:36:30] [debug] Run time error 4: "Array index out of bounds"
[18:36:30] [debug]  Attempted to read/write array element at index 65535 in array of size 1000
[18:36:30] [debug] AMX backtrace:
[18:36:30] [debug] #0 00101798 in public OnPlayerDeath (playerid=0, killerid=65535, reason=54) at D:\RPG V3 EDITED\gamemodes\gtarg.pwn:13966
[18:36:30] [debug] #1 000f947c in public OnPlayerTakeDamage (playerid=0, issuerid=65535, Float:amount=3.30000, weaponid=54, bodypart=3) at D:\RPG V3 EDITED\gamemodes\gtarg.pwn:13357
Code hightlight line 13357

Code:
				if(PlayerInfo[killerid][pPaintKills] == 190)
				{
				    PlayerInfo[killerid][pPaintRank] = 14;
					Update(killerid, pPaintRankx);
					PlayerInfo[killerid][pCash] += 700000;
					Update(killerid, pCashx);
					GivePlayerCash(killerid, 500000);
					PlayerInfo[killerid][pExp] += 10;
					Update(killerid, pRP);
					PlayerInfo[playerid][pPremiumPoints] += 7;
					Update(playerid, pPremiumPointsx);
				    SCM(playerid, COLOR_GREEN, "Xep hang tang! Ban bay gio la Distinguished Master Guardian.");
				    SCM(playerid, COLOR_GREEN, "Ban nhan duoc $700.000, 10 RP va 7 PP(vip xu)");
        			format(rankz, sizeof(rankz), "Distinguished Master Guardian");
        			PlayerInfo[killerid][pRankName] = rankz;
				    Update(killerid, pRankNamex);
				}
Reply
#2

the killerid and issuerid should be checked that they dont equal to invalid playerid
Reply
#3

Quote:

#0 00101798 in public OnPlayerDeath (playerid=0, killerid=65535, reason=54)
#1 000f947c in public OnPlayerTakeDamage (playerid=0, issuerid=65535, Float:amount=3.30000, weaponid=54, bodypart=3)

Quote:

the killerid and issuerid should be checked that they dont equal to invalid playerid

one that is correct

Two. Your killerid and playerid is reaching 65535.

playerid's only reach 1000.

so either there is something wrong with your code or you are using mysql with 6000+ registered players/accounts.

correct your loops on that coz you are not giving the right playerid's on issuerid and killerid's
Reply
#4

Quote:
Originally Posted by JesterlJoker
View Post
one that is correct

Two. Your killerid and playerid is reaching 65535.

playerid's only reach 1000.

so either there is something wrong with your code or you are using mysql with 6000+ registered players/accounts.

correct your loops on that coz you are not giving the right playerid's on issuerid and killerid's
INVALID_PLAYER_ID = 65535
That's why you need to check if the issuerid is correct.
Reply
#5

What the others meant was, on the Line number:> 13966 inside gtrg.pwn, you are trying to access an Array Slot (65535) which exceed the mentioned array size..
If a player dies due to his carelessness / fault(Suicide), the killerid in OnPlayerDeath(playerid, killerid, reason), will be INVALID_PLAYER_ID(65535)..
For instance when you have a script to increase the kill count of a player, you must do
PHP Code:
public OnPlayerDeath(playeridkilleridreason)
{
    if(
killerid != INVALID_PLAYER_ID) { //This will make sure there is no array out of bound due to INVALID_PLAYER_ID
        
Player_Stats[killerid]++;
    }
    
Player_Stats[playerid]++;

Rep+ goes to the above guys who helped. I just rephrased their words.
Reply
#6

That "Rep+" isn't even valid lol.

https://sampwiki.blast.hk/wiki/OnPlayerDeath Provides a great example.
Reply
#7

Quote:
Originally Posted by ISmokezU
View Post
That "Rep+" isn't even valid lol.

https://sampwiki.blast.hk/wiki/OnPlayerDeath Provides a great example.
my bad.

Don't follow what I said.

I guess I need to read more and more.

rep doesn't even work properly
Reply
#8

Thank all . That really great
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)