SA-MP Forums Archive
Private Owned Vehicle Clones [ Need Help ASAP] - 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: Private Owned Vehicle Clones [ Need Help ASAP] (/showthread.php?tid=382306)



Private Owned Vehicle Clones [ Need Help ASAP] - Richard Steinheimer - 02.10.2012

Alright, So as you can see. My private owned vehicle saving / loading system is messed up. I have no clue where. But everytime i load the vehicles they clone ontop of each other. And its a fair ammount. Can you please help me??

pawn Код:
stock LoadVehicles()
{
    new file[100];
    new tmp[256];
    new var[18];

    new model;
    new Float:x;
    new Float:y;
    new Float:z;
    new Float:a;
    new vehicleid;
    for (new i = 1; i < MAX_VEHICLES; i += 1)
    {
        format(file, sizeof(file), "DealerInfo/cars/%d.cdat", i);
        if (dini_Exists(file))
        {
            model = dini_Int(file, "veh_model");
            x = dini_Float(file, "veh_x");
            y = dini_Float(file, "veh_y");
            z = dini_Float(file, "veh_z");
            a = dini_Float(file, "veh_rot");
            vehicleid = AddStaticVehicleEx(model, x, y, z, a, 1, 1, -1);

            tmp = dini_Get(file, "veh_plate");
            format(VehicleEnum[vehicleid][veh_plate], MAX_PLATE_LENGTH + 1, tmp);
           
            tmp = dini_Get(file, "veh_owner");
            format(VehicleEnum[vehicleid][veh_owner], MAX_PLAYER_NAME, tmp);
           
            VehicleEnum[vehicleid][veh_model] = dini_Int(file, "veh_model");
            VehicleEnum[vehicleid][veh_owned] = dini_Int(file, "veh_owned");
            VehicleEnum[vehicleid][veh_price] = dini_Int(file, "veh_price");
            VehicleEnum[vehicleid][veh_x] = dini_Float(file, "veh_x");
            VehicleEnum[vehicleid][veh_y] = dini_Float(file, "veh_y");
            VehicleEnum[vehicleid][veh_z] = dini_Float(file, "veh_z");
            VehicleEnum[vehicleid][veh_rot] = dini_Float(file, "veh_rot");
            for(new c = 1; c < 18; c++)
            {
                format(var, sizeof(var), "veh_component%d", c);
                VehicleEnum[vehicleid][veh_comp][c] = dini_Int(file, var);
            }
            VehicleEnum[vehicleid][veh_colors][1] = dini_Int(file, "veh_color1");
            VehicleEnum[vehicleid][veh_colors][2] = dini_Int(file, "veh_color2");
            VehicleEnum[vehicleid][veh_paintjob] = dini_Int(file, "veh_paintjob");
            VehicleEnum[vehicleid][veh_locked] = dini_Int(file, "veh_locked");
            VehicleEnum[vehicleid][veh_slot] = dini_Int(file, "veh_slot");
            VehicleEnum[vehicleid][veh_int] = dini_Int(file, "veh_int");
            VehicleEnum[vehicleid][veh_world] = dini_Int(file, "veh_world");
            VehicleEnum[vehicleid][veh_neon] = dini_Int(file, "veh_neon");
            VehicleEnum[vehicleid][veh_impounded] = dini_Int(file, "veh_impounded");
            VehicleEnum[vehicleid][veh_impoundprice] = dini_Int(file, "veh_impoundprice");
            VehicleEnum[vehicleid][veh_haslock] = dini_Int(file, "veh_haslock");
            VehicleEnum[vehicleid][veh_registerdate][1] = dini_Int(file, "veh_registerdate1");
            VehicleEnum[vehicleid][veh_registerdate][2] = dini_Int(file, "veh_registerdate2");
            VehicleEnum[vehicleid][veh_registerdate][3] = dini_Int(file, "veh_registerdate3");
            VehicleEnum[vehicleid][veh_registerdate][4] = dini_Int(file, "veh_registerdate4");
            VehicleEnum[vehicleid][veh_registerdate][5] = dini_Int(file, "veh_registerdate5");
            VehicleEnum[vehicleid][veh_registerdate][6] = dini_Int(file, "veh_registerdate6");
            NeonActivated[vehicleid] = dini_Int(file, "NeonActivated");
            VehicleEnum[vehicleid][veh_trunkgun1] = dini_Int(file, "veh_trunkgun1");
            VehicleEnum[vehicleid][veh_trunkgun2] = dini_Int(file, "veh_trunkgun2");
            VehicleEnum[vehicleid][veh_trunkgun3] = dini_Int(file, "veh_trunkgun3");
            VehicleEnum[vehicleid][veh_trunkgun4] = dini_Int(file, "veh_trunkgun4");
            VehicleEnum[vehicleid][veh_trunkarmor] = dini_Float(file, "veh_trunkarmor");
            VehicleEnum[vehicleid][veh_trunkcocaine] = dini_Int(file, "veh_trunkcocaine");
            VehicleEnum[vehicleid][veh_trunkweed] = dini_Int(file, "veh_trunkweed");
            VehicleEnum[vehicleid][veh_trunkmeth] = dini_Int(file, "veh_trunkmeth");
            VehicleEnum[vehicleid][veh_trunkheroin] = dini_Int(file, "veh_trunkheroin");
            VehicleEnum[vehicleid][veh_trunkmats] = dini_Int(file, "veh_trunkmats");
            VehicleEnum[vehicleid][veh_trunkcash] = dini_Int(file, "veh_trunkcash");

            ModifyVehicle(vehicleid);
            LinkVehicleToInterior(vehicleid, VehicleEnum[vehicleid][veh_int]);
            SetVehicleVirtualWorld(vehicleid, VehicleEnum[vehicleid][veh_world]);
            if(VehicleEnum[vehicleid][veh_locked]) LockVehicle(vehicleid);
            if (NeonActivated[vehicleid])
            {
                AddNeonToVehicle(-1, vehicleid, VehicleEnum[vehicleid][veh_neon]);
            }
            if(vehicleid != INVALID_VEHICLE_ID) ownedcars++;
            if (IsABicycle(vehicleid) || IsATrain(vehicleid) || IsVehicleRCVehicle(vehicleid)) SetVehicleEngine(vehicleid, 1);
            else SetVehicleEngine(vehicleid, 0);

            //fremove(file);
            //SaveVehicle(vehicleid);
        }
    }
    return 1;
}
pawn Код:
stock SaveVehicle(vehicleid)
{
    new i = 1;
    new file[100];
    new var[18];
    format(file, sizeof(file), "DealerInfo/cars/%d.cdat", vehicleid);
    if (!VehicleEnum[vehicleid][veh_owned]) return 0;
    if (!dini_Exists(file)) dini_Create(file);
    dini_Set(file, "veh_plate", VehicleEnum[vehicleid][veh_plate]);
    dini_Set(file, "veh_owner", VehicleEnum[vehicleid][veh_owner]);
    dini_IntSet(file, "veh_model", VehicleEnum[vehicleid][veh_model]);
    dini_IntSet(file, "veh_owned", VehicleEnum[vehicleid][veh_owned]);
    dini_IntSet(file, "veh_price", VehicleEnum[vehicleid][veh_price]);
    dini_FloatSet(file, "veh_x", VehicleEnum[vehicleid][veh_x]);
    dini_FloatSet(file, "veh_y", VehicleEnum[vehicleid][veh_y]);
    dini_FloatSet(file, "veh_z", VehicleEnum[vehicleid][veh_z]);
    dini_FloatSet(file, "veh_rot", VehicleEnum[vehicleid][veh_rot]);
    while (i < 18)
    {
        format(var, sizeof(var), "veh_component%d", i);
        dini_IntSet(file, var, VehicleEnum[vehicleid][veh_comp][i]);
        i++;
    }
    dini_IntSet(file, "veh_color1", VehicleEnum[vehicleid][veh_colors][1]);
    dini_IntSet(file, "veh_color2", VehicleEnum[vehicleid][veh_colors][2]);
    dini_IntSet(file, "veh_paintjob", VehicleEnum[vehicleid][veh_paintjob]);
    dini_IntSet(file, "veh_locked", VehicleEnum[vehicleid][veh_locked]);
    dini_IntSet(file, "veh_slot", VehicleEnum[vehicleid][veh_slot]);
    dini_IntSet(file, "veh_int", VehicleEnum[vehicleid][veh_int]);
    dini_IntSet(file, "veh_world", VehicleEnum[vehicleid][veh_world]);
    dini_IntSet(file, "veh_neon", VehicleEnum[vehicleid][veh_neon]);
    dini_IntSet(file, "veh_impounded", VehicleEnum[vehicleid][veh_impounded]);
    dini_IntSet(file, "veh_impoundprice", VehicleEnum[vehicleid][veh_impoundprice]);
    dini_IntSet(file, "veh_haslock", VehicleEnum[vehicleid][veh_haslock]);
    dini_IntSet(file, "veh_registerdate1", VehicleEnum[vehicleid][veh_registerdate][1]);
    dini_IntSet(file, "veh_registerdate2", VehicleEnum[vehicleid][veh_registerdate][2]);
    dini_IntSet(file, "veh_registerdate3", VehicleEnum[vehicleid][veh_registerdate][3]);
    dini_IntSet(file, "veh_registerdate4", VehicleEnum[vehicleid][veh_registerdate][4]);
    dini_IntSet(file, "veh_registerdate5", VehicleEnum[vehicleid][veh_registerdate][5]);
    dini_IntSet(file, "veh_registerdate6", VehicleEnum[vehicleid][veh_registerdate][6]);
    dini_IntSet(file, "NeonActivated", NeonActivated[vehicleid]);
    dini_IntSet(file, "veh_trunkgun1", VehicleEnum[vehicleid][veh_trunkgun1]);
    dini_IntSet(file, "veh_trunkgun2", VehicleEnum[vehicleid][veh_trunkgun2]);
    dini_IntSet(file, "veh_trunkgun3", VehicleEnum[vehicleid][veh_trunkgun3]);
    dini_IntSet(file, "veh_trunkgun4", VehicleEnum[vehicleid][veh_trunkgun4]);
    dini_FloatSet(file, "veh_trunkarmor", VehicleEnum[vehicleid][veh_trunkarmor]);
    dini_IntSet(file, "veh_trunkcocaine", VehicleEnum[vehicleid][veh_trunkcocaine]);
    dini_IntSet(file, "veh_trunkweed", VehicleEnum[vehicleid][veh_trunkweed]);
    dini_IntSet(file, "veh_trunkmeth", VehicleEnum[vehicleid][veh_trunkmeth]);
    dini_IntSet(file, "veh_trunkheroin", VehicleEnum[vehicleid][veh_trunkheroin]);
    dini_IntSet(file, "veh_trunkmats", VehicleEnum[vehicleid][veh_trunkmats]);
    dini_IntSet(file, "veh_trunkcash", VehicleEnum[vehicleid][veh_trunkcash]);
    return 1;
}



Re: Private Owned Vehicle Clones [ Need Help ASAP] - Richard Steinheimer - 02.10.2012

Could you past a new code or something? I need help. Im majorly confused.