error 032: array index out of bounds
#1

I cant solve this problem. I am busy making a vehicle system for my gamemode and kinda need this solved ASAP.

Thanks

Enums:
Код:
enum loadedinfo
{
	vehicles = 0,
}
new LoadedInfo[loadedinfo];

enum posInfo
{
    Float: vX,
    Float: vY,
    Float: vZ,
    Float: vR,
}

enum vehicleinfo
{
	vID,
	vOwner[25],
	vModel,
	vPrice,
	Float:Pos[posInfo],
	vColor1,
	vColor2
}
new vInfo[SCRIPT_CARS][vehicleinfo];
Code:
Код:
stock Load_Vehicles()
{
	new Query[512], savestr[50], rows, fields, id;
	mysql_format(dbHandle,Query, sizeof(Query), "SELECT * FROM `Vehicles`");
	mysql_query(dbHandle,Query);
	cache_get_data(rows, fields);
	id = LoadedInfo[vehicles];
	if(rows)
	{
		/*
		cache_get_field_content(0, "ID", savestr);			vInfo[SCRIPT_CARS][vID] = strval(savestr);
		cache_get_field_content(0, "Owner", savestr);		vInfo[SCRIPT_CARS][vOwner] = strval(savestr);
		cache_get_field_content_int(0, "Model", savestr);		vInfo[SCRIPT_CARS][vModel] = strval(savestr);
		cache_get_field_content(0, "PosX", savestr);		vInfo[SCRIPT_CARS][vPosX] = floatstr(savestr);
		cache_get_field_content(0, "PosY", savestr);		vInfo[SCRIPT_CARS][vPosY] = floatstr(savestr);
		cache_get_field_content(0, "PosZ", savestr);		vInfo[SCRIPT_CARS][vPosZ] = floatstr(savestr);
		cache_get_field_content(0, "PosA", savestr);		vInfo[SCRIPT_CARS][vPosA] = floatstr(savestr);
		cache_get_field_content_int(0, "Color1", savestr);		vInfo[SCRIPT_CARS][vColor1] = strval(savestr);
		cache_get_field_content_int(0, "Color2", savestr);		vInfo[SCRIPT_CARS][vColor2] = strval(savestr); */
		
		cache_get_field_content(0, "ID", savestr); vInfo[SCRIPT_CARS][vID] = strval(savestr);
	} 
	AddStaticVehicleEx(vInfo[id][vModel], vInfo[id][Pos][vX], vInfo[id][Pos][vY], vInfo[id][Pos][vZ], vInfo[id][Pos][vR], vInfo[SCRIPT_CARS][vColor1], vInfo[SCRIPT_CARS][vColor2], 10000); 
}
Reply
#2

new vInfo[SCRIPT_CARS][vehicleinfo];
try change this to the following
new vInfo[MAX_VEHICLES][vehicleinfo];
Reply
#3

Nope still nothing . I dont understand why its not working
Reply
#4

#define SCRIPT_CARS ? how many?
Reply
#5

#define SCRIPT_CARS 20000

I put that at the top of the script. but still doesn't do anything...
Reply
#6

pawn Код:
enum loadedinfo
{
    vehicles = 0,
}
new LoadedInfo[loadedinfo];
why is this there
if it has only 1=dimension array after it then why use enum for it
change this thing something is wrong with this
Reply
#7

I used this tutorial...
https://sampforum.blast.hk/showthread.php?tid=186495
If that helps
Reply
#8

The problem is that instead of the index, you used the size of the array:
pawn Код:
// an example:
vInfo[SCRIPT_CARS][vID] = strval(savestr);
Basically, when you declare an array with size N, the valid bounds are between 0 and N-1 so using N as index will give the error 032.

There are also many mistakes on your code.

1) The way you load is incorrect. Using cache_get_data function clearly shows that you use cache functions and thus a version from R7 and higher. The ways to load is either with threaded queries or with non-threaded queries in which case, you did not use one of them. The new method of using non-threaded queries is different and needs to store the resultid etc. for more information check (on ******) "samp mysql r33 wiki".

2) You'll need a loop so you can use the row ID.

3) There are functions in the mysql (cache..int/float) that retrieves the data and returns the value itself so you won't need to store to a temporary string and then strval/floatstr.

4) vOwner is a string and using strval like it's an integer is totally incorrect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)