Any help to fix this issue please?
#1

Hi. I have been working on a vehicle system that will save vehicles bought at a dealership on OnGameModeExit and then load those saved vehicles up on OnGameModeInit.

I had this problem months ago but just got back into scripting so im a bit rusty xD

I almost have it but I've been up so long; not sure whether the issue is just as easy as renaming a word or just moving one word out of there or something xD

Could any1 take a quick look at this?

Im getting the "error 047: array sizes do not match, or destination array is too small" error.

Im 100% sure it's to do with "carData[vehicle][owner]" in the LoadVehicle stock. Marked with "//THIS".
I marked the full error line with "/*ERROR LINE*/"

Thanks to anyone that helps

CreateVehicleEx stock.
pawn Код:
stock CreateVehicleEx(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawntime, ownername[MAX_PLAYER_NAME])
{
    new carid = GetFreeVehicleSlot();
    carData[carid][model] = modelid;
    carData[carid][xspawn] = x;
    carData[carid][yspawn] = y;
    carData[carid][zspawn] = z;
    carData[carid][anglespawn] = angle;
    carData[carid][col1] = color1;
    carData[carid][col2] = color2;
    carData[carid][respawn] = respawntime;
    carData[carid][owner] = ownername;
    validcar[carid] = true;
    CreateVehicle(modelid, x, y, z, angle, color1, color2, respawntime);
    return carid;
}
The other needed stocks/publics.
pawn Код:
stock LoadVehicle(vehicle, filename[])
{
    INI_ParseFile(filename, "LoadVehicleData", .bExtra = true, .extra = vehicle);
    /*ERROR LINE*/CreateVehicleEx(carData[vehicle][model], carData[vehicle][xspawn], carData[vehicle][yspawn], carData[vehicle][zspawn], carData[vehicle][anglespawn], carData[vehicle][col1], carData[vehicle][col2], carData[vehicle][respawn], carData[vehicle][owner]);//THIS
}



forward public LoadVehicleData(vehicle, name[], value[]);
public LoadVehicleData(vehicle, name[], value[])
{
    INI_Int("Model", carData[vehicle][model]);
    INI_Float("xLast", carData[vehicle][xspawn]);
    INI_Float("yLast", carData[vehicle][yspawn]);
    INI_Float("zLast", carData[vehicle][zspawn]);
    INI_Float("aLast", carData[vehicle][anglespawn]);
    INI_Int("Color1", carData[vehicle][col1]);
    INI_Int("Color2", carData[vehicle][col2]);
    INI_Int("Respawn", carData[vehicle][respawn]);
    INI_String("Owner", carData[vehicle][owner], MAX_PLAYER_NAME);
   
    return 1;
}

stock LoadAllVehicles()
{
    //new fname[36];
    new loadindex = 0;
    //format(fname, sizeof(fname), "/vehicles/%d.ini", loadindex);
    while(fexist(VehiclePath(loadindex)))  //Here's the reason why the ini files are named continuosly
    {
        LoadVehicle(loadindex, VehiclePath(loadindex));
        loadindex++;
        //format(fname, sizeof(fname), "/vehicles/%d.ini", index);
    }
    printf("Vehicles Loaded: %d", loadindex);
}
Reply
#2

I believe you have an enum to store the cardata variables. There should be probably an owner without a size. Try to find the:
pawn Код:
enum data // or similar
{
     // Stuff...
     owner,     // Should be: owner[MAX_PLAYER_NAME],
     // Other stuff...
};
new carData[MAX_VEHICLES][data];
Reply
#3

Hi Dragon

That was the first thing I checked but i have the owner's string size as MAX_PLAYER_NAME already

pawn Код:
enum carDataEnum
{        
    model,
    Float:xspawn,
    Float:yspawn,
    Float:zspawn,
    Float:anglespawn,
    col1,
    col2,
    respawn,
    owner[MAX_PLAYER_NAME]
}  
new carData[MAX_VEHICLES][carDataEnum];
Any other idea?
Reply
#4

What's the line which gives you the error? When I tried to compile your code, it actually compiled it without warnings/errors.

pawn Код:
#include < a_samp >
#include < YSI\y_ini >

enum carDataEnum
{
    model,
    Float:xspawn,
    Float:yspawn,
    Float:zspawn,
    Float:anglespawn,
    col1,
    col2,
    respawn,
    owner[MAX_PLAYER_NAME]
}
new carData[MAX_VEHICLES][carDataEnum];



forward public LoadVehicleData(vehicle, name[], value[]);
public LoadVehicleData(vehicle, name[], value[])
{
    INI_Int("Model", carData[vehicle][model]);
    INI_Float("xLast", carData[vehicle][xspawn]);
    INI_Float("yLast", carData[vehicle][yspawn]);
    INI_Float("zLast", carData[vehicle][zspawn]);
    INI_Float("aLast", carData[vehicle][anglespawn]);
    INI_Int("Color1", carData[vehicle][col1]);
    INI_Int("Color2", carData[vehicle][col2]);
    INI_Int("Respawn", carData[vehicle][respawn]);
    INI_String("Owner", carData[vehicle][owner], MAX_PLAYER_NAME);

    return 1;
}

stock LoadAllVehicles()
{
    //new fname[36];
    new loadindex = 0;
    //format(fname, sizeof(fname), "/vehicles/%d.ini", loadindex);
    while(fexist(VehiclePath(loadindex)))  //Here's the reason why the ini files are named continuosly
    {
        LoadVehicle(loadindex, VehiclePath(loadindex));
        loadindex++;
        //format(fname, sizeof(fname), "/vehicles/%d.ini", index);
    }
    printf("Vehicles Loaded: %d", loadindex);
}

stock CreateVehicleEx(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawntime, ownername[MAX_PLAYER_NAME])
{
    new carid = GetFreeVehicleSlot();
    carData[carid][model] = modelid;
    carData[carid][xspawn] = x;
    carData[carid][yspawn] = y;
    carData[carid][zspawn] = z;
    carData[carid][anglespawn] = angle;
    carData[carid][col1] = color1;
    carData[carid][col2] = color2;
    carData[carid][respawn] = respawntime;
    carData[carid][owner] = ownername;
    validcar[carid] = true;
    CreateVehicle(modelid, x, y, z, angle, color1, color2, respawntime);
    return carid;
}
The only thing I'm not sure about is CreateVehicleEx function. You set the size of the array and then you assign about the owner's name. I'd use strcpy, YSI contains it already.

pawn Код:
stock CreateVehicleEx(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawntime, ownername[])
{
    new carid = GetFreeVehicleSlot();
    carData[carid][model] = modelid;
    carData[carid][xspawn] = x;
    carData[carid][yspawn] = y;
    carData[carid][zspawn] = z;
    carData[carid][anglespawn] = angle;
    carData[carid][col1] = color1;
    carData[carid][col2] = color2;
    carData[carid][respawn] = respawntime;
    strcpy(carData[carid][owner], ownername, MAX_PLAYER_NAME);
    validcar[carid] = true;
    CreateVehicle(modelid, x, y, z, angle, color1, color2, respawntime);
    return carid;
}
Reply
#5

Hi Konstantinos

The error line is in the LoadVehicle stock Marked with 'ERROR LINE' at the start of the CreateVehicleEx function.

pawn Код:
stock LoadVehicle(vehicle, filename[])
{
    INI_ParseFile(filename, "LoadVehicleData", .bExtra = true, .extra = vehicle);
    /*ERROR LINE*/CreateVehicleEx(carData[vehicle][model], carData[vehicle][xspawn], carData[vehicle][yspawn], carData[vehicle][zspawn], carData[vehicle][anglespawn], carData[vehicle][col1], carData[vehicle][col2], carData[vehicle][respawn], carData[vehicle][owner]);//THIS
}
Thanks for "strcpy" too It didn't fix this particular problem but i will be using it in the future

Any ideas?
Reply
#6

It still compiles fine.
pawn Код:
#include < a_samp >
#include < YSI\y_ini >

enum carDataEnum
{
    model,
    Float:xspawn,
    Float:yspawn,
    Float:zspawn,
    Float:anglespawn,
    col1,
    col2,
    respawn,
    owner[MAX_PLAYER_NAME]
}
new carData[MAX_VEHICLES][carDataEnum];

forward LoadVehicleData(vehicle, name[], value[]);
public LoadVehicleData(vehicle, name[], value[])
{
    INI_Int("Model", carData[vehicle][model]);
    INI_Float("xLast", carData[vehicle][xspawn]);
    INI_Float("yLast", carData[vehicle][yspawn]);
    INI_Float("zLast", carData[vehicle][zspawn]);
    INI_Float("aLast", carData[vehicle][anglespawn]);
    INI_Int("Color1", carData[vehicle][col1]);
    INI_Int("Color2", carData[vehicle][col2]);
    INI_Int("Respawn", carData[vehicle][respawn]);
    INI_String("Owner", carData[vehicle][owner], MAX_PLAYER_NAME);

    return 1;
}

stock LoadAllVehicles()
{
    //new fname[36];
    new loadindex = 0;
    //format(fname, sizeof(fname), "/vehicles/%d.ini", loadindex);
    while(fexist(VehiclePath(loadindex)))  //Here's the reason why the ini files are named continuosly
    {
        LoadVehicle(loadindex, VehiclePath(loadindex));
        loadindex++;
        //format(fname, sizeof(fname), "/vehicles/%d.ini", index);
    }
    printf("Vehicles Loaded: %d", loadindex);
}

stock CreateVehicleEx(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawntime, ownername[])
{
    new carid = GetFreeVehicleSlot();
    carData[carid][model] = modelid;
    carData[carid][xspawn] = x;
    carData[carid][yspawn] = y;
    carData[carid][zspawn] = z;
    carData[carid][anglespawn] = angle;
    carData[carid][col1] = color1;
    carData[carid][col2] = color2;
    carData[carid][respawn] = respawntime;
    strcpy(carData[carid][owner], ownername, MAX_PLAYER_NAME);
    validcar[carid] = true;
    CreateVehicle(modelid, x, y, z, angle, color1, color2, respawntime);
    return carid;
}

stock LoadVehicle(vehicle, filename[])
{
    INI_ParseFile(filename, "LoadVehicleData", .bExtra = true, .extra = vehicle);
    CreateVehicleEx(carData[vehicle][model], carData[vehicle][xspawn], carData[vehicle][yspawn], carData[vehicle][zspawn], carData[vehicle][anglespawn], carData[vehicle][col1], carData[vehicle][col2], carData[vehicle][respawn], carData[vehicle][owner]);
}
Reply
#7

Really? Wtf.. xD

Would an outdated include cause this? If there are any newly updated Y_INI includes that is :P

EDIT: Ahh! Damnit lol. I never realised that you removed the string size for 'owner' in the CreateVehicleEx stock XD

Thanks alot man

No idea how much times i changed that to everything but empty lol.. xD
Reply
#8

Download the latest version to make sure it's the correct. In the console shows "YSI version 3.09.0684" to me. Also make sure, you replaced the CreateVehicleEx function and it's
pawn Код:
ownername[]
without a size.
Reply
#9

Thanks literally just edited my previous post lol

(Will +Rep when i can, cant for some reason today even though i've only +repped 1 person xD)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)