02.09.2012, 15:35
(
Последний раз редактировалось zDevon; 03.09.2012 в 08:25.
)
Hi all.
I'm gonna try to be as descriptive as possible with my problem, we'll see. I was originally saving vehicle stats by their own ID, which became problematic when their IDs changed when new ones were created, etc, so I'm needing to assign specific file IDs now. But I can't get that part to work.
I have my vehicle enums:
and then, the saving:
I feel like there's something really simple that I'm missing. What happens with the above code is 0.ini is created, within scriptfiles/vehicles, but that's the only one. If I save one vehicle, it's stored to that file. If I save a second, it only overwrites the old data in that file instead of creating a new one.
If anyone could explain why this is happening, provide a fix, or offer another method to get what I'm trying to do done, that'd be great. If any more code is needed I'll gladly post it.
I'm gonna try to be as descriptive as possible with my problem, we'll see. I was originally saving vehicle stats by their own ID, which became problematic when their IDs changed when new ones were created, etc, so I'm needing to assign specific file IDs now. But I can't get that part to work.
I have my vehicle enums:
pawn Код:
enum VehicleStatistics
{
Color1,
Color2,
SAMPID = 999,
FileID = 999,
ModelID,
Float: ParkX,
Float: ParkY,
Float: ParkZ,
Float: ParkAng,
Plate[MAX_NUMBER_PLATE],
GPSLevel,
LockLevel,
HasLaserKey,
AlarmLevel,
FrameLevel,
TiresLevel,
TrunkSlot1,
TrunkSlot2,
TrunkSlot3,
TrunkSlot4,
TrunkSlot5,
Ammo1,
Ammo2,
Ammo3,
Ammo4,
Ammo5
}
pawn Код:
stock SaveVehicle(i)
{
new Float:Ang;
GetVehicleZAngle(i,Float:Ang);
new Float:X, Float:Y, Float:Z;
GetVehiclePos(i,Float:X,Float:Y,Float:Z);
new color1, color2;
GetVehicleColor(i,color1,color2);
if(gVehicleStats[i][FileID] == 999)
{
gVehicleStats[i][FileID] = GetAvailableFileID();
}
new path[32];
format(path, sizeof(path), "vehicles/%d.ini", gVehicleStats[i][FileID]);
new INI:File = INI_Open(path);
INI_SetTag(File, "data");
INI_WriteInt(File,"ModelID", GetVehicleModel(i));
INI_WriteInt(File,"Color1", gVehicleStats[i][Color1]);
INI_WriteInt(File,"Color2", gVehicleStats[i][Color2]);
INI_WriteFloat(File,"ParkX", X);
INI_WriteFloat(File,"ParkY", Y);
INI_WriteFloat(File,"ParkZ", Z);
INI_WriteFloat(File,"ParkAng", Ang);
INI_WriteString(File,"Plate", gVehicleStats[i][Plate]);
INI_WriteInt(File,"GPSLevel", gVehicleStats[i][GPSLevel]);
INI_WriteInt(File,"LockLevel", gVehicleStats[i][LockLevel]);
INI_WriteInt(File,"HasLaserKey", gVehicleStats[i][HasLaserKey]);
INI_WriteInt(File,"AlarmLevel", gVehicleStats[i][AlarmLevel]);
INI_WriteInt(File,"FrameLevel", gVehicleStats[i][FrameLevel]);
INI_WriteInt(File,"TiresLevel", gVehicleStats[i][TiresLevel]);
INI_WriteInt(File,"TrunkSlot1", gVehicleStats[i][TrunkSlot1]);
INI_WriteInt(File,"TrunkSlot2", gVehicleStats[i][TrunkSlot2]);
INI_WriteInt(File,"TrunkSlot3", gVehicleStats[i][TrunkSlot3]);
INI_WriteInt(File,"TrunkSlot4", gVehicleStats[i][TrunkSlot4]);
INI_WriteInt(File,"TrunkSlot5", gVehicleStats[i][TrunkSlot5]);
INI_WriteInt(File,"Ammo1", gVehicleStats[i][Ammo1]);
INI_WriteInt(File,"Ammo2", gVehicleStats[i][Ammo2]);
INI_WriteInt(File,"Ammo3", gVehicleStats[i][Ammo3]);
INI_WriteInt(File,"Ammo4", gVehicleStats[i][Ammo4]);
INI_WriteInt(File,"Ammo5", gVehicleStats[i][Ammo5]);
INI_Close(File);
}
If anyone could explain why this is happening, provide a fix, or offer another method to get what I'm trying to do done, that'd be great. If any more code is needed I'll gladly post it.