Raised This Month: $ Target: $400
 0% 

Must be assigned to an array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Aae
Junior Member
Join Date: Jun 2016
Old 01-02-2017 , 10:00   Must be assigned to an array
Reply With Quote #1

Hi,

I'm trying to store a line in a file in a 2d array but I am getting the error 006: must be assigned to an array.

This is the error code: MapLocations[currentMap][locCount] = line;

and the array is defined like this: new MapLocations[32][256];

Would you happen to know why I am getting this error? currentMap and locCount are both integers.

I just figured out that you can only store numbers in a 2d array, however, how can I store the line string?

Thanks!
Aae is offline
Timocop
AlliedModders Donor
Join Date: Mar 2013
Location: Germany
Old 01-02-2017 , 10:53   Re: Must be assigned to an array
Reply With Quote #2

"line" is a string right? So its an char array and you need to make the variable a 3d array with the max. lenght for the string you want to store.
Also, you need to use the "String:" tag because you're storing a string to the variable.

PHP Code:
new String:MapLocations[32][64][256];
new 
String:MapLocations[/* Map Range */][/* Log Count */][/* String Lenght */];

Format(MapLocations[0][0], sizeof(MapLocations[][]), "Jesus was here!"); 

Last edited by Timocop; 01-02-2017 at 10:54.
Timocop is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 01-02-2017 , 11:33   Re: Must be assigned to an array
Reply With Quote #3

OFFTOP

Last edited by ZASTRELIS; 01-02-2017 at 13:19.
ZASTRELIS is offline
Timocop
AlliedModders Donor
Join Date: Mar 2013
Location: Germany
Old 01-02-2017 , 12:06   Re: Must be assigned to an array
Reply With Quote #4

wut
Timocop is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode