error 047: array sizes do not match, or destination array is too small
#1

error 047: array sizes do not match, or destination array is too small

it should bu easy but i just dont get it..

thank you..

pawn Код:
CarSystem[i][cVehicleOwner] = dini_Get(string, "VehicleOwner");
Reply
#2

post where you create the array also
Reply
#3

Quote:
Originally Posted by cessil
Посмотреть сообщение
post where you create the array also
pawn Код:
public LoadCarSystem()
{
    new string[128];
    for(new i = 1; i < MAX_DVEHICLES; i++)
    {
        format(string,sizeof(string),"Vehicles/%i.ini",i);
        if(dini_Exists(string))
        {
            CarSystem[i][cModel] = dini_Int(string, "Model");
            CarSystem[i][cX] = dini_Float(string, "X");
            CarSystem[i][cY] = dini_Float(string, "Y");
            CarSystem[i][cZ] = dini_Float(string, "Z");
            CarSystem[i][cAngle] = dini_Float(string, "Angle");
            CarSystem[i][cColor1] = dini_Int(string, "Color1");
            CarSystem[i][cColor2] = dini_Int(string, "Color2");
            CarSystem[i][cDelay] = dini_Int(string, "Delay");
            CarSystem[i][cObjective] = dini_Int(string, "Objective");
            CarSystem[i][cDoorsLocked] = dini_Int(string, "DoorsLocked");
            CarSystem[i][cVehicleOwner] = dini_Get(string, "VehicleOwner");
            CarSystem[i][cVehicleMaterials] = dini_Int(string, "VehicleMaterials");
            CarSystem[i][cVehicleCrack] = dini_Int(string, "VehicleCrack");
            CarSystem[i][cVehiclePot] = dini_Int(string, "VehiclePot");
            CarSystem[i][cLoad] = dini_Int(string, "VehicleLoad");
            CarSystem[i][cCapasity] = dini_Int(string, "VehicleCapasity");
            CarSystem[i][cVehicleHealth] = dini_Float(string, "VehicleHealth");
            CarSystem[i][cVehicleAlarm] = dini_Int(string, "VehicleAlarm");
            CarSystem[i][cVehicleOwned] = dini_Int(string, "VehicleOwned");
            CarSystem[i][cNitro] = dini_Int(string, "Nitro");
            CarSystem[i][cPaintJob] = dini_Int(string, "PaintJob");
            CarSystem[i][cHydro] = dini_Int(string, "Hydro");
            CarSystem[i][cPimped] = dini_Int(string, "Pimped");
            CarSystem[i][cPerma] = dini_Int(string, "Perma");
            CarSystem[i][cRank] = dini_Int(string, "Rank");
            CarSystem[i][cPrice] = dini_Int(string, "Price");
            CarSystem[i][cFileID] = i;
            CarSystem[i][cVehicleID] = AddStaticVehicleEx(CarSystem[i][cModel],CarSystem[i][cX],CarSystem[i][cY],CarSystem[i][cZ],CarSystem[i][cAngle],CarSystem[i][cColor1],CarSystem[i][cColor2], CarSystem[i][cDelay]);
            SetVehicleHealth(CarSystem[i][cVehicleID],CarSystem[i][cVehicleHealth]);
            //ChangeVehicleColor(CarSystem[i][cVehicleID], CarSystem[i][cColor1], CarSystem[i][cColor2]);
            //ChangeVehiclePaintjob(CarSystem[i][cVehicleID], CarSystem[i][cPaintJob]);
            CarCount ++;
            if(CarSystem[i][cPimped] == 1)
            {
                if(CarSystem[i][cModel] == 560)
                {
                    AddVehicleComponent(i, 1026);
                    AddVehicleComponent(i, 1027);
                    AddVehicleComponent(i, 1028);
                    AddVehicleComponent(i, 1026);
                    AddVehicleComponent(i, 1032);
                    AddVehicleComponent(i, 1041);
                }
                if(CarSystem[i][cModel] == 562)
                {
                    AddVehicleComponent(i, 1034);
                    AddVehicleComponent(i, 1036);
                    AddVehicleComponent(i, 1038);
                    AddVehicleComponent(i, 1040);
                }
            }
            if(CarSystem[i][cNitro] == 1)
            {
                AddVehicleComponent(i, 1010);
            }
            if(CarSystem[i][cHydro] == 1)
            {
                AddVehicleComponent(i, 1087);
            }
        }
    }
    return true;
}
Reply
#4

Quote:
Originally Posted by FujiNNN
Посмотреть сообщение
pawn Код:
public LoadCarSystem()
{
    new string[128];
    for(new i = 1; i < MAX_DVEHICLES; i++)
    {
        format(string,sizeof(string),"Vehicles/%i.ini",i);
        if(dini_Exists(string))
        {
            CarSystem[i][cModel] = dini_Int(string, "Model");
            CarSystem[i][cX] = dini_Float(string, "X");
            CarSystem[i][cY] = dini_Float(string, "Y");
            CarSystem[i][cZ] = dini_Float(string, "Z");
            CarSystem[i][cAngle] = dini_Float(string, "Angle");
            CarSystem[i][cColor1] = dini_Int(string, "Color1");
            CarSystem[i][cColor2] = dini_Int(string, "Color2");
            CarSystem[i][cDelay] = dini_Int(string, "Delay");
            CarSystem[i][cObjective] = dini_Int(string, "Objective");
            CarSystem[i][cDoorsLocked] = dini_Int(string, "DoorsLocked");
            CarSystem[i][cVehicleOwner] = dini_Get(string, "VehicleOwner");
            CarSystem[i][cVehicleMaterials] = dini_Int(string, "VehicleMaterials");
            CarSystem[i][cVehicleCrack] = dini_Int(string, "VehicleCrack");
            CarSystem[i][cVehiclePot] = dini_Int(string, "VehiclePot");
            CarSystem[i][cLoad] = dini_Int(string, "VehicleLoad");
            CarSystem[i][cCapasity] = dini_Int(string, "VehicleCapasity");
            CarSystem[i][cVehicleHealth] = dini_Float(string, "VehicleHealth");
            CarSystem[i][cVehicleAlarm] = dini_Int(string, "VehicleAlarm");
            CarSystem[i][cVehicleOwned] = dini_Int(string, "VehicleOwned");
            CarSystem[i][cNitro] = dini_Int(string, "Nitro");
            CarSystem[i][cPaintJob] = dini_Int(string, "PaintJob");
            CarSystem[i][cHydro] = dini_Int(string, "Hydro");
            CarSystem[i][cPimped] = dini_Int(string, "Pimped");
            CarSystem[i][cPerma] = dini_Int(string, "Perma");
            CarSystem[i][cRank] = dini_Int(string, "Rank");
            CarSystem[i][cPrice] = dini_Int(string, "Price");
            CarSystem[i][cFileID] = i;
            CarSystem[i][cVehicleID] = AddStaticVehicleEx(CarSystem[i][cModel],CarSystem[i][cX],CarSystem[i][cY],CarSystem[i][cZ],CarSystem[i][cAngle],CarSystem[i][cColor1],CarSystem[i][cColor2], CarSystem[i][cDelay]);
            SetVehicleHealth(CarSystem[i][cVehicleID],CarSystem[i][cVehicleHealth]);
            //ChangeVehicleColor(CarSystem[i][cVehicleID], CarSystem[i][cColor1], CarSystem[i][cColor2]);
            //ChangeVehiclePaintjob(CarSystem[i][cVehicleID], CarSystem[i][cPaintJob]);
            CarCount ++;
            if(CarSystem[i][cPimped] == 1)
            {
                if(CarSystem[i][cModel] == 560)
                {
                    AddVehicleComponent(i, 1026);
                    AddVehicleComponent(i, 1027);
                    AddVehicleComponent(i, 1028);
                    AddVehicleComponent(i, 1026);
                    AddVehicleComponent(i, 1032);
                    AddVehicleComponent(i, 1041);
                }
                if(CarSystem[i][cModel] == 562)
                {
                    AddVehicleComponent(i, 1034);
                    AddVehicleComponent(i, 1036);
                    AddVehicleComponent(i, 1038);
                    AddVehicleComponent(i, 1040);
                }
            }
            if(CarSystem[i][cNitro] == 1)
            {
                AddVehicleComponent(i, 1010);
            }
            if(CarSystem[i][cHydro] == 1)
            {
                AddVehicleComponent(i, 1087);
            }
        }
    }
    return true;
}
He asked where you create the array, not where you load data into it. Paste the enum part where you declare 'cVehicleOwner'.
Reply
#5

sorry got you wrong..

pawn Код:
enum Cars
{
    cModel,
    Float:cX,
    Float:cY,
    Float:cZ,
    Float:cAngle,
    cColor1,
    cColor2,
    cDelay,
    cObjective,
    cDoorsLocked,
    cVehicleOwner[128],
    cVehicleMaterials,
    cVehicleCrack,
    cVehiclePot,
    cLoad,
    cCapasity,
    Float:cVehicleHealth,
    cVehicleAlarm,
    cVehicleOwned,
    cNitro,
    cPaintJob,
    cHydro,
    cPimped,
    cPerma,
    cRank,
    cPrice,
    cVehicleID,
    cFileID,
};
Reply
#6

dini_Get returns an array with the cell size of 255 cells (by default). Even though the string you're collecting is 24 cells (not 128, you're actually wasting 104 cells (104 * 4 = 416 bytes) as it is).

Try this:
pawn Код:
format(CarSystem[i][cVehicleOwner], MAX_PLAYER_NAME, "%s", dini_Get(string, "VehicleOwner"));
instead of your current dini_Get line, and change

pawn Код:
cVehicleOwner[128],
to

pawn Код:
cVehicleOwner[MAX_PLAYER_NAME],
Reply
#7

Done!, Calgon thank you very much for the explanation i will remember tha't. thank you again and good day.
Reply
#8

True.

Replace
pawn Код:
format(CarSystem[i][cVehicleOwner], MAX_PLAYER_NAME, "%s", dini_Get(string, "VehicleOwner"));
to
pawn Код:
strcat(dini_Get(string, "VehicleOwner"), CarSystem[i][cVehicleOwner], MAX_PLAYER_NAME);
. If you wish to.
Reply
#9

Noted, with the instructions from ****** I think it's pretty clear what to change if you wish to implement the more efficient method.

Just changed all formats which were used to copy strings to strcpy in my script, thanks for the tip anyhow.
Reply
#10

i got the same problem but its these codes

Pawn Code:
(231) : error 047: array sizes do not match, or destination array is too small
(234) : error 047: array sizes do not match, or destination array is too small
tmp = strtok(params, index);
tmp2 = strtok(params, index);
these 2 are 231 and 234 can anybody help
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)