SA-MP Forums Archive
Vehicle Sys.. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Vehicle Sys.. (/showthread.php?tid=218740)



Vehicle Sys.. - Luis- - 30.01.2011

Okay, the saving now works, It is just the loading, This is was is causing the "World Boundaries" bug;

The Saving
pawn Код:
if(strcmp(cmdtext, "/savevehicles", true) == 0)
    { //Saves ALL vehicles. There you go, ELuisabiatch. I hope this meets your needs, I can't be too sure tho, I no haef source so no testing -.-
        new file[128], Float:Pos[4], vehModel, Plate, str[128], Type;
        new vehicleid = GetPlayerVehicleID(playerid);
        //if(PlayerInfo[playerid][pAdmin] <  10 && !IsPlayerAdmin(playerid)) return 1;
        for(new i = 1; i<=MAX_CARS; i++)
        {
            if(!GetVehicleModel(i)) return 1;
            format(file, sizeof(file), "Vehicles/%d.ini", i);
            if(!dini_Exists(file))
            {
                dini_Create(file);
                printf("Vehicle ID %d file created", i);
            }
            GetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]);
            GetVehicleZAngle(vehicleid, Pos[3]);
            vehModel = GetVehicleModel(i);
            //dini_Create(file);
            dini_IntSet(file, "Model", vehModel);
            dini_FloatSet(file, "PosX", Pos[0]);
            dini_FloatSet(file, "PosY", Pos[1]);
            dini_FloatSet(file, "PosZ", Pos[2]);
            dini_FloatSet(file, "PosA", Pos[3]);
            //dini_Set(file, "Plate", Plate);
            dini_IntSet(file, "Type", Type);

            printf("Vehicle ID %d saved", i);
            format(str, sizeof(str), "DEBUG: Vehicle ID %d saved", i);
            SendClientMessage(playerid, COLOR_YELLOW, str);
            print("Debug Message: Saving Vehicles is Good!");
            //break;
        }
        return 1;
    }
The Loading
Now, I want the Loading to be perfect just like the Saving.
pawn Код:
forward LoadVehicle();
public LoadVehicle()
{
    new file[128], Model, Veh, Float:Pos[4];
    for(new i = 1; i<=MAX_CARS; i++)
    {
        format(file, sizeof(file), "Vehicles/%d.ini", i);
        if(dini_Exists(file))
        {
            Model = dini_Int(file, "Model");
            Pos[0] = dini_Int(file, "VehX");
            Pos[1] = dini_Int(file, "VehY");
            Pos[2] = dini_Int(file, "VehZ");
            Pos[3] = dini_Int(file, "VehA");
            Veh = CreateVehicle(Model, Pos[0], Pos[1], Pos[2], Pos[3], 1, 1, 1000);
            VehicleInfo[i][vModel] = Model;
            VehicleInfo[i][vX] = Pos[0];
            VehicleInfo[i][vY] = Pos[1];
            VehicleInfo[i][vZ] = Pos[2];
            VehicleInfo[i][vA] = Pos[3];
        }
        //CreateVehicle(VehicleInfo[i][vModel], VehicleInfo[i][vX], VehicleInfo[i][vY], VehicleInfo[i][vZ], VehicleInfo[i][vA], 1, 1, false);
    }
    print("Debug Message: Loading Vehicles is Good!");
    return 1;
}
I know it is a mess, But I am still an Amateur with Scripting so I am sorry about that.


Re: Vehicle Sys.. - DRIFT_HUNTER - 31.01.2011

Well i noticed that you using dini_Int for Float

Try these
pawn Код:
forward LoadVehicle();
public LoadVehicle()
{
    new file[128], Model, Veh, Float:Pos[4];
    for(new i = 1; i<=MAX_CARS; i++)
    {
        format(file, sizeof(file), "Vehicles/%d.ini", i);
        if(dini_Exists(file))
        {
            VehicleInfo[i][vModel] = dini_Int(file, "Model");
            VehicleInfo[i][vX] = dini_Float(file, "VehX");
            VehicleInfo[i][vY] = dini_Float(file, "VehY");
            VehicleInfo[i][vZ] = dini_Float(file, "VehZ");
            VehicleInfo[i][vA] = dini_Float(file, "VehA"
            CreateVehicle(VehicleInfo[i][vModel], VehicleInfo[i][vX], VehicleInfo[i][vY], VehicleInfo[i][vZ], VehicleInfo[i][vA], 1, 1, false);
        }
    }
    print("Debug Message: Loading Vehicles is Good!");
    return 1;
}