Densi2882
Новичок
После рестарта идет слет дома. Если выдать дом через базу то все ок.
SaveHouse
stock LoadHouse
покупка дома
Код:
stock UpdateHouse(house, save = 1)
{
new string[300];
if(IsValidDynamicMapIcon(HouseIcon[house])) DestroyDynamicMapIcon(HouseIcon[house]);
static const dour_status[2][23 + 1] = {
"{3D9829}Îòêðûòà{FFFFFF}",
"{C22323}Çàêðûòà{FFFFFF}"
};
static const hgarage_status[2][24 + 1] = {
"[{fa736c} ÍÅÒ {FFFFFF}]",
"[{27c627} ÅÑÒÜ {FFFFFF}]"
};
if(GetString(HouseInfo[house][hOwner],"The State"))
{
format(string,sizeof(string),
"{FF9900}*** Äîì ïðîäàåòñÿ ***\
\n\n{FFFFFF}Íîìåð äîìà: {AFAFAF}%d\
\n{FFFFFF}Êëàññ äîìà: {AFAFAF}%d\
\n{FFFFFF}Ñòîèìîñòü: {AFAFAF}$%d\
\n{FFFFFF}Ãàðàæ: {AFAFAF}%s",house,
HouseInfo[house][hKlass],
HouseInfo[house][hCost],
hgarage_status[HouseInfo[house][hGarage]]
);
HouseIcon[house] = CreateDynamicMapIcon(HouseInfo[house][hEnter_X], HouseInfo[house][hEnter_Y], HouseInfo[house][hEnter_Z], 31, 0);
} else {
if(strlen(HouseInfo[house][hOpis])) format(string, sizeof(string), "\n{ffff00}%s", HouseInfo[house][hOpis]);
else string[0] = EOS;
format(string,sizeof(string),
"{FF9900}*** Äîì çàíÿò ***\
%s\n\n\
\n\n{FFFFFF}Íîìåð äîìà: {AFAFAF}%d\
\n{FFFFFF}Êëàññ äîìà: {AFAFAF}%d\
\n{FFFFFF}Äâåðü: %s\
\n{FFFFFF}Ãàðàæ: {AFAFAF}%s",
string,house,
HouseInfo[house][hKlass],
dour_status[HouseInfo[house][hLock]],
hgarage_status[HouseInfo[house][hGarage]]
);
HouseIcon[house] = CreateDynamicMapIcon(HouseInfo[house][hEnter_X], HouseInfo[house][hEnter_Y], HouseInfo[house][hEnter_Z], 32, 0);
}
UpdateDynamic3DTextLabelText(House3DText[house],COLOR_WHITE,string);
if(save) SaveHouse(house);
return 1;
}
SaveHouse
Код:
stock SaveHouse(houseid)
{
new string[1200], str[256];
format(str, sizeof(str), "UPDATE `houses` SET");
strcat(string, str);
format(str, sizeof(str), "`Enter_X` = '%.4f',`Enter_Y` = '%.4f',`Enter_Z` = '%.4f', ",
HouseInfo[houseid][hEnter_X],
HouseInfo[houseid][hEnter_Y],
HouseInfo[houseid][hEnter_Z]);
strcat(string, str);
format(str, sizeof(str), "`Exit_X` = '%.4f', `Exit_Y` = '%.4f', `Exit_Z` = '%.4f', ",
HouseInfo[houseid][hExit_X],
HouseInfo[houseid][hExit_Y],
HouseInfo[houseid][hExit_Z]);
strcat(string, str);
format(str, sizeof(str), "`Owner` = '%s', `Room_Owner_0` = '%s',`Room_Owner_1` = '%s', ",
HouseInfo[houseid][hOwner],
HRoomOwner[houseid][0],
HRoomOwner[houseid][1]);
strcat(string, str);
format(str, sizeof(str), "`Room_Owner_2` = '%s', `Room_Owner_3` = '%s', `Room_Owner_4` = '%s', ",
HRoomOwner[houseid][2],
HRoomOwner[houseid][3],
HRoomOwner[houseid][4]);
strcat(string, str);
format(str, sizeof(str), "`Level` = '%d', `Cost` = '%d', `Lock` = '%d', `Rent` = '%d', ",
HouseInfo[houseid][hLevel],
HouseInfo[houseid][hCost],
HouseInfo[houseid][hLock],
HouseInfo[houseid][hRent]);
strcat(string, str);
format(str, sizeof(str), "`Interior` = '%d', `Money` = '%d', `Drugs` = '%d', `Mats` = '%d', ",
HouseInfo[houseid][hInt],
HouseInfo[houseid][hMoney],
HouseInfo[houseid][hDrugs],
HouseInfo[houseid][hMats]);
strcat(string, str);
format(str, sizeof(str), "`Bar` = '%d', `Podval` = '%d', `Skin_1` = '%d', `Skin_2` = '%d', ",
HouseInfo[houseid][hBar],
HouseInfo[houseid][hPodval],
HouseInfo[houseid][hSkin][0],
HouseInfo[houseid][hSkin][1]);
strcat(string, str);
format(str, sizeof(str), "`Skin_3` = '%d', `Skin_4` = '%d', `Skin_5` = '%d', `NoOwner` = '%d', `Nalog` = '%d', `Klass` = '%d', `Med` = '%d', ",
HouseInfo[houseid][hSkin][2],
HouseInfo[houseid][hSkin][3],
HouseInfo[houseid][hSkin][4],
HouseInfo[houseid][hNoOwner],
HouseInfo[houseid][hNalog],
HouseInfo[houseid][hKlass],
HouseInfo[houseid][hMed]);
strcat(string, str);
format(str, sizeof(str), "`Garage`='%i', `Garage_X`='%.4f', `Garage_Y`='%.4f', `Garage_Z`='%.4f' WHERE `ID` = '%i'",
HouseInfo[houseid][hGarage],
HouseInfo[houseid][hGarage_X],
HouseInfo[houseid][hGarage_Y],
HouseInfo[houseid][hGarage_Z],
HouseInfo[houseid][hOpis],
houseid);
strcat(string, str);
mysql_query(mysql, string, false);
return 1;
}
Код:
stock LoadHouses()
{
for(new i = -1; ++i < MAX_HOUSES;) SetString(HouseInfo[i][hOwner], "The State");
new Cache:result = mysql_query(mysql, "SELECT * FROM `houses`");
OWNABLEHOUSES = cache_get_row_count(mysql);
for (new i = -1; ++i < OWNABLEHOUSES;)
{
HouseInfo[i+1][hID] = cache_get_row_int(i, 0, mysql);
HouseInfo[i+1][hEnter_X] = cache_get_row_float(i, 1, mysql);
HouseInfo[i+1][hEnter_Y] = cache_get_row_float(i, 2, mysql);
HouseInfo[i+1][hEnter_Z] = cache_get_row_float(i, 3, mysql);
HouseInfo[i+1][hExit_X] = cache_get_row_float(i, 4, mysql);
HouseInfo[i+1][hExit_Y] = cache_get_row_float(i, 5, mysql);
HouseInfo[i+1][hExit_Z] = cache_get_row_float(i, 6, mysql);
cache_get_row(i, 7, HouseInfo[i+1][hOwner], mysql, 24);
cache_get_row(i, 8, HRoomOwner[i+1][0], mysql, 24);
cache_get_row(i, 9, HRoomOwner[i+1][1], mysql, 24);
cache_get_row(i, 10, HRoomOwner[i+1][2], mysql, 24);
cache_get_row(i, 11, HRoomOwner[i+1][3], mysql, 24);
cache_get_row(i, 12, HRoomOwner[i+1][4], mysql, 24);
HouseInfo[i+1][hLevel] = cache_get_row_int(i, 13, mysql);
HouseInfo[i+1][hCost] = cache_get_row_int(i, 14, mysql);
HouseInfo[i+1][hLock] = cache_get_row_int(i, 15, mysql);
HouseInfo[i+1][hRent] = cache_get_row_int(i, 16, mysql);
HouseInfo[i+1][hInt] = cache_get_row_int(i, 17, mysql);
HouseInfo[i+1][hMoney] = cache_get_row_int(i, 18, mysql);
HouseInfo[i+1][hDrugs] = cache_get_row_int(i, 19, mysql);
HouseInfo[i+1][hMats] = cache_get_row_int(i, 20, mysql);
HouseInfo[i+1][hBar] = cache_get_row_int(i, 21, mysql);
HouseInfo[i+1][hPodval] = cache_get_row_int(i, 22, mysql);
HouseInfo[i+1][hSkin][0] = cache_get_row_int(i, 23, mysql);
HouseInfo[i+1][hSkin][1] = cache_get_row_int(i, 24, mysql);
HouseInfo[i+1][hSkin][2] = cache_get_row_int(i, 25, mysql);
HouseInfo[i+1][hSkin][3] = cache_get_row_int(i, 26, mysql);
HouseInfo[i+1][hSkin][4] = cache_get_row_int(i, 27, mysql);
HouseInfo[i+1][hNoOwner] = cache_get_row_int(i, 28, mysql);
HouseInfo[i+1][hNalog] = cache_get_row_int(i, 29, mysql);
HouseInfo[i+1][hKlass] = cache_get_row_int(i, 30, mysql);
HouseInfo[i+1][hMed] = cache_get_row_int(i, 31, mysql);
HouseInfo[i+1][hGarage] = cache_get_row_int(i, 32, mysql);
HouseInfo[i+1][hGarage_X] = cache_get_row_float(i, 33, mysql);
HouseInfo[i+1][hGarage_Y] = cache_get_row_float(i, 34, mysql);
HouseInfo[i+1][hGarage_Z] = cache_get_row_float(i, 35, mysql);
cache_get_row(0, 36, HouseInfo[i+1][hOpis],mysql, 32);
}
cache_delete(result, mysql);
return 1;
}
Код:
case 1:
{
new house = InfoHouse[playerid];
if(!strcmp(HouseInfo[house][hOwner], "The State"))
{
HouseEntered[playerid] = house;
HouseInfo[house][hNoOwner] = 0;
InfoHouse[playerid] = -1;
PI[playerid][pDCTime] = 1;
SendClientMessage(playerid, -1, !">> {FF6347} Местом спавна автоматически назначен ваш дом. Изменить место спавна {FFFFFF}>> {FF6347}/setspawn!");
GiveMoney(playerid,-HouseInfo[house][hCost]);
// aml2,playerid,"","Покупка дома",HouseInfo[house][hCost],0,0,0,0);
PI[playerid][pHouseKey] = house;
foreach(new i: Player)
{
if(HouseNalog[i] == house)
{
callcmd::stopjob(i, "");
SendClientMessage(i, COLOR_RED, !"[Информация] {FFFFFF}Дом над которым вы работаете был выкуплен. Начните работу заново.");
}
}
SetPlayerInterior(playerid, HouseInfo[house][hInt]);
SetPlayerVirtualWorld(playerid, house + 50);
TextDrawHideForPlayer(playerid, HInfoBG);
for(new i; i < 6; i ++)PlayerTextDrawHide(playerid, HInfoDraw[playerid][i]);
TextDrawHideForPlayer(playerid, HInfoEnterDraw);
TextDrawHideForPlayer(playerid, HInfoBuyDraw);
J_SetPlayerPos(playerid, HouseInfo[house][hExit_X], HouseInfo[house][hExit_Y], HouseInfo[house][hExit_Z]);
SetString(HouseInfo[house][hOwner], PN(playerid));
UpdateHouse(house);
SendClientMessage(playerid, COLOR_VALIK, !"[Информация] {FFFFFF}Поздравляю! Теперь этот дом ваш!");
PlayerPlaySound(playerid, 30800, 0.0, 0.0, 0.0);
format(string, sizeof(string), "%s [%d] купил дом по гос. цене! Капча: %s! За %.2fmc!", PN(playerid), playerid, inputtext,buytime[playerid]);
SendAdminsMessage(COLOR_RED, string);
WriteLog("", string);
KillTimer(buytime2[playerid]);
buytime[playerid] = 0;
TogglePlayerControllable(playerid, false);//
SetTimerEx("@__UnFreez",3000, 0, "d", playerid);
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, !"[Ошибка] {FFFFFF}Этот дом уже куплен!");
KillTimer(buytime2[playerid]);
buytime[playerid] = 0;
}
}
Последнее редактирование:
