Array index out of bounds -- HELP PLS
#1

hi! so, i typed some codes on player death , but some of them will not work ! and i get this lines on samp-server.exe
:
Code:
[13:00:43] [debug] Run time error 4: "Array index out of bounds"
[13:00:43] [debug]  Attempted to read/write array element at index 99 in array of size 16
[13:00:43] [debug] AMX backtrace:
[13:00:43] [debug] #0 000df064 in public FailRob (0, 1) in BlankScript.amx
[13:00:43] [debug] #1 000df330 in public AB_OnPlayerDeath (0, 65535, 255) in BlankScript.amx
[13:00:43] [debug] #2 00035f24 in public OnPlayerDeathWeapons (0, 65535, 255) in BlankScript.amx
[13:00:43] [debug] #3 000319f0 in public ac_OnPlayerDeath (0, 65535, 255) in BlankScript.amx
[13:00:43] [debug] #4 0000d348 in public OnPlayerDeath (0, 65535, 255) in BlankScript.amx
here is onplayerdeath code :

Code:
new Robber[MAX_PLAYERS];
new BankRobber[MAX_PLAYERS];
	public OnPlayerDeath(playerid, killerid, reason)
	{
	    if(Robber[playerid] != 0)
	    {
			Robber[playerid] = 0;
			
		 	if(BankRobber[playerid] == 1)
		    {
		        BankRobber[playerid] = 0;
			FailRob(playerid,1);
		    }
	    }
         return 1;
       }
and the FailRob Public:
Code:
forward FailRob(playerid,robid);

public FailRob(playerid,robid)
{
	if(robid == 1)
	{
		        SendClientMessageToAll(-1,"Test String"); // worked!
				DestroyDynamicCP(RobCps[playerid]); // not worked!
				//
				HideTimer(playerid); // not worked (this stock should hide some textdraws)
	}
    return 1;
}
i tried to use failrob public codes in onplayerdeath to but not worked again and show same errors help me please!
Reply
#2

Code:
new RobCps[MAX_PLAYERS];
and this is the code on starting robbery , set the player checkpoint:
Code:
		new rand = random(sizeof(robberycheckpoints));
		RobCps[playerid] = CreateDynamicCP(robberycheckpoints[rand][0],robberycheckpoints[rand][1],robberycheckpoints[rand][2],robberycheckpoints[rand][3], -1, -1, playerid, -1);
and this :
Code:
new Float: robberycheckpoints[3][4] =
{
	{-751.9777,-131.2435,65.8281, 3.0 }, // 1
	{-548.4982,-181.6734,78.4063, 3.0 }, // 2
	{-520.1964,-544.4396,25.5234, 3.0 }, // 3
};
Reply
#3

Did you post everything from `FailRob` function because it is incomplete. The function is called with playerid=0 and robid=1 and the only array in your current code is `RobCps`. The index is 0, not 99 that crashdetect reported.
Reply
#4

Full code:
Code:
public FailRob(playerid,robid)
{
	if(robid == 1)
	{
				new Float:X, Float:Y, Float:Z , string[300];
				GetPlayerPos(playerid,X,Y,Z);
				mbag = CreateObject(1550, X, Y, Z);
		        mbtxtdraw = Create3DTextLabel("Money Bag",COLOR_CYAN,X,Y,Z-0.8010, 15.0, 0, 0); 
				//
		        SendClientMessageToAll(-1,"Test String");
				//
				DestroyDynamicCP(RobCps[playerid]);
				//
				HideTimer(playerid);
	}
    return 1;
}
Reply
#5

Quote:

public FailRob(playerid,robid)
{
if(robid == 1)
{
SendClientMessageToAll(-1,"Test String"); // worked!
DestroyDynamicCP(RobCps[playerid]); // not worked!
//
HideTimer(playerid); // not worked (this stock should hide some textdraws)
}
return 1;
}

lol why you place like this?
try use it
Quote:

public FailRob(playerid,robid)
{
if(robid == 1)
{
SendClientMessageToAll(-1,"Test String"); // worked!
DestroyDynamicCP(RobCps[playerid]); // not worked!
//
HideTimer(playerid); // not worked (this stock should hide some textdraws)
}
return 1;
}

Reply
#6

cant see any diffrence
Reply
#7

Quote:
Originally Posted by PoniStar
View Post
um, i cant send the full code here , i will send it as a private mssge to you and y_less!
We only need the code in `FailRob` function, not the whole script. If it is that long, upload to pastebin but do not limit the help to just two users.
Reply
#8

Quote:
Originally Posted by Calisthenics
View Post
We only need the code in `FailRob` function, not the whole script. If it is that long, upload to pastebin but do not limit the help to just two users.
i edited my post :
Code:
public FailRob(playerid,robid)
{
	if(robid == 1)
	{
				new Float:X, Float:Y, Float:Z , string[300];
				GetPlayerPos(playerid,X,Y,Z);
				mbag = CreateObject(1550, X, Y, Z);
		        mbtxtdraw = Create3DTextLabel("Money Bag",COLOR_CYAN,X,Y,Z-0.8010, 15.0, 0, 0);
				//
		        SendClientMessageToAll(-1,"Test String");
				//
				DestroyDynamicCP(RobCps[playerid]);
				//
				HideTimer(playerid);
	}
    return 1;
}
Reply
#9

Quote:
Originally Posted by PoniStar
View Post
i edited my post :
Code:
public FailRob(playerid,robid)
{
	if(robid == 1)
	{
				new Float:X, Float:Y, Float:Z , string[300];
				GetPlayerPos(playerid,X,Y,Z);
				mbag = CreateObject(1550, X, Y, Z);
		        mbtxtdraw = Create3DTextLabel("Money Bag",COLOR_CYAN,X,Y,Z-0.8010, 15.0, 0, 0);
				//
		        SendClientMessageToAll(-1,"Test String");
				//
				DestroyDynamicCP(RobCps[playerid]);
				//
				HideTimer(playerid);
	}
    return 1;
}
The above code cannot give run time error 4. By hiding the code, you hide the mistake.
Reply
#10

-_- found the problem thnx for your help guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)