SA-MP Forums Archive
Problem SyncUp2 - 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: Problem SyncUp2 (/showthread.php?tid=586395)



Problem SyncUp2 - Mititel - 21.08.2015

[00:14:44] [debug] Run time error 4: "Array index out of bounds"
[00:14:44] [debug] Accessing element at index 200 past array upper bound 199
[00:14:44] [debug] AMX backtrace:
[00:14:44] [debug] #0 0038bea4 in ?? () from vitalcs.amx
[00:14:44] [debug] #1 0011170c in ?? () from vitalcs.amx
[00:14:44] [debug] #2 001114f4 in public SyncUp2 () from vitalcs.amx

Code:

Код:
public SyncUp2()
{
	SyncTime2();
}



Re: Problem SyncUp2 - Mititel - 22.08.2015

UP!?


Re: Problem SyncUp2 - Mititel - 24.08.2015

Quote:
Originally Posted by Mititel
Посмотреть сообщение
UP!?
Nobody?


Re: Problem SyncUp2 - Abagail - 24.08.2015

Show the code for SyncTime2.


Re: Problem SyncUp2 - Mititel - 25.08.2015

Код:
public SyncTime2()
{
	IncreaseVehicleHours();
}



Re: Problem SyncUp2 - Abagail - 25.08.2015

Show IncreaseVehicleHours and any other functions inside of it.


Re: Problem SyncUp2 - Mititel - 25.08.2015

Код:
stock IncreaseVehicleHours()
{
    for(new id = 0; id <= MAX_PLAYERS; id++)
	{
		VehicleInfo[id][minutes] += 1;
		VehicleInfo2[id][minutes] += 1;
		MotoInfo[id][minutes] += 1;
		PlaneInfo[id][minutes] += 1;
		if(VehicleInfo[id][minutes] >= 60)
		{
		    VehicleInfo[id][hours] += 1;
		    VehicleInfo[id][minutes] = 0;
		}
		if(VehicleInfo2[id][minutes] >= 60)
		{
		    VehicleInfo2[id][hours] += 1;
		    VehicleInfo2[id][minutes] = 0;
		}
		if(MotoInfo[id][minutes] >= 60)
		{
		    MotoInfo[id][hours] += 1;
		    MotoInfo[id][minutes] = 0;
		}
  		if(PlaneInfo[id][minutes] >= 60)
		{
		    PlaneInfo[id][hours] += 1;
		    PlaneInfo[id][minutes] = 0;
		}
	}
}



Re: Problem SyncUp2 - jamal1992 - 25.08.2015

MAX_PLAYERS cat il ai definit ?


Re: Problem SyncUp2 - Mititel - 25.08.2015

Код:
#define MAX_PLAYERS 200



Re: Problem SyncUp2 - prineside - 25.08.2015

If VehicleInfo size is MAX_PLAYERS, it has indexes from 0 to 199.
In your function there's a 'for' loop from 0 to 200 (as of <= condition). You should use < instead of <=