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

I noticed i got these things in server_log.txt few minutes ago. Anyone know's where the problem? Everything seems to work fine.

Код:
[17:59:13] [debug] Run time error 4: "Array index out of bounds"
[17:59:14] [debug]  Accessing element at index 142 past array upper bound 99
[17:59:14] [debug] AMX backtrace:
[17:59:14] [debug] #0 00052f70 in public OtherTimer () from godlikerpg.amx
Thanks in advance!
Reply
#2

Show us OtherTimer callback.

There's an array of size 100 and you pass 142 instead.
Reply
#3

Is the problem here?

Код:
public OtherTimer()
{
	//print("otherTimer1");
    //new Float:maxspeed = 175.0;
    //new plname[MAX_PLAYER_NAME];
	new string[256];
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    //print("otherTimer2");
	    if(IsPlayerConnected(i))
	    {
	        //CheckWeapons(i);
	        //print("otherTimer3");
            if(SafeTime[i] > 0)
			{
				SafeTime[i]--;
			}
			if(SafeTime[i] == 1)
			{
				if(gPlayerAccount[i] == 1 && gPlayerLogged[i] == 0)
				{
					SendClientMessage(i, COLOR_WHITE, "{DC0C0C}GodLike: {FFFFFF}Te poti loga tastand parola in chenar.");
				}
			}
			if(!IsPlayerInAnyVehicle(i) && PlayerInfo[i][pRadar] == 1) PlayerInfo[i][pRadar] = 0;
			if(PayTimer[i] > 0) PayTimer[i] --;
			if(SexTimer[i] > 0) SexTimer[i] --;
			if(WantedLevel[i] > 0) SetPlayerWantedLevel(i, WantedLevel[i]);
			if(WantedLevel[i] != GetPlayerWantedLevel(i)) SetPlayerWantedLevel(i, WantedLevel[i]);
			if(PlayerHQ[i] != 0 && GetPlayerInterior(i) == 0) PlayerHQ[i] = 0;
			//if(TimerShowing[i] >= 1) TimerShowing[i] --;
   			new newcar = GetPlayerVehicleID(i);
   			//print("otherTimer4");
			if(GetVehicleTrailer(newcar) == 331 || GetVehicleTrailer(newcar) == 328 || GetVehicleTrailer(newcar) == 338 || GetVehicleTrailer(newcar) == 333 || GetVehicleTrailer(newcar) == 337 || GetVehicleTrailer(newcar) == 346 || GetVehicleTrailer(newcar) == 347 || GetVehicleTrailer(newcar) == 345 || GetVehicleTrailer(newcar) == 339 || GetVehicleTrailer(newcar) == 344)
			{
			    if(StartedTransporting[i] == 0 && GetPlayerState(i) == PLAYER_STATE_DRIVER)
			    {
			        if(PlayerInfo[i][pJob] == 23 || PlayerInfo[i][pJob1] == 23) {} else return 1;
					SendClientMessage(i, COLOR_LIGHTBLUE, "{DC0C0C}Sofer de Tir: {FFFFFF}Du-te la checkpoint pentru a livra bunurile.");
					new rand = random(sizeof(gRandomTransporterCP));
					SetPlayerCheckpoint(i, gRandomTransporterCP[rand][0], gRandomTransporterCP[rand][1], gRandomTransporterCP[rand][2], 6.0);
					CP[i] = 357;
					StartedTransporting[i] = rand;
			    }
			}
			//print("otherTimer5");
			if(!PlayerToPoint(100.0, i, 3296.0210,-1971.2427,4.8088) && PlayerInfo[i][pJailed] == 1 && WantedLevel[i] != 7 && GetPlayerVirtualWorld(i) != 1)
			{
			    new sendernamej[MAX_PLAYER_NAME];
			    GetPlayerName(i, sendernamej, sizeof(sendernamej));
			    if(EvadeTimer[i] > 10) { EvadeTimer[i] = 0; } else return EvadeTimer[i]++;
			    //UndercoveredW[i] = 0;
			    PlayerInfo[i][pJailed] = 0;
			    Update(i, pJailedx);
				//WantedLevel[i] = 7;
				SetPlayerWantedLevel(i, 7);
				SendClientMessage(i, COLOR_WHITE, "{DC0C0C}Evadare: {FFFFFF}Ai evadat, iar politia este pe urmele tale acum!");
				//SetPlayerCriminal(i,255, "Evadarea de la locul Inchisorii");
				PlayerInfo[i][pJailTime] = 0;
				Update(i, pJailTimex);
				for(new n = 0; n < MAX_PLAYERS; n++)
    			{
       				if(IsPlayerConnected(n))
           			{
              			if(PlayerInfo[n][pMember] == 1||PlayerInfo[n][pLeader] == 1||PlayerInfo[n][pMember] == 2||PlayerInfo[n][pLeader] == 2||PlayerInfo[n][pMember] == 3||PlayerInfo[n][pLeader] == 3)
                 		{
                        	//format(string, sizeof(string), ,sendernamej);
                         	SendClientMessage(n, TEAM_BLUE_COLOR, "Evadare: Un criminal a evadat din inchisoare!");
                     	}
                   	}
              	}
			}
Reply
#4

Check your OtherTimer code (arrays).

I cant help your w/o OtherTimer code.

EDIT: Sorry lags, anyway remove comments from debug print and see where stops
Reply
#5

You need to debug your code, from a fast look I did not see anything strange.

By the way, those arrays you have created are you really sure that they have the size of "MAX_PLAYERS"? Because if you did for example:

pawn Код:
// MAX_PLAYERS = 100
new Something[ MAX_PLAYERS ][ Something_enum ];
new Something2[ 80 ][ Something2_enum ];

// Somewhere:
for(new i = 0; i < MAX_PLAYERS; i++ )
{
    Something[ i ][ blabla ] = 0;
    Something2[ i ][ blablabla ] = 1; // When "i" will be 80: "Array index out of bounds"
}
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
You can narrow down the problem line with -d3.
What are you talking about?
Reply
#7

Quote:
Originally Posted by toofast
Посмотреть сообщение
What are you talking about?
http://forum.sa-mp.com/showpost.php?...32&postcount=7

Quote:

You can also get more information like line numbers, function names, parameter values, etc if compile that script in debug mode to make compiler put extra information about all that stuff into the output .amx

But it does not always show the line it was caused.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)