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=592927)



error 006: must be assigned to an array - razorkick - 31.10.2015

Hi,
im new to pawn and working on a new tuning system. I try this to get the saved stuff from the .ini's:
PHP код:
    for(new 0MAX_VEHICLESi++)
    {
         new 
str[30];
         
format(strsizeof(str), "/tunedVehicles/%d.car"i);
        if(
dini_Exists(str))
        {
        
tuningParts[i][tuning_0] = dini_Get(str"tuning_0");
        
tuningParts[i][tuning_0_X] = dini_Get(str"tuning_0_X");
        
tuningParts[i][tuning_0_Y] = dini_Get(str"tuning_0_Y");
        
tuningParts[i][tuning_0_Z] = dini_Get(str"tuning_0_Z");
        
tuningParts[i][tuning_0_RX] = dini_Get(str"tuning_0_RX");
        
tuningParts[i][tuning_0_RY] = dini_Get(str"tuning_0_RY");
        
tuningParts[i][tuning_0_RZ] = dini_Get(str"tuning_0_RZ");
        
tuningParts[i][tuning_1] = dini_Get(str"tuning_1");
        
tuningParts[i][tuning_1_X] = dini_Get(str"tuning_1_X");
        
tuningParts[i][tuning_1_Y] = dini_Get(str"tuning_1_Y");
        
tuningParts[i][tuning_1_Z] = dini_Get(str"tuning_1_Z");
        
tuningParts[i][tuning_1_RX] = dini_Get(str"tuning_1_RX");
        
tuningParts[i][tuning_1_RY] = dini_Get(str"tuning_1_RY");
        
tuningParts[i][tuning_1_RZ] = dini_Get(str"tuning_1_RZ");
        
tuningParts[i][tuning_2] = dini_Get(str"tuning_2");
        
tuningParts[i][tuning_2_X] = dini_Get(str"tuning_2_X");
        
tuningParts[i][tuning_2_Y] = dini_Get(str"tuning_2_Y");
        
tuningParts[i][tuning_2_Z] = dini_Get(str"tuning_2_Z");
        
tuningParts[i][tuning_2_RX] = dini_Get(str"tuning_2_RX");
        
tuningParts[i][tuning_2_RY] = dini_Get(str"tuning_2_RY");
        
tuningParts[i][tuning_2_RZ] = dini_Get(str"tuning_2_RZ");
        
tuningParts[i][tuning_3] = dini_Get(str"tuning_3");
        
tuningParts[i][tuning_3_X] = dini_Get(str"tuning_3_X");
        
tuningParts[i][tuning_3_Y] = dini_Get(str"tuning_3_Y");
        
tuningParts[i][tuning_3_Z] = dini_Get(str"tuning_3_Z");
        
tuningParts[i][tuning_3_RX] = dini_Get(str"tuning_3_RX");
        
tuningParts[i][tuning_3_RY] = dini_Get(str"tuning_3_RY");
        
tuningParts[i][tuning_3_RZ] = dini_Get(str"tuning_3_RZ");
        
tuningParts[i][tuning_4] = dini_Get(str"tuning_4");
        
tuningParts[i][tuning_4_X] = dini_Get(str"tuning_4_X");
        
tuningParts[i][tuning_4_Y] = dini_Get(str"tuning_4_Y");
        
tuningParts[i][tuning_4_Z] = dini_Get(str"tuning_4_Z");
        
tuningParts[i][tuning_4_RX] = dini_Get(str"tuning_4_RX");
        
tuningParts[i][tuning_4_RY] = dini_Get(str"tuning_4_RY");
        
tuningParts[i][tuning_4_RZ] = dini_Get(str"tuning_4_RZ");
        }
    }
    print(
"Tuning-vehicles succesfully loaded"); 
but it says me for every of this lines "must be assigned to an array", i dont understand it why cant it put the things into the enum?

Here is the enum if needed:
PHP код:
enum tuning
{
    
tuning_0,
    
tuning_0_X,
    
tuning_0_Y,
    
tuning_0_Z,
    
tuning_0_RX,
    
tuning_0_RY,
    
tuning_0_RZ,
    
tuning_1,
    
tuning_1_X,
    
tuning_1_Y,
    
tuning_1_Z,
    
tuning_1_RX,
    
tuning_1_RY,
    
tuning_1_RZ,
    
tuning_2,
    
tuning_2_X,
    
tuning_2_Y,
    
tuning_2_Z,
    
tuning_2_RX,
    
tuning_2_RY,
    
tuning_2_RZ,
    
tuning_3,
    
tuning_3_X,
    
tuning_3_Y,
    
tuning_3_Z,
    
tuning_3_RX,
    
tuning_3_RY,
    
tuning_3_RZ,
    
tuning_4,
    
tuning_4_X,
    
tuning_4_Y,
    
tuning_4_Z,
    
tuning_4_RX,
    
tuning_4_RY,
    
tuning_4_RZ,
}
new 
tuningParts[MAX_VEHICLES][tuning]; 
I hope you can help me
Thanks


Re: error 006: must be assigned to an array - jlalt - 31.10.2015

I'm not sure but try to replace
new str[30];
With
new str[256];


Re: error 006: must be assigned to an array - razorkick - 31.10.2015

Didnt worked but thanks


AW: error 006: must be assigned to an array - Nero_3D - 31.10.2015

Well you used dini_Get which returns a string but I guess you wanted to use dini_Int and dini_Float instead (next to them is also dini_bool if you ever need it)

Just replace dini_Get with the correct function
PHP код:
        tuningParts[i][tuning_0] = dini_Int(str"tuning_0"); // I guess that should be an integer
        
tuningParts[i][tuning_0_X] = dini_Float(str"tuning_0_X"); // and these should be floats
        
tuningParts[i][tuning_0_Y] = dini_Float(str"tuning_0_Y");
        
tuningParts[i][tuning_0_Z] = dini_Float(str"tuning_0_Z"); 
Also add a Float: tag in front of your float variables
PHP код:
enum tuning
{
    
tuning_0,
    
Floattuning_0_X,
    
Floattuning_0_Y,
    
Floattuning_0_Z,
    
Floattuning_0_RX,
    
Floattuning_0_RY,
    
Floattuning_0_RZ,
    
tuning_1,
    
Floattuning_1_X,
    
Floattuning_1_Y



Re: error 006: must be assigned to an array - PrO.GameR - 31.10.2015

Your problem was answered in posts above

but I got a serious question, you do know you can add another dimension to your array right ?

enum tuning
{
tuningid,
Float:tuning_X,
Float:tuning_Y,
Float:tuning_Z,
Float:tuning_RX,
Float:tuning_RY,
Float:tuning_RZ,
}
tuningParts[MAX_VEHICLES][5][tuning];

^^ this just makes life 100 times easier and code 100 lines less


Re: error 006: must be assigned to an array - razorkick - 01.11.2015

Okay thanks to both of you the error codes are away but there are new ones:
array index out of bounds (variable "tuningParts")

This come for each line into the enum:
enum tuning
{
tuningid,
Float:tuning_X,
Float:tuning_Y,
Float:tuning_Z,
Float:tuning_RX,
Float:tuning_RY,
Float:tuning_RZ,
}
new tuningParts[MAX_VEHICLES][5][tuning];


Re: error 006: must be assigned to an array - PrO.GameR - 01.11.2015

how are you using it ?
to call each one you should start from 0 to size-1( which is 5-1 in this case)
I.E: tuningParts[102][0][tuningid] - tuningParts[102][4][tuningid] ( I suspect you are using it as [5] when recalling it.)


Re: error 006: must be assigned to an array - razorkick - 01.11.2015

-_- now it works perfectly

Thank you all so much