SA-MP Forums Archive
invalid subscript (not an array or too many subscripts) error - 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: invalid subscript (not an array or too many subscripts) error (/showthread.php?tid=388374)



invalid subscript (not an array or too many subscripts) error - Darth1993 - 28.10.2012

Hello, I thought it's possible to do something like that:

Код:
enum map
{
	name[128],
	played,
	likes,
	Float:racer_x[4], Float:racer_y[4], Float:racer_z[4], Float:racer_h[4], // 4 positions for racer
	Float:cop_x[4], Float:cop_y[4], Float:cop_z[4], Float:cop_h[4] // 4 positions for cop
};
new MapI[MAX_MAPS][map];
Код:
				mysql_get_field("position_id", str);
				position_id = strval(str);

				mysql_get_field("x", str);
				MapI[map_id][racer_x[position_id]] = floatstr(str);

				mysql_get_field("y", str);
				MapI[map_id][racer_y[position_id]] = floatstr(str);

				mysql_get_field("z", str);
				MapI[map_id][racer_z[position_id]] = floatstr(str);

				mysql_get_field("heading", str);
				MapI[map_id][racer_h[position_id]] = floatstr(str);
But, I'm getting an error:
Код:
: error 028: invalid subscript (not an array or too many subscripts): "racer_h"
Is there any other way to store x,y,z,heading (4 positions per map) for each map, without making new variables like pos_x_1, pos_x_2 and etc? My array for positions isn't working. :S


Re: invalid subscript (not an array or too many subscripts) error - Emmet_ - 28.10.2012

pawn Код:
mysql_get_field("position_id", str);
position_id = strval(str);

mysql_get_field("x", str);
MapI[map_id][racer_x][position_id] = floatstr(str);

mysql_get_field("y", str);
MapI[map_id][racer_y][position_id] = floatstr(str);

mysql_get_field("z", str);
MapI[map_id][racer_z][position_id] = floatstr(str);

mysql_get_field("heading", str);
MapI[map_id][racer_h][position_id] = floatstr(str);



Re: invalid subscript (not an array or too many subscripts) error - Darth1993 - 28.10.2012

Oh damn, of course!
Thank you.