Problem SyncUp2
#1

[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();
}
Reply
#2

UP!?
Reply
#3

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

Show the code for SyncTime2.
Reply
#5

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

Show IncreaseVehicleHours and any other functions inside of it.
Reply
#7

Код:
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;
		}
	}
}
Reply
#8

MAX_PLAYERS cat il ai definit ?
Reply
#9

Код:
#define MAX_PLAYERS 200
Reply
#10

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 <=
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)