24.03.2014, 07:12
pawn Код:
stock SellHouse()
{
for (new i = 1, bank, notice[8], text[3], playerid; i <= TOTALHOUSE; i++) {
HouseInfo[i][hRobhouse] = false;
if (HouseInfo[i][hOwned]) {
if (HouseInfo[i][hTakings] < HouseInfo[i][hPaycash]) {
playerid = INVALID_PLAYER_ID;
sscanf(HouseInfo[i][hOwner], "u", playerid);
if (IsPlayerConnected(playerid)) {
PlayerInfo[playerid][pBank] += (HouseInfo[i][hValue] + HouseInfo[i][hTakings] - HouseInfo[i][hPaycash] * 2);
PlayerInfo[playerid][pIDHouse] = 0;
SetPVarInt(playerid, "GetHome", 1);
} else {
format(query, sizeof(query), "SELECT Bank, Notice FROM "TABLE_ACCOUNT" WHERE Name='%s'", HouseInfo[i][hOwner]);
mysql_query(query);
mysql_store_result();
if (mysql_fetch_row_format(query)) {
sscanf(query, "p<|>is[8]", bank, notice);
mysql_free_result();
sscanf(notice, "p<,>a<i>[3]", text);
text[0] = 1;
format(notice, sizeof(notice),"%d,%d,%d", text[0], text[1], text[2]);
bank += HouseInfo[i][hValue];
SetPlayerInt(HouseInfo[i][hOwner], "Bank", bank);
SetPlayerStr(HouseInfo[i][hOwner], "Notice", notice);
}// я пологаю что если строки вдруг нет или произошла ошибка в БД надо что-то предпринять
}
HouseInfo[i][hOwned] = 0;
HouseInfo[i][hHealme] = 0;
HouseInfo[i][hTakings] = 0;
strmid(HouseInfo[i][hOwner], "The State", 0, strlen("The State"), 255);
SetHouseStr(i,"Owner",HouseInfo[i][hOwner]);
SetHouseInt(i,"Owned",HouseInfo[i][hOwned]);
SetHouseInt(i,"Takings",HouseInfo[i][hTakings]);
SetHouseInt(i,"Healme",HouseInfo[i][hHealme]);
UpdateHouseInfo(i);
} else {
HouseInfo[i][hTakings] -= HouseInfo[i][hPaycash];
SetHouseInt(i, "Takings", HouseInfo[i][hTakings]);
}
}
}
return 1;
}