Advertisement
OKStyle

Question 1

Jul 12th, 2021
1,516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.14 KB | None | 0 0
  1. stock UpdateHouse(h)
  2. {
  3.     new STR[100], status = 1;
  4.     DestroyDynamicPickup(House[h][Pickup]);
  5.     DestroyDynamicMapIcon(House[h][MapIcon]);
  6.     if(!strcmp(House[h][Owner], !"The State", true)) status = 0;
  7.     House[h][Pickup] = CreateDynamicPickup((!status) ? 1273 : 19522, 23, House[h][Ex], House[h][Ey], House[h][Ez]);
  8.     House[h][MapIcon] = CreateDynamicMapIcon(House[h][Ex], House[h][Ey], House[h][Ez], (!status) ? 31 : 32, (!status) ? COLOR_GREEN : COLOR_RED);
  9.     if(!status) format(STR, sizeof(STR), "[Дом продается]\nЦена: $%d", House[h][Price]);
  10.     else format(STR, sizeof(STR),"[Дом]\nВладелец: %s", House[h][Owner]);
  11.     Update3DTextLabelText(House[h][Text], 0xFFFFFFFF, STR);
  12.     return 1;
  13. }
  14.  
  15. stock LoadHouses()
  16. {
  17.     mysql_query(connects, "SELECT * FROM `house`");
  18.     new rows, fields, status = 1;
  19.     cache_get_data(rows, fields);
  20.     for(new h; h < rows; h++)
  21.     {
  22.         House[h][id] = cache_get_field_content_int(0, "id", connects);
  23.         cache_get_field_content(0, "owner", House[h][Owner], connects, 24);
  24.         House[h][Ex] = cache_get_field_content_float(0, "x", connects);
  25.         House[h][Ey] = cache_get_field_content_float(0, "y", connects);
  26.         House[h][Ez] = cache_get_field_content_float(0, "z", connects);
  27.         House[h][Int] = cache_get_field_content_int(0, "int", connects);
  28.         House[h][Vw] = cache_get_field_content_int(0, "vw", connects);
  29.         House[h][Class] = cache_get_field_content_int(0, "class", connects);
  30.         House[h][Price] = cache_get_field_content_int(0, "price", connects);
  31.         House[h][Lock] = cache_get_field_content_int(0, "lock", connects);
  32.         CreateDynamicPickup(1318, 23, HInts[House[h][Int]][hiX], HInts[House[h][Int]][hiY], HInts[House[h][Int]][hiZ]); // пикап
  33.         if(!strcmp(House[h][Owner], !"The State", true)) status = 0;
  34.         House[h][Pickup] = CreateDynamicPickup((!status) ? 1273 : 19522, 23, House[h][Ex], House[h][Ey], House[h][Ez]);
  35.         House[h][MapIcon] = CreateDynamicMapIcon(House[h][Ex], House[h][Ey], House[h][Ez], (!status) ? 31 : 32, (!status) ? COLOR_GREEN : COLOR_RED);
  36.         if(!status) format(STR, sizeof(STR), "[Дом продается]\nЦена: $%d", House[h][Price]);
  37.         else format(STR, sizeof(STR),"[Дом]\nВладелец: %s", House[h][Owner]);
  38.         House[h][Text] = Create3DTextLabel(STR, COLOR_WHITE, House[h][Ex], House[h][Ey], House[h][Ez], 2.0, 0);
  39.     }
  40.     return 1;
  41. }
  42.  
  43.  
  44.  
  45. CMD:house(playerid)
  46. {
  47.     new query[128];
  48.     format(query, sizeof(query), "SELECT * FROM `house` WHERE `Owner` = '%s'", Player[playerid][pName]);
  49.     mysql_query(connects, query);
  50.     new rows, fields;
  51.     cache_get_data(rows, fields);
  52.     if(!rows) return SendClientMessage(playerid, COLOR_RED, !"У вас нет своего дома!");
  53.     for(new h; h < rows; h++)
  54.     {
  55.         if(!IsPlayerInRangeOfPoint(playerid, 3.0, House[h][Ex], House[h][Ey], House[h][Ez])) continue;
  56.         if(!strcmp(House[h][Owner], Player[playerid][pName], true)) return ShowPlayerDialog(playerid, DIALOG_HOUSE_MENU, DIALOG_STYLE_LIST, "Меню дома", (!House[h][Lock]) ? ("Закрыть дом\nПродать дом игроку") : ("Открыть дом\nПродать дом игроку"), "Далее", "Отмена");
  57.         else return SendClientMessage(playerid, COLOR_RED, !"Это не ваш дом!");
  58.     }
  59.     SendClientMessage(playerid, COLOR_RED, !"Вы должны быть рядом со своим домом!");
  60.     return 1;
  61. }
  62.  
  63.  
  64.  
  65.     else if(newkeys & KEY_WALK)
  66.     {
  67.         mysql_query(connects, "SELECT * FROM `house`");
  68.         new rows, fields;
  69.         cache_get_data(rows, fields);
  70.         for(new h; h < rows; h++)
  71.         {
  72.             if(IsPlayerInRangeOfPoint(playerid, 1.0, House[h][Ex], House[h][Ey], House[h][Ez]))
  73.             {
  74.                 if(House[h][Lock] == 1) return SendClientMessage(playerid, COLOR_RED, "Дом закрыт! Если это ваш дом то откройте его через </house>");
  75.                 SendClientMessage(playerid, COLOR_WHITE, "Ты зашёл в дом!");
  76.                 SetPlayerPos(playerid, HInts[House[h][Int]][hiX], HInts[House[h][Int]][hiY], HInts[House[h][Int]][hiZ]);
  77.                 SetPlayerInterior(playerid, HInts[House[h][Int]][hiInt]);
  78.                 SetPlayerVirtualWorld(playerid, House[h][Vw]);
  79.                 inHouse[playerid] = 1;
  80.                 PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
  81.                 return 1;
  82.             }
  83.             else if(IsPlayerInRangeOfPoint(playerid, 1.0, HInts[House[h][Int]][hiX], HInts[House[h][Int]][hiY], HInts[House[h][Int]][hiZ]))
  84.             {
  85.                 SendClientMessage(playerid, COLOR_WHITE, "Ты вышел из дома!");
  86.                 inHouse[playerid] = 0;
  87.                 SetPlayerInterior(playerid, 0);
  88.                 SetPlayerVirtualWorld(playerid, 0);
  89.                 SetPlayerPos(playerid, House[h][Ex], House[h][Ey], House[h][Ez]);
  90.                 PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
  91.                 return 1;
  92.             }
  93.         }
  94.     }
  95.     else if(newkeys & KEY_YES)
  96.     {
  97.         mysql_query(connects, "SELECT * FROM `house`");
  98.         new rows, fields;
  99.         cache_get_data(rows, fields);
  100.         for(new h; h < rows; h++)
  101.         {
  102.             if(!IsPlayerInRangeOfPoint(playerid, 1.0, House[h][Ex], House[h][Ey], House[h][Ez])) continue;
  103.             if(!strcmp(House[h][Owner], "The State"))
  104.             {
  105.                 if(Player[playerid][pMoney] < House[h][Price]) return SendClientMessage(playerid, COLOR_RED, "У вас недостаточно денег для покупки этого дома!");
  106.                 Player[playerid][pMoney] -= House[h][Price];
  107.                 format(House[h][Owner], 24, "%s", Player[playerid][pName]);
  108.                 SendClientMessage(playerid,-1,"Вы успешно купили дом!");
  109.                 PlayerPlaySound(playerid,1054,0.0,0.0,0.0);
  110.                 UpdateHouse(h);
  111.                 SaveHouses(h);
  112.                 return 1;
  113.             }
  114.             SendClientMessage(playerid, COLOR_RED, "Этот дом уже куплен!");
  115.             return 1;
  116.         }
  117.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement