Must be assigned to an array
#1

First time receiving this error.

Код:
Error 006: Must be assigned to an array
PHP код:
for(new veh=0;veh<15;veh++)
        {
            new 
str1[50],str2[20],str3[20],str4[20],str5[20],str6[20],str7[20];
            
format(str1sizeof(str1), "VehX%d"veh);
            
format(str2sizeof(str1), "VehY%d"veh);
            
format(str3sizeof(str1), "VehZ%d"veh);
            
format(str4sizeof(str1), "VehAngle%d"veh);
            
format(str5sizeof(str1), "VehType%d"veh);
            
format(str6sizeof(str1), "Col1%d"veh);
            
format(str7sizeof(str1), "Col2%d"veh);
            
FacInfo[i][VehX][veh] = str1;
            
FacInfo[i][VehY][veh] = str2;
            
FacInfo[i][VehZ][veh] = str3;
              
FacInfo[i][VehRot][veh] = str4;
            
FacInfo[i][VehType][veh] = str5;
            
FacInfo[i][VehC1][veh] = str6;
            
FacInfo[i][VehC2][veh] = str7;
        } 
Reply
#2

If all those FacInfo's are correctly setup (which I doubt but anyways), you cannot assign strings to char arrays like that in pawn, you need to use format, just like you did for str1-7.

Example:
Код:
format(FacInfo[i][VehX][veh], 50, "VehX%d", veh);
Although why do you want them to store "VehX%d" and not just the %d itself? :'x It doesn't make a lot of sense to me, but whatever.

Lastly, make sure your enum is correctly setup:
Код:
enum something{
	VehX[MAX_VEHICLES][50],
	VehY[MAX_VEHICLES][20],
	...
};
But again, not sure why you want to save down strings, but hey it's up to you!
Reply
#3

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
Lastly, make sure your enum is correctly setup:
Код:
enum something{
	VehX[MAX_VEHICLES][50],
	VehY[MAX_VEHICLES][20],
	...
};
It will show the error
Код:
expected token: "}", but found "["
I guess.

EDIT:

I just want to apply these functions in OnPlayerConnect and reset it to 0 then load it again on OnPlayerSpawn.

PHP код:
for(new veh=0;veh<15;veh++)
            {
                new 
str1[50],str2[20],str3[20],str4[20],str5[20],str6[20],str7[20];
                
format(str1sizeof(str1), "VehX%d"veh);
                
format(str2sizeof(str1), "VehY%d"veh);
                
format(str3sizeof(str1), "VehZ%d"veh);
                
format(str4sizeof(str1), "VehAngle%d"veh);
                
format(str5sizeof(str1), "VehType%d"veh);
                
format(str6sizeof(str1), "Col1%d"veh);
                
format(str7sizeof(str1), "Col2%d"veh);
                
INI_WriteFloat(str1FacInfo[i][VehX][veh]);
                
INI_WriteFloat(str2FacInfo[i][VehY][veh]);
                
INI_WriteFloat(str3FacInfo[i][VehZ][veh]);
                
INI_WriteFloat(str4FacInfo[i][VehRot][veh]);
                
INI_WriteInt(str5FacInfo[i][VehType][veh]);
                
INI_WriteInt(str6FacInfo[i][VehC1][veh]);
                
INI_WriteInt(str7FacInfo[i][VehC2][veh]);
            } 
Reply
#4

Pawn does not support this. But you can use this:
Код:
enum e_smt
{
     veh_x[50],
     veh_y[50],
     ...
}
new smt[MAX_VEHICLES][e_smt];
Reply
#5

I'm using this filterscript btw. I guess it will give more information.
Reply
#6

Nevermind. Fixed it. Forgot that I wasn't loading the data rather I was resetting the data.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)