Error Help = +REP
#1

I get:
Quote:

:45:36] [debug] Run time error 4: "Array index out of bounds"
[16:45:36] [debug] Accessing element at index 15 past array upper bound 14
[16:45:36] [debug] AMX backtrace:
[16:45:36] [debug] #0 000d99ec in ?? () from Badlands.amx
[16:45:36] [debug] #1 00107ca4 in public PZone_OnGameModeInit () from Badlands.amx
[16:45:36] [debug] #2 native CallLocalFunction () [00472ad0] from samp-server.exe
[16:45:36] [debug] #3 00015dd4 in public SSCANF_OnGameModeInit () from Badlands.amx
[16:45:36] [debug] #4 native CallLocalFunction () [00472ad0] from samp-server.exe
[16:45:36] [debug] #5 0000ff9c in public zcmd_OnGameModeInit () from Badlands.amx
[16:45:36] [debug] #6 native CallLocalFunction () [00472ad0] from samp-server.exe
[16:45:36] [debug] #7 0000f8fc in ?? () from Badlands.amx
[16:45:36] [debug] #8 000090ac in public Itter_OnGameModeInit () from Badlands.amx
[16:45:36] [debug] #9 native CallLocalFunction () [00472ad0] from samp-server.exe
[16:45:36] [debug] #10 000026d4 in ?? () from Badlands.amx
[16:45:36] [debug] #11 000015a4 in public OnGameModeInit () from Badlands.amx
[16:45:36]

For:

NOTE:When I remove 'LoadcDealerships();' the server runs fine?

Код:
LoadcDealerships();
under OnGameModeInit();

Код:
LoadcDealerships()
{
    new string2[64];
	format(string2, sizeof(string2), "cardealerships.ini");
	new File: DealerFile = fopen(string2, io_read);
	if ( DealerFile )
	{
		new key[ 256 ] , val[ 256 ];
		new Data[ 256 ];
		while ( fread( DealerFile , Data , sizeof( Data ) ) )
		{
		    new string[128];
		    for(new f = 0; f < MAX_FAMILY; f++)
    		{
				key = ini_GetKey( Data );
				format(string, 128, "cd%dOwned",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdOwned] = strval( val ); }
				format(string, 128, "cd%dOwner",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); strmid(CarDealershipInfo[f][cdOwner], val, 0, strlen(val)-1, 255); }
				format(string, 128, "cd%dEntranceX",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdEntranceX] = floatstr( val ); }
				format(string, 128, "cd%dEntranceY",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdEntranceY] = floatstr( val ); }
				format(string, 128, "cd%dEntranceZ",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdEntranceZ] = floatstr( val ); }
				format(string, 128, "cd%dExitX",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdExitX] = floatstr( val ); }
				format(string, 128, "cd%dExitY",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdExitY] = floatstr( val ); }
				format(string, 128, "cd%dExitZ",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdExitZ] = floatstr( val ); }
				format(string, 128, "cd%dMessage",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); strmid(CarDealershipInfo[f][cdMessage], val, 0, strlen(val)-1, 255); }
				format(string, 128, "cd%dTill",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdTill] = strval( val ); }
				format(string, 128, "cd%dInterior",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdInterior] = strval( val ); }
				format(string, 128, "cd%dVehicleSpawn0",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawn][0] = floatstr( val ); }
				format(string, 128, "cd%dVehicleSpawn1",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawn][1] = floatstr( val ); }
				format(string, 128, "cd%dVehicleSpawn2",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawn][2] = floatstr( val ); }
				format(string, 128, "cd%dVehicleSpawn3",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawn][3] = floatstr( val ); }
				format(string, 128, "cd%dRadius",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdRadius] = floatstr( val ); }
				format(string, 128, "cd%dPrice",f);
				if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdPrice] = strval( val ); }

				for(new fv = 0; fv < MAX_DEALERSHIPVEHICLES; fv++)
    			{
    			    format(string, 128, "cd%dVeh%dModelId",f, fv);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleModel][fv] = strval( val ); }
					format(string, 128, "cd%dVeh%dCost",f, fv);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleCost][fv] = strval( val ); }
					format(string, 128, "cd%dVeh%dSpawnX",f, fv);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawnX][fv] = floatstr( val ); }
					format(string, 128, "cd%dVeh%dSpawnY",f, fv);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawnY][fv] = floatstr( val ); }
					format(string, 128, "cd%dVeh%dSpawnZ",f, fv);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawnZ][fv] = floatstr( val ); }
					format(string, 128, "cd%dVeh%dSpawnA",f, fv);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawnAngle][fv] = floatstr( val ); }
    			}
			}
		}
		fclose(DealerFile);
	}
	return 1;
}
Enum:

Код:
enum cdInfo
{
	cdOwned,
	cdOwner[MAX_PLAYER_NAME],
	Float: cdEntranceX,
	Float: cdEntranceY,
	Float: cdEntranceZ,
	Float: cdExitX,
	Float: cdExitY,
	Float: cdExitZ,
	cdMessage[128],
	cdTill,
	cdInterior,
	Float: cdRadius,
	cdPrice,
	cdPickupID,
	Text3D:cdTextLabel,
	Text3D:cdVehicleLabel[MAX_DEALERSHIPVEHICLES],
	cdVehicleModel[MAX_DEALERSHIPVEHICLES],
	cdVehicleCost[MAX_DEALERSHIPVEHICLES],
	cdVehicleId[MAX_DEALERSHIPVEHICLES],
	Float: cdVehicleSpawnX[MAX_DEALERSHIPVEHICLES],
	Float: cdVehicleSpawnY[MAX_DEALERSHIPVEHICLES],
	Float: cdVehicleSpawnZ[MAX_DEALERSHIPVEHICLES],
	Float: cdVehicleSpawnAngle[MAX_DEALERSHIPVEHICLES],
	Float: cdVehicleSpawn[4],
};
new CarDealershipInfo[MAX_CARDEALERSHIPS][cdInfo];
Reply
#2

You're missing the .json file. Do you have the scriptfile cardealerships.json? If not, that is your problem right there.
Reply
#3

redefine MAX_FAMILY to 16
Reply
#4

I have it there.
Reply
#5

Thanks @Mirou, it worked.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)