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



invalid subscript (not an array or too many subscripts): - Erno. - 22.07.2016

LoadSEnter() return mysql_tquery(g_iHandle, "SELECT * FROM `senters`", "OnSEnterLoad", "");

forward OnSEnterLoad();
public OnSEnterLoad()
{
for (new i, j = cache_get_row_count(); i != j; i++) // loops through the rows
{
sEnterID[i] = cache_get_row_int(i, 0);
sEnter_x[i] = cache_get_row_float(i, 1);
sEnter_y[i] = cache_get_row_float(i, 2);
sEnter_z[i] = cache_get_row_float(i, 3);
sExit_x[i] = cache_get_row_float(i, 4);
sExit_y[i] = cache_get_row_float(i, 5);
sExit_z[i] = cache_get_row_float(i, 6);
Int[i] = cache_get_row_int(i, 7);
Int2[i] = cache_get_row_int(i, ;
Wirt[i] = cache_get_row_int(i, 9);
Wirt2[i] = cache_get_row_int(i, 10);
Name[i] = cache_get_row_int(i, 11);
UpdateSEnterText( i );
Itter_Add(sEnters,i);
}
}


Error line - sEnterID[i] = cache_get_row_int(i, 0);

error 028: invalid subscript (not an array or too many subscripts): "sEnterID"
warning 215: expression has no effect
expected token: ";", but found "]"
error 029: invalid expression, assumed zero


Re: invalid subscript (not an array or too many subscripts): - evan69 - 22.07.2016

Show me the part where you declared the array "sEnterID". Probably it seems you haven't declared the array properly.

You need to declare array using this syntax:
Код:
new array_name[SIZE];



Re: invalid subscript (not an array or too many subscripts): - Erno. - 22.07.2016

Quote:
Originally Posted by evan69
Посмотреть сообщение
Show me the part where you declared the array "sEnterID". Probably it seems you haven't declared the array properly.

You need to declare array using this syntax:
Код:
new array_name[SIZE];
enum senters
{
sEnterID,
FloatEnter_x,
FloatEnter_y,
FloatEnter_z,
FloatExit_x,
FloatExit_Y,
FloatExit_z,
Int,
Int2,
Wirt,
Wirt2,
Name[126]
}

#define MAX_SENTERS 100

new sEnter[ MAX_SENTERS ][ senters ];


Re: invalid subscript (not an array or too many subscripts): - Stinged - 22.07.2016

All of them need to be:
Код:
sEnter[i][sEnterID] = ...;
sEnter[i][Enter_x] = ...;
// ...



Re: invalid subscript (not an array or too many subscripts): - Flake. - 22.07.2016

PHP код:
sEnter[i][sEnterID] = cache_get_row_int(i0); 
Apply that to the rest of the rows you're trying to retrieve.

Edit: Stinged beat me to it : (


Re: invalid subscript (not an array or too many subscripts): - Erno. - 22.07.2016

Thanks guys.