10.05.2011, 11:50
(
Последний раз редактировалось black_dota; 10.05.2011 в 13:04.
)
This is my House System from 0
I dont get what is problem with loading and saving houses,it only loads first house, and when i shut down server the houses.cfg makes some random numbers, and deleting all houses except first one.
I dont get what is problem with loading and saving houses,it only loads first house, and when i shut down server the houses.cfg makes some random numbers, and deleting all houses except first one.
pawn Код:
enum hInfo
{
Float:hEntX,
Float:hEntY,
Float:hEntZ,
hInt,
Float:hExitX,
Float:hExitY,
Float:hExitZ,
hPickup,
hOwner[24],
hPrice,
hRentPrice,
hOwned,
hVehModel,
Float:hVehX,
Float:hVehY,
Float:hVehZ,
Float:hVehA,
hLocked,
hRented
};
new HouseInfo[10][hInfo];
new Iterator:Houses<10>;
public OnGameModeInit()
{
LoadHouses();
foreach(Houses, h)
{
if(HouseInfo[h][hOwned] == 1) HouseInfo[h][hPickup] = CreateDynamicPickup(1272, 23, HouseInfo[h][hEntX], HouseInfo[h][hEntY], HouseInfo[h][hEntZ]);
else if(HouseInfo[h][hOwned] == 0) HouseInfo[h][hPickup] = CreateDynamicPickup(1273, 23, HouseInfo[h][hEntX], HouseInfo[h][hEntY], HouseInfo[h][hEntZ]);
}
return true;
}
public LoadHouses()
{
new strFromFile2[256];
new File: file = fopen("IGRP/houses.cfg", io_read);
if(file)
{
Iter_Add(Houses, 1);
Iter_Add(Houses, 1);
Iter_Add(Houses, 1);
Iter_Add(Houses, 1);
Iter_Add(Houses, 1);
Iter_Add(Houses, 1);
Iter_Add(Houses, 1);
Iter_Add(Houses, 1);
Iter_Add(Houses, 1);
foreach(Houses, idx)
{
fread(file, strFromFile2);
sscanf(strFromFile2, "p<,>fffifffis[24]iiiiiiffff",
HouseInfo[idx][hEntX],
HouseInfo[idx][hEntY],
HouseInfo[idx][hEntZ],
HouseInfo[idx][hInt],
HouseInfo[idx][hExitX],
HouseInfo[idx][hExitY],
HouseInfo[idx][hExitZ],
HouseInfo[idx][hPickup],
HouseInfo[idx][hOwner],
HouseInfo[idx][hPrice],
HouseInfo[idx][hRentPrice],
HouseInfo[idx][hOwned],
HouseInfo[idx][hLocked],
HouseInfo[idx][hRented],
HouseInfo[idx][hVehModel],
HouseInfo[idx][hVehX],
HouseInfo[idx][hVehY],
HouseInfo[idx][hVehZ],
HouseInfo[idx][hVehA]);
if(IsValidVehicleModel(HouseInfo[idx][hVehModel]))
{
CreateVehicle(HouseInfo[idx][hVehModel], HouseInfo[idx][hVehX], HouseInfo[idx][hVehY], HouseInfo[idx][hVehZ], HouseInfo[idx][hVehA], -1, -1, -1);
}
}
fclose(file);
}
return true;
}
public SaveHouses()
{
new
coordsstring[256],
File: File;
printf("Owner: %s", HouseInfo[1][hOwner]);
foreach(Houses, idx)
{
format(coordsstring, 256, "%f,%f,%f,%i,%f,%f,%i,s%,%i,%i,%i,%i,%i,%i,%f,%f,%f,%f",
HouseInfo[idx][hEntX],
HouseInfo[idx][hEntY],
HouseInfo[idx][hEntZ],
HouseInfo[idx][hInt],
HouseInfo[idx][hExitX],
HouseInfo[idx][hExitY],
HouseInfo[idx][hExitZ],
HouseInfo[idx][hPickup],
HouseInfo[idx][hOwner],
HouseInfo[idx][hPrice],
HouseInfo[idx][hRentPrice],
HouseInfo[idx][hOwned],
HouseInfo[idx][hLocked],
HouseInfo[idx][hRented],
HouseInfo[idx][hVehModel],
HouseInfo[idx][hVehX],
HouseInfo[idx][hVehY],
HouseInfo[idx][hVehZ],
HouseInfo[idx][hVehA]);
if(idx == 1)
{
File = fopen("IGRP/houses.cfg", io_write);
}
else
{
File = fopen("IGRP/houses.cfg", io_append);
}
fwrite(File, coordsstring);
fclose(File);
}
return true;
}