Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock UpdateHouse(h)
- {
- new STR[100], status = 1;
- DestroyDynamicPickup(House[h][Pickup]);
- DestroyDynamicMapIcon(House[h][MapIcon]);
- if(!strcmp(House[h][Owner], !"The State", true)) status = 0;
- House[h][Pickup] = CreateDynamicPickup((!status) ? 1273 : 19522, 23, House[h][Ex], House[h][Ey], House[h][Ez]);
- House[h][MapIcon] = CreateDynamicMapIcon(House[h][Ex], House[h][Ey], House[h][Ez], (!status) ? 31 : 32, (!status) ? COLOR_GREEN : COLOR_RED);
- if(!status) format(STR, sizeof(STR), "[Дом продается]\nЦена: $%d", House[h][Price]);
- else format(STR, sizeof(STR),"[Дом]\nВладелец: %s", House[h][Owner]);
- Update3DTextLabelText(House[h][Text], 0xFFFFFFFF, STR);
- return 1;
- }
- stock LoadHouses()
- {
- mysql_query(connects, "SELECT * FROM `house`");
- new rows, fields, status = 1;
- cache_get_data(rows, fields);
- for(new h; h < rows; h++)
- {
- House[h][id] = cache_get_field_content_int(0, "id", connects);
- cache_get_field_content(0, "owner", House[h][Owner], connects, 24);
- House[h][Ex] = cache_get_field_content_float(0, "x", connects);
- House[h][Ey] = cache_get_field_content_float(0, "y", connects);
- House[h][Ez] = cache_get_field_content_float(0, "z", connects);
- House[h][Int] = cache_get_field_content_int(0, "int", connects);
- House[h][Vw] = cache_get_field_content_int(0, "vw", connects);
- House[h][Class] = cache_get_field_content_int(0, "class", connects);
- House[h][Price] = cache_get_field_content_int(0, "price", connects);
- House[h][Lock] = cache_get_field_content_int(0, "lock", connects);
- CreateDynamicPickup(1318, 23, HInts[House[h][Int]][hiX], HInts[House[h][Int]][hiY], HInts[House[h][Int]][hiZ]); // пикап
- if(!strcmp(House[h][Owner], !"The State", true)) status = 0;
- House[h][Pickup] = CreateDynamicPickup((!status) ? 1273 : 19522, 23, House[h][Ex], House[h][Ey], House[h][Ez]);
- House[h][MapIcon] = CreateDynamicMapIcon(House[h][Ex], House[h][Ey], House[h][Ez], (!status) ? 31 : 32, (!status) ? COLOR_GREEN : COLOR_RED);
- if(!status) format(STR, sizeof(STR), "[Дом продается]\nЦена: $%d", House[h][Price]);
- else format(STR, sizeof(STR),"[Дом]\nВладелец: %s", House[h][Owner]);
- House[h][Text] = Create3DTextLabel(STR, COLOR_WHITE, House[h][Ex], House[h][Ey], House[h][Ez], 2.0, 0);
- }
- return 1;
- }
- CMD:house(playerid)
- {
- new query[128];
- format(query, sizeof(query), "SELECT * FROM `house` WHERE `Owner` = '%s'", Player[playerid][pName]);
- mysql_query(connects, query);
- new rows, fields;
- cache_get_data(rows, fields);
- if(!rows) return SendClientMessage(playerid, COLOR_RED, !"У вас нет своего дома!");
- for(new h; h < rows; h++)
- {
- if(!IsPlayerInRangeOfPoint(playerid, 3.0, House[h][Ex], House[h][Ey], House[h][Ez])) continue;
- if(!strcmp(House[h][Owner], Player[playerid][pName], true)) return ShowPlayerDialog(playerid, DIALOG_HOUSE_MENU, DIALOG_STYLE_LIST, "Меню дома", (!House[h][Lock]) ? ("Закрыть дом\nПродать дом игроку") : ("Открыть дом\nПродать дом игроку"), "Далее", "Отмена");
- else return SendClientMessage(playerid, COLOR_RED, !"Это не ваш дом!");
- }
- SendClientMessage(playerid, COLOR_RED, !"Вы должны быть рядом со своим домом!");
- return 1;
- }
- else if(newkeys & KEY_WALK)
- {
- mysql_query(connects, "SELECT * FROM `house`");
- new rows, fields;
- cache_get_data(rows, fields);
- for(new h; h < rows; h++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.0, House[h][Ex], House[h][Ey], House[h][Ez]))
- {
- if(House[h][Lock] == 1) return SendClientMessage(playerid, COLOR_RED, "Дом закрыт! Если это ваш дом то откройте его через </house>");
- SendClientMessage(playerid, COLOR_WHITE, "Ты зашёл в дом!");
- SetPlayerPos(playerid, HInts[House[h][Int]][hiX], HInts[House[h][Int]][hiY], HInts[House[h][Int]][hiZ]);
- SetPlayerInterior(playerid, HInts[House[h][Int]][hiInt]);
- SetPlayerVirtualWorld(playerid, House[h][Vw]);
- inHouse[playerid] = 1;
- PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
- return 1;
- }
- else if(IsPlayerInRangeOfPoint(playerid, 1.0, HInts[House[h][Int]][hiX], HInts[House[h][Int]][hiY], HInts[House[h][Int]][hiZ]))
- {
- SendClientMessage(playerid, COLOR_WHITE, "Ты вышел из дома!");
- inHouse[playerid] = 0;
- SetPlayerInterior(playerid, 0);
- SetPlayerVirtualWorld(playerid, 0);
- SetPlayerPos(playerid, House[h][Ex], House[h][Ey], House[h][Ez]);
- PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
- return 1;
- }
- }
- }
- else if(newkeys & KEY_YES)
- {
- mysql_query(connects, "SELECT * FROM `house`");
- new rows, fields;
- cache_get_data(rows, fields);
- for(new h; h < rows; h++)
- {
- if(!IsPlayerInRangeOfPoint(playerid, 1.0, House[h][Ex], House[h][Ey], House[h][Ez])) continue;
- if(!strcmp(House[h][Owner], "The State"))
- {
- if(Player[playerid][pMoney] < House[h][Price]) return SendClientMessage(playerid, COLOR_RED, "У вас недостаточно денег для покупки этого дома!");
- Player[playerid][pMoney] -= House[h][Price];
- format(House[h][Owner], 24, "%s", Player[playerid][pName]);
- SendClientMessage(playerid,-1,"Вы успешно купили дом!");
- PlayerPlaySound(playerid,1054,0.0,0.0,0.0);
- UpdateHouse(h);
- SaveHouses(h);
- return 1;
- }
- SendClientMessage(playerid, COLOR_RED, "Этот дом уже куплен!");
- return 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement