26.07.2012, 09:37
Houses dont save
This is saving system.
Housing dont save.
pawn Код:
public SaveHouses()
{
new idx;
new File: file2;
while (idx < sizeof(HouseInfo))
{
new coordsstring[512];
format(coordsstring, sizeof(coordsstring), "%d|%d|%s|%d|%d|%d|%d|%d|%d|%d|%d|%f|%f|%f|%f|%f|%f|%f|%f|%d|%d|%d|%d\r\n",
HouseInfo[idx][hOwned],
HouseInfo[idx][hPrice],
HouseInfo[idx][hOwner],
HouseInfo[idx][hLevel],
HouseInfo[idx][hLocked],
HouseInfo[idx][hRentable],
HouseInfo[idx][hRentPrice],
HouseInfo[idx][hGun1],
HouseInfo[idx][hGun2],
HouseInfo[idx][hGun3],
HouseInfo[idx][hMoney],
HouseInfo[idx][hEntranceX],
HouseInfo[idx][hEntranceY],
HouseInfo[idx][hEntranceZ],
HouseInfo[idx][hEntranceA],
HouseInfo[idx][hExitX],
HouseInfo[idx][hExitY],
HouseInfo[idx][hExitZ],
HouseInfo[idx][hExitA],
HouseInfo[idx][hInt],
HouseInfo[idx][hWorld],
HouseInfo[idx][hInsideInt],
HouseInfo[idx][hInsideWorld]);
if(idx == 0)
{
file2 = fopen("Houses.cfg", io_write);
}
else
{
file2 = fopen("Houses.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
pawn Код:
YCMD:buyhouse(playerid, params[])
{
if(gPlayerLoggedIn[playerid] == 0) return 1;
new id = IsPlayerNearHouseEnt(playerid);
new rentid = PlayerInfo[playerid][RentingID];
if(id == -1 || id == 0) return SendClientMessage(playerid, COLOR_GREY, "You are not near a house.");
if(HouseInfo[id][hOwned] != 0 || HouseInfo[id][hPrice] == 0) return SendClientMessage(playerid, COLOR_GREY, "This house is not for sale.");
if(rentid != 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are currently renting a house.");
if(PlayerInfo[playerid][HouseID] != 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You already own a house.");
if(PlayerInfo[playerid][Money] < HouseInfo[id][hPrice]) return SendClientMessage(playerid, COLOR_LIGHTRED, "Sorry, you can not afford this house.");
PlayerInfo[playerid][HouseID] = id;
PlayerInfo[playerid][Money] -= HouseInfo[id][hPrice];
GivePlayerMoney(playerid, -HouseInfo[id][hPrice]);
HouseInfo[id][hLocked] = 0;
HouseInfo[id][hOwned] = 1;
HouseInfo[id][hRentable] = 0;
strmid(HouseInfo[id][hOwner], PlayerName(playerid), 0, strlen(PlayerName(playerid)), 255);
SendClientMessage(playerid, COLOR_YELLOW, "Congratulations on your new home! Use /househelp to get help, or /ask!");
return 1;
}