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

Код:
Error: [19:19:48] [debug] Run time error 4: "Array index out of bounds"
[19:19:48] [debug]  Attempted to read/write array element at index 51 in array of size 50
[19:19:48] [debug] AMX backtrace:
[19:19:48] [debug] #0 000314f4 in public MinigameUpdate () in RLS.amx
[19:19:50] [debug] Run time error 4: "Array index out of bounds"
[19:19:50] [debug]  Attempted to read/write array element at index 51 in array of size 50
[19:19:50] [debug] AMX backtrace:
[19:19:50] [debug] #0 0003248c in public MinigameWinner (51) in RLS.amx
[19:19:50] [debug] #1 00031800 in public MinigameUpdate () in RLS.amx
Код:
public MinigameUpdate( )
{
	if(Iter_Count(FallOutMg) < 1) return EndMinigame( );

	new str[128], Float:playerx, Float:playery, Float:playerz[MAX_PLAYERS];
	foreach(FallOutMg, i)
	{
		GetPlayerPos(i, playerx, playery, playerz[i]);
		if(playerz[i] < 2.0) //Checks if player is in the water
		{
			format(str, sizeof(str), "%s {33FFFF}has dropped out of FallOut Minigame, Rank {FF0000}%d", PlayerName(i), Iter_Count(FallOutMg));
			SendClientMessageToAll(0xFF0000C8, str);
			//--------------------------------------
			GameTextForPlayer(i, pFellOffText[random(sizeof(pFellOffText))], 2500, 3);
			Iter_Remove(FallOutMg, i);
			PlayerInfo[i][ActionID] = 0;
			Minigamer_{i} = false;
			RespawnPlayer(i);
		}
	}
	if(Iter_Count(FallOutMg) < 2)
	{
 		foreach(FallOutMg, i) MinigameWinner(i);
	}
 	new objectid, Float:ObjectX, Float:ObjectY, Float:ObjectZ;
	//--------------------------------------------------------------------------
    if(!VIEW_FROM_ABOVE)
    {
	 	foreach(_FallOutObjects, i)
		{
			if(IsOdd(random(10) ) )
			{
		 	    GetObjectPos(Objects_[0][i], ObjectX, ObjectY, ObjectZ);
				MoveObject(Objects_[0][i], ObjectX, ObjectY, ObjectZ -1.5, 0.2);
	   			MoveObject(Objects_[1][i], ObjectX, ObjectY, ObjectZ -1.5, 0.2);
			}
			else
			{
				GetObjectPos(Objects_[0][i], ObjectX, ObjectY, ObjectZ);
				MoveObject(Objects_[0][i], ObjectX, ObjectY, ObjectZ +1.5, 0.2);
				MoveObject(Objects_[1][i], ObjectX, ObjectY, ObjectZ +1.5, 0.2);
			}
		}
	}
 	objectid = Iter_Random(_FallOutObjects);
	GetObjectPos(Objects_[0][objectid], ObjectX, ObjectY, ObjectZ);
	SetTimerEx("SpeedUp", 500, 0, "ifff", objectid, ObjectX, ObjectY, ObjectZ);
	MoveObject(Objects_[0][objectid], ObjectX, ObjectY, ObjectZ -5, 1);
	if(!VIEW_FROM_ABOVE)
	MoveObject(Objects_[1][objectid], ObjectX, ObjectY, ObjectZ -5, 1);
    Iter_Remove(_FallOutObjects, objectid);
	return 1;
}
Код:
public MinigameWinner(player)
{
	new str[128];
	//-----------
	format(str, sizeof(str), "%s {33FFFF}has won Fallout Minigame!", PlayerName(player));
	SendClientMessageToAll(0xFF0000C8, str);
	//--------------------------------------
	switch(PlayerInfo[player][Language])
    {
		case 0: SendClientMessage(player, -1, "You are won the Fallout ! {FF0000}Reward 100 score , 50.000$ and 50 Coins .");
		case 1: SendClientMessage(player, -1, "{0080FF}Ai castigat minigame-ul {FF8040}Fallout {0080FF}! {FF0000}Premiu 100 score , 5.000$ si 50 Coins .");
	}
	SetPlayerScore(player, GetPlayerScore(player) + 100);
 	GivePlayerCash(player, 5000);
 	PlayerInfo[player][Coins] += 50;
	//------------------------------
 	Minigamer_{player} = false;
	Iter_Remove(FallOutMg, player);
	PlayerInfo[player][ActionID] = 0;
	SetTimerEx("RespawnPlayer", 1400, 0, "i", player);
	SetTimer("EndMinigame", 1700, 0);
}
And:
Код:
new bool:Minigamer_[MAX_PLAYERS char];
Reply
#2

Yeah and, how is anyone supposed to have any idea from that?
Reply
#3

en: this is your error, Attempted to read/write array element at index 51 in array of size 50.
ro: ai depasit dimensiunea unui vector, foloseste alt compiler poate iti ofera mai multe informatii
Reply
#4

These two public functions have something in common:
pawn Код:
PlayerInfo[i][ActionID] = 0;
Minigamer_{i} = false;
// and
PlayerInfo[player][ActionID] = 0;
Minigamer_{player} = false;
`MinigameWinner` passed 51 as player parameter while the size of the faulty array is 50. Check how you declared `PlayerInfo` and `Minigamer_` arrays. If you want to know the line caused it, compile with -d3 flag.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)