15.05.2011, 03:56
Gente eu criei o codigo para salvar o vehicleinfo com o Fini. Olhe o Codigo:
Eu coloquei 2 printf escrito Parte 1 ou 2. Quando eu abro o GM, sу aparece o da parte 1 e cria o arquivo.
pawn Код:
#define MAX_VEHICLES_USED 1283
enum vehInfo
{
vehModelo,
Float:vehX,
Float:vehY,
Float:vehZ,
Float:vehR,
vehDono[64],
vehCor1,
vehCor2,
vehVendido,
}
new VehInfo[MAX_VEHICLES_USED+201][vehInfo];
public SalvarStatusDosVeiculos()
{
new idx = Veiculos+1;
new string[64];
if(!Fini_Exists("vehicles/Venda.txt"))
{
Fini_Create("vehicles/Venda.txt");
Fini_OpenFile("vehicles/Venda.txt");
printf("Parte 1");
while(idx < MAX_VEHICLES_USED+201)
{
VehInfo[idx][vehModelo] = 411;
format(string, sizeof(string), "Modelo%d", idx);
Fini_SetVal(string, 411);
VehInfo[idx][vehX] = 0;
format(string, sizeof(string), "X%d", idx);
Fini_SetFloat(string, 0);
VehInfo[idx][vehY] = 0;
format(string, sizeof(string), "Y%d", idx);
Fini_SetFloat(string, 0);
VehInfo[idx][vehZ] = 0;
format(string, sizeof(string), "Z%d", idx);
Fini_SetFloat(string, 0);
VehInfo[idx][vehR] = 0;
format(string, sizeof(string), "R%d", idx);
Fini_SetFloat(string, 0);
format(VehInfo[idx][vehDono], VehInfo[idx][vehVendido], "Ninguem");
format(string, sizeof(string), "Dono%d", idx);
Fini_SetStr(string, "Ninguem");
VehInfo[idx][vehVendido] = 0;
format(string, sizeof(string), "Vendido%d", idx);
Fini_SetVal(string, 0);
VehInfo[idx][vehCor1] = 0;
format(string, sizeof(string), "Cor1%d", idx);
Fini_SetVal(string, 0);
VehInfo[idx][vehCor2] = 0;
format(string, sizeof(string), "Cor2%d", idx);
Fini_SetVal(string, 0);
idx++;
}
Fini_SaveFile("vehicles/Venda.txt");
printf("Parte 2");
Fini_CloseFile();
PegarStatusDosVeiculos();
}
else
{
Fini_OpenFile("vehicles/Venda.txt");
while(idx < MAX_VEHICLES_USED+201)
{
Fini_SetVal("Modelo", VehInfo[idx][vehModelo]);
Fini_SetFloat("X", VehInfo[idx][vehX]);
Fini_SetFloat("Y", VehInfo[idx][vehY]);
Fini_SetFloat("Z", VehInfo[idx][vehZ]);
Fini_SetFloat("R", VehInfo[idx][vehR]);
Fini_SetStr("Dono", VehInfo[idx][vehDono]);
Fini_SetVal("Vendido", VehInfo[idx][vehVendido]);
Fini_SetVal("Cor1", VehInfo[idx][vehCor1]);
Fini_SetVal("Cor2", VehInfo[idx][vehCor2]);
idx++;
}
Fini_SaveFile("vehicles/Venda");
Fini_CloseFile();
}
return 1;
}