26.02.2014, 23:18
Dini to Y_INI can be a complicated process for beginners, but if you know how Y_INI works, you'll be fine. Just look at the y_ini thread and it will explain enough for you to be able to study it, so I'll just give you the code for now :P
This will load each car individually. You will need a loop under OnGameModeInit.
pawn Код:
stock CreateVehicleEx(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawntime, ownername[MAX_PLAYER_NAME], factioncar, noobcar)
{
new carid = GetFreeVehicleSlot();
validcar[carid] = true;
new file[40];
format(file, sizeof(file), "Vehicles/%d.ini", carid); //Change 'Vehicles/%d.ini' to the location of your vehicle file.
new INI:carfile = INI_Open(file);
INI_SetTag(carfile, "data");
INI_WriteInt(carfile, "Model", modelid);
INI_WriteFloat(carfile, "vX", x);
INI_WriteFloat(carfile, "vY", y);
INI_WriteFloat(carfile, "vZ", z);
INI_WriteFloat(carfile, "vA", angle);
INI_WriteInt(carfile, "Color1", color1);
INI_WriteInt(carfile, "Color2", color2);
INI_WriteInt(carfile, "Respawn", respawntime);
INI_WriteString(carfile, "Owner", ownername);
INI_WriteInt(carfile, "FactionCar", factioncar);
INI_WriteInt(carfile, "NoobCar", noobcar);
INI_Close(carfile);
INI_ParseFile(file, "LoadVehicle_%s", .bExtra = true, .extra = carid);
return CreateVehicle(modelid, x, y, z, angle, color1, color2, respawntime);
}
forward LoadVehicle_data(carid, name[], value[]);
public LoadVehicle_data(carid, name[], value[])
{
INI_Int("Model", VehicleInfo[carid][vModel]);
INI_Float("vX", VehicleInfo[carid][vX]);
INI_Float("vY", VehicleInfo[carid][vY]);
INI_Float("vZ", VehicleInfo[carid][vZ]);
INI_Float("vA", VehicleInfo[carid][vA]);
INI_Int("Color1", VehicleInfo[carid][vColor1]);
INI_Int("Color2", VehicleInfo[carid][vColor2]);
INI_Int("Respawn", VehicleInfo[carid][vRespawn]);
INI_String("Owner", VehicleInfo[carid][vOwner], MAX_PLAYER_NAME);
INI_Int("FactionCar", VehicleInfo[carid][vFaction]);
INI_Int("NoobCar", VehicleInfo[carid][vNoob]);
}
stock LoadVehicle(carid)
{
new file[40];
format(file, sizeof(file), "Vehicles/%d.ini", carid); //Change 'Vehicles/%d.ini' to the location of your vehicle file.
INI_ParseFile(file, "LoadVehicle_%s", .bExtra = true, .extra = carid);
CreateVehicle(VehicleInfo[carid][vModel], VehicleInfo[carid][vX], VehicleInfo[carid][vY], VehicleInfo[carid][vZ], VehicleInfo[carid][vA], VehicleInfo[carid][vColor1], VehicleInfo[carid][vColor2], VehicleInfo[carid][vRespawn]);
return 1;
}