SA-MP Forums Archive
error 006: must be assigned to an array - 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: error 006: must be assigned to an array (/showthread.php?tid=471464)



error 006: must be assigned to an array - sianbg - 23.10.2013

This is my code:
Код:
new buycars[500];
enum cars
{
	modelid,
	carname,
	price
}
new BuyCarsAll[128][cars];

main( ) { }


public OnGameModeInit()
{
    mysql_connect(mysql_host, mysql_user, mysql_database, mysql_password);
	new query[300], savingstring[200], id;
	query = "SELECT * FROM cars";
	mysql_query(query); 
	mysql_store_result();
	while(mysql_fetch_row_format(query,"|"))
	{
		id = id+1;
		mysql_fetch_field_row(savingstring, "modelid");
		BuyCarsAll[id][modelid] = savingstring;
		mysql_fetch_field_row(savingstring, "price");
		BuyCarsAll[id][price] = savingstring;
		mysql_fetch_field_row(savingstring, "carname");
		BuyCarsAll[id][carname] = savingstring;
		format(savingstring, sizeof(savingstring), "%s\n", savingstring);
		strins(buycars, savingstring, strlen(buycars));
	}
	mysql_free_result();
	strdel(buycars, strlen(buycars)-1, strlen(buycars)); 
}
I got this error
Код:
C:\Users\sianbg\Desktop\compiler samp race\pawno\race.pwn(46) : error 006: must be assigned to an array
C:\Users\sianbg\Desktop\compiler samp race\pawno\race.pwn(48) : error 006: must be assigned to an array
C:\Users\sianbg\Desktop\compiler samp race\pawno\race.pwn(50) : error 006: must be assigned to an array
C:\Users\sianbg\Desktop\compiler samp race\pawno\race.pwn(453) : warning 203: symbol is never used: "OnPlayerCommandPerformed"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.



Re: error 006: must be assigned to an array - x96664 - 23.10.2013

Код:
This forum requires that you wait 240 seconds between posts. Please try again in 124 seconds.
Which lines are exactly 46/48/50 ?


Re: error 006: must be assigned to an array - sianbg - 23.10.2013

Quote:
Originally Posted by x96664
Посмотреть сообщение
Код:
This forum requires that you wait 240 seconds between posts. Please try again in 124 seconds.
Which lines are exactly 46/48/50 ?
BuyCarsAll[id][modelid] = savingstring; - 46 line
BuyCarsAll[id][price] = savingstring; - 48 line
BuyCarsAll[id][carname] = savingstring; - 50 line


Re: error 006: must be assigned to an array - Konstantinos - 23.10.2013

Assuming modelid and price should stay integers and only carname should be a string.
pawn Код:
enum cars
{
    modelid,
    carname[32],
    price
}
pawn Код:
mysql_fetch_field_row(savingstring, "modelid");
BuyCarsAll[id][modelid] = strval(savingstring);
mysql_fetch_field_row(savingstring, "price");
BuyCarsAll[id][price] = strval(savingstring);
mysql_fetch_field_row(savingstring, "carname");
strcpy(BuyCarsAll[id][carname], savingstring, 32);
pawn Код:
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
By the way, reduce savingstring. 200 is too much.


Re: error 006: must be assigned to an array - zT KiNgKoNg - 23.10.2013

@Konstantinos - Make sure you're actually commenting what you've fixed and where you fixed it so he will know in the future same with other people, otherwise you're giving out help but not actaully helping.


Re: error 006: must be assigned to an array - sianbg - 23.10.2013

ty @Konstantinos