[HELP] "Array Index out of bounds"
#1

Does someone can help me fix it?
When i start samp-server.exe always like this.
The gamemode will keep restarting and i can start my gamemode

Code:
Number of vehicle models: 28
Pickups Max = 100, Current Pickups = 78
[debug] Run time error 4: "Array index out of bounds"
[debug]  Attempted to read/write array element at index 1 in array of size 1
[debug] AMX backtrace:
[debug] #0 00052ad0 in public AddCar (1) from one.amx
[debug] #1 0003f384 in public OnGameModeInit () from one.amx
Reading File: blank
Reading File: properties/houses.txt
Reading File: properties/businesses.txt
Reading File: properties/banks.txt
Reading File: properties/police.txt
Heres the code

Code:
forward AddCar(carcoords);


public OnGameModeInit()
{
for(new i = 0; i < 165; i++)
	{
              AddCar(i);
	}
	      CarInit();
	return 1;
}


public AddCar(carcoords)
{
      new randcol = random(126);
      new randcol2 = 1;
      if (rccounter == 14)
      {
            	rccounter = 0;
      }
      AddStaticVehicleEx(carselect[rccounter], CarSpawns[carcoords][pos_x], CarSpawns[carcoords][pos_y], CarSpawns[carcoords][pos_z], CarSpawns[carcoords][z_angle], randcol, randcol2, 60000);
      rccounter++;
      return 1;
}
And This...


Code:
public OnGameModeInit()
{
    new string[MAX_PLAYER_NAME];
    new string1[MAX_PLAYER_NAME];
	for(new c=0;c<CAR_AMOUNT;c++)
	{
		Gas[c] = GasMax;
	}
	LoadProperty();
	LoadBizz();
	LoadSBizz();
	LoadBoxer();
	LoadStuff();
	LoadIRC();
	LoadFamilies();
	LoadCK();
	LoadTurfs();
	LoadPapers();
	IRCInfo[0][iPlayers] = 0; IRCInfo[1][iPlayers] = 0; IRCInfo[2][iPlayers] = 0;
	IRCInfo[3][iPlayers] = 0; IRCInfo[4][iPlayers] = 0; IRCInfo[5][iPlayers] = 0;
	IRCInfo[6][iPlayers] = 0; IRCInfo[7][iPlayers] = 0; IRCInfo[8][iPlayers] = 0;
	IRCInfo[9][iPlayers] = 0;
	News[hTaken1] = 0; News[hTaken2] = 0; News[hTaken3] = 0; News[hTaken4] = 0; News[hTaken5] = 0;
	format(string, sizeof(string), "Nothing");
	strmid(News[hAdd1], string, 0, strlen(string), 255);
	strmid(News[hAdd2], string, 0, strlen(string), 255);
	strmid(News[hAdd3], string, 0, strlen(string), 255);
	strmid(News[hAdd4], string, 0, strlen(string), 255);
	strmid(News[hAdd5], string, 0, strlen(string), 255);
	format(string1, sizeof(string1), "No-one");
	strmid(News[hContact1], string1, 0, strlen(string1), 255);
	strmid(News[hContact2], string1, 0, strlen(string1), 255);
	strmid(News[hContact3], string1, 0, strlen(string1), 255);
	strmid(News[hContact4], string1, 0, strlen(string1), 255);
	strmid(News[hContact5], string1, 0, strlen(string1), 255);
	PlayerHaul[78][pCapasity] = 100;
	PlayerHaul[79][pCapasity] = 100;
	PlayerHaul[80][pCapasity] = 50;
	PlayerHaul[81][pCapasity] = 50;
	SetGameModeText("Hillside Rp V0.5");
	format(objstore, sizeof(objstore), "MOLE: I got nothing, check back with me later.");
	format(cbjstore, sizeof(cbjstore), "HQ: There is nothing in your Vicinity, Out.");
	format(motd, sizeof(motd), "Welcome to the Role Play - Life in 90's Server.");
	gettime(ghour, gminute, gsecond);
	FixHour(ghour);
	ghour = shifthour;
	if(!realtime)
	{
		SetWorldTime(wtime);
	}
	SetPDistance(10);
	AllowInteriorWeapons(1);
	UsePlayerPedAnims();
	DisableInteriorEnterExits();
	// CreatedCars check
	for(new i = 0; i < sizeof(CreatedCars); i++)
	{
	    CreatedCars[i] = 0;
	}
	// Zones
	for(new i = 0; i < sizeof(TurfInfo); i++)
	{
	    Turfs[i] = GangZoneCreate(TurfInfo[i][zMinX],TurfInfo[i][zMinY],TurfInfo[i][zMaxX],TurfInfo[i][zMaxY]);
	}
	// Player Class's
	for(new i = 0; i <= sizeof(Peds)-1; i++)
	{
		AddPlayerClass(Peds[i][0],1958.3783,1343.1572,1100.3746,269.1425,-1,-1,-1,-1,-1,-1);
	}
	// Car Spawns
    for(new h = 0; h < sizeof(HouseInfo); h++)
	{
		AddStaticVehicleEx(HouseInfo[h][hVec], HouseCarSpawns[h][0], HouseCarSpawns[h][1], HouseCarSpawns[h][2], HouseCarSpawns[h][3], HouseInfo[h][hVcol1], HouseInfo[h][hVcol2], 60000);
		gCarLock[h+1] = 1;
	}//34

.......
.......
Theres so much more
Reply
#2

Hello!

Can you show us your "new" of carselect, please?
Reply
#3

Quote:
Originally Posted by Mencent
View Post
Hello!

Can you show us your "new" of carselect, please?
Here's the code sir..

Code:
new carselect[15];
Code:
public OnGameModeInit()
......
......
new randa = random(sizeof(RandCars));
	randa = random(sizeof(RandCars));carselect[0] = RandCars[randa][0];
	randa = random(sizeof(RandCars));carselect[1] = RandCars[randa][0];
	randa = random(sizeof(RandCars));carselect[2] = RandCars[randa][0];
	randa = random(sizeof(RandCars));carselect[3] = RandCars[randa][0];
	randa = random(sizeof(RandCars));carselect[4] = RandCars[randa][0];
	randa = random(sizeof(RandCars));carselect[5] = RandCars[randa][0];
	randa = random(sizeof(RandCars));carselect[6] = RandCars[randa][0];
	randa = random(sizeof(RandCars));carselect[7] = RandCars[randa][0];
	randa = random(sizeof(RandCars));carselect[8] = RandCars[randa][0];
	randa = random(sizeof(RandCars));carselect[9] = RandCars[randa][0];
	randa = random(sizeof(RandCars));carselect[10] = RandCars[randa][0];
	randa = random(sizeof(RandCars));carselect[11] = RandCars[randa][0];
	randa = random(sizeof(RandCars));carselect[12] = RandCars[randa][0];
	randa = random(sizeof(RandCars));carselect[13] = RandCars[randa][0];
	randa = random(sizeof(RandLCars));carselect[14] = RandLCars[randa][0];
	AddStaticVehicleEx(carselect[14], 1279.4,-1337.0,13.5,1.0,-1, -1, -1);//long
........
........
Reply
#4

Do you have 165 "CarCoords" initialized?
Reply
#5

The problem it's on CarSpawns var. Can u show us how u defined it?
Reply
#6

Quote:
Originally Posted by kingmk
View Post
The problem it's on CarSpawns var. Can u show us how u defined it?
Heres sir

Code:
new CarSpawns[1][eCars] = {
 	{551,1694.7080,-1501.7454,13.1675,357.8150}
    };
Reply
#7

Quote:
Originally Posted by Joe Staff
View Post
Do you have 165 "CarCoords" initialized?
Here's the code

Code:
forward AddCar(carcoords);


public AddCar(carcoords)
{
	new randcol = random(126);
	new randcol2 = 1;
	if (rccounter == 14)
	{
		rccounter = 0;
	}
	AddStaticVehicleEx(carselect[rccounter], CarSpawns[carcoords][pos_x], CarSpawns[carcoords][pos_y], CarSpawns[carcoords][pos_z], CarSpawns[carcoords][z_angle], randcol, randcol2, 60000);
	rccounter++;
	return 1;
}
Reply
#8

Your code is trying to utilize 165 different "CarSpawns" but you've only initialized 1.

Code:
public OnGameModeInit()
{
for(new i = 0; i < sizeof(CarSpawns); i++)
	{
              AddCar(i);
	}
	      CarInit();
	return 1;
}
Replacing your old code with that will prevent you from out reaching the amount of coordinates you've created, but be aware of your vehicle limits when adding future coordinates.
Reply
#9

Quote:
Originally Posted by Joe Staff
View Post
Your code is trying to utilize 165 different "CarSpawns" but you've only initialized 1.

Replacing your old code with that will prevent you from out reaching the amount of coordinates you've created, but be aware of your vehicle limits when adding future coordinates.
It work sir, but my server keep restarting when i try to play.
Do you know what happen?

Here's my server logs :

Code:
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3.DL-R1, ©2005-2018 SA-MP Team

[13:01:10] 
[13:01:10] Server Plugins
[13:01:10] --------------
[13:01:10]  Loading plugin: crashdetect
[13:01:10]   CrashDetect plugin 4.19
[13:01:10]   Loaded.
[13:01:10]  Loading plugin: streamer
[13:01:10] 

*** Streamer Plugin v2.5.2 by Incognito loaded ***

[13:01:10]   Loaded.
[13:01:10]  Loading plugin: sscanf
[13:01:10] 

[13:01:10]  ===============================

[13:01:10]       sscanf plugin loaded.     

[13:01:10]          Version:  2.8.3        

[13:01:10]   © 2018 Alex "Y_Less" Cole  

[13:01:10]  ===============================

[13:01:10]   Loaded.
[13:01:10]  Loading plugin: nativechecker
[13:01:10]   Loaded.
[13:01:10]  Loading plugin: Whirlpool
[13:01:10]  
[13:01:10]  ==================
[13:01:10]  
[13:01:10]   Whirlpool loaded
[13:01:10]  
[13:01:10]  ==================
[13:01:10]  
[13:01:10]   Loaded.
[13:01:10]  Loaded 5 plugins.

[13:01:10] [artwork:crc] lvpdpc2.dff CRC = 0xFBD1EA7C
[13:01:10] [artwork:crc] lvpdpc2.txd CRC = 0xDC92731E
[13:01:10] [artwork:crc] lapdpd2.dff CRC = 0xA558D422
[13:01:10] [artwork:crc] lapdpd2.txd CRC = 0xA442E2DA
[13:01:10] [artwork:crc] wallzzz.dff CRC = 0x4BC6EDFF
[13:01:10] [artwork:crc] wallzzz.txd CRC = 0x235E3EEB
[13:01:10] 
[13:01:10] Filterscripts
[13:01:10] ---------------
[13:01:10]   Loading filterscript 'flymode.amx'...
[13:01:10]   Loading filterscript 'gl_realtime.amx'...
[13:01:10]   Loaded 2 filterscripts.

[13:01:10] Pickups Max = 100, Current Pickups = 78
[13:01:10]  
[13:01:10]  
[13:01:10] -----------------------------
[13:01:10]  Life In 90's Roleplay v1.0
[13:01:10] -----------------------------
[13:01:10]  
[13:01:10]  
[13:01:10] Number of vehicle models: 27
[13:01:23] Pickups Max = 100, Current Pickups = 78
[13:01:23]  
[13:01:23]  
[13:01:23] -----------------------------
[13:01:23]  Life In 90's Roleplay v1.0
[13:01:23] -----------------------------
[13:01:23]  
[13:01:23]  
[13:01:23] Number of vehicle models: 28

And i think the problem is here, but how to fix it?


Code:
[13:01:10] [artwork:crc] lvpdpc2.dff CRC = 0xFBD1EA7C
[13:01:10] [artwork:crc] lvpdpc2.txd CRC = 0xDC92731E
[13:01:10] [artwork:crc] lapdpd2.dff CRC = 0xA558D422
[13:01:10] [artwork:crc] lapdpd2.txd CRC = 0xA442E2DA
[13:01:10] [artwork:crc] wallzzz.dff CRC = 0x4BC6EDFF
[13:01:10] [artwork:crc] wallzzz.txd CRC = 0x235E3EEB
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)