Estou fazendo meu sistema de House ainda, mas tem um sу problema, quando carrega as casas as casas ficam com 3 veiculos, sendo que era pra ter 1 sу, e outra, quando salva o arquivo da casa, ele vem todo ferrado tpo Casa Simples,0,0,1,32456,Casa VIP,5412 ele vem todo zuadaгo, tpo mas qdo tinha 1 casa sу no arquivo ficava normal, zuo dps q eu coloquei mais, e o pior, era pra eu ter consiguido resolver mas msm assim to sem saber oq fazer:
pawn Code:
#define MaxHouses 27
#define MaxVehicles 152
new HouseInfo[MaxHouses][info_h];
forward LoadHouses();
public LoadHouses()
{
new arrCoords[24][64];
new strFromFile2[256];
new File: file = fopen("BCC/Houses/Houses.ini", io_read);
if (file)
{
new idx = 1;
while (idx < sizeof(HouseInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, ',');
strmid(HouseInfo[idx][HouseName], arrCoords[0], 0, strlen(arrCoords[0]), 40);
strmid(HouseInfo[idx][Owner], arrCoords[1], 0, strlen(arrCoords[1]), 40);
HouseInfo[idx][MoneyInBox] = strval(arrCoords[2]);
HouseInfo[idx][Rentable] = strval(arrCoords[3]);
HouseInfo[idx][PosX] = floatstr(arrCoords[4]);
HouseInfo[idx][PosY] = floatstr(arrCoords[5]);
HouseInfo[idx][PosZ] = floatstr(arrCoords[6]);
HouseInfo[idx][ForSell] = strval(arrCoords[7]);
HouseInfo[idx][VehicleModel] = strval(arrCoords[8]);
HouseInfo[idx][VHPosX] = floatstr(arrCoords[9]);
HouseInfo[idx][VHPosY] = floatstr(arrCoords[10]);
HouseInfo[idx][VHPosZ] = floatstr(arrCoords[11]);
HouseInfo[idx][VHRotation] = floatstr(arrCoords[12]);
HouseInfo[idx][VColor1] = strval(arrCoords[13]);
HouseInfo[idx][VColor2] = strval(arrCoords[14]);
HouseInfo[idx][InteriorId] = strval(arrCoords[15]);
HouseInfo[idx][IntPosX] = floatstr(arrCoords[16]);
HouseInfo[idx][IntPosY] = floatstr(arrCoords[17]);
HouseInfo[idx][IntPosZ] = floatstr(arrCoords[18]);
HouseInfo[idx][Cost] = strval(arrCoords[19]);
HouseInfo[idx][Locked] = strval(arrCoords[20]);
HouseInfo[idx][Level] = strval(arrCoords[21]);
HouseInfo[idx][ForVip] = strval(arrCoords[22]);
HouseInfo[idx][VirtualWorld] = strval(arrCoords[23]);
HouseInfo[idx][HouseId] = idx;
HouseInfo[idx][VHouseId] = idx+MaxVehicles;
CreateVehicle(HouseInfo[idx][VehicleModel],HouseInfo[idx][VHPosX],HouseInfo[idx][VHPosY],HouseInfo[idx][VHPosZ],HouseInfo[idx][VHRotation],HouseInfo[idx][VColor1],HouseInfo[idx][VColor2],60000);
printf("Id do Carro da Casa %d",HouseInfo[idx][VHouseId]);
printf("Casa: '%s'[ID:%d] Dono:%s [ForSell: %d] Custo: $%d Level[%d] Vip: %d",HouseInfo[idx][HouseName],HouseInfo[idx][HouseId],HouseInfo[idx][Owner],HouseInfo[idx][ForSell],HouseInfo[idx][Cost],HouseInfo[idx][Level],HouseInfo[idx][ForVip]);
if(HouseInfo[idx][ForSell] == 1) AddStaticPickup(1273, 23, HouseInfo[idx][PosX], HouseInfo[idx][PosY], HouseInfo[idx][PosZ]);
if(HouseInfo[idx][ForSell] == 0) AddStaticPickup(1272, 23, HouseInfo[idx][PosX], HouseInfo[idx][PosY], HouseInfo[idx][PosZ]);
idx++;
}
}
return 1;
}
SaveHouses();
public SaveHouses()
{
new File: file2;
new idx;
while (idx < sizeof(HouseInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%s,%s,%d,%d,%f,%f,%f,%d,%d,%f,%f,%f,%f,%d,%d,%d,%f,%f,%f,%d,%d,%d,%d,%d\n",
HouseInfo[idx][HouseName],
HouseInfo[idx][Owner],
HouseInfo[idx][MoneyInBox],
HouseInfo[idx][Rentable],
HouseInfo[idx][PosX],
HouseInfo[idx][PosY],
HouseInfo[idx][PosZ],
HouseInfo[idx][ForSell],
HouseInfo[idx][VehicleModel],
HouseInfo[idx][VHPosX],
HouseInfo[idx][VHPosY],
HouseInfo[idx][VHPosZ],
HouseInfo[idx][VHRotation],
HouseInfo[idx][VColor1],
HouseInfo[idx][VColor2],
HouseInfo[idx][InteriorId],
HouseInfo[idx][IntPosX],
HouseInfo[idx][IntPosY],
HouseInfo[idx][IntPosZ],
HouseInfo[idx][Cost],
HouseInfo[idx][Locked],
HouseInfo[idx][Level],
HouseInfo[idx][ForVip],
HouseInfo[idx][VirtualWorld]
);
if(idx == 1)
{
file2 = fopen("BCC/Houses/Houses.ini", io_write);
printf("HouseID [%d] Dono [%s] ForSell[%d] - Salva com sucesso",idx,HouseInfo[idx][Owner],HouseInfo[idx][ForSell]);
}
else
{
file2 = fopen("BCC/Houses/Houses.ini", io_append);
printf("HouseID [%d] Dono [%s] ForSell[%d] - Salva com sucesso",idx,HouseInfo[idx][Owner],HouseInfo[idx][ForSell]);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
OnGameModeInit()
{
LoadHouses();
}
OnGameModeExit()
{
SaveHouses();
}