Advertisement
Guest User

S32_House

a guest
Nov 6th, 2011
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 82.27 KB | None | 0 0
  1. /*
  2.  * S32_House - Create house with just one line (MySQL)!
  3.  * Copyright(c)System32
  4.  * This file is provided as is (no warranties)
  5.  
  6.  
  7.  * I started developing this include a 2-3 months ago but I had a big problems, now it's fixed and everything works!
  8.  * Functions: 38
  9.  * Commands: 11
  10.  * Credits:
  11.      * System32 - Almost everything!
  12.      * The Guy - Helped me a lot, thank you!
  13.      * Y_Less - y_hooks, y_commands & sscanf!
  14.      * G-Stylezz (BlueG) - MySQL plugin!
  15.      * Some guy on forums like wups, Y_Less - helped me with some things!
  16.  * That is basically it, have fun with this include and easy scripting!
  17.  */
  18.  
  19. #if !defined _inc_a_samp
  20.     #include <a_samp>
  21. #endif
  22. #if !defined _inc_a_mysql
  23.     #include <a_mysql>
  24. #endif
  25. #include <YSI\y_hooks>
  26. #include <YSI\y_commands>
  27.  
  28. #define MAX_HOUSES 150
  29. #define house_version "v1.0.0"
  30.  
  31. #define COLOR_LIME                                              0x10F441AA
  32. #define COLOR_KRED                                              0xFF0000FF
  33. #define COLOR_YELLOW                                            0xFFFF00AA
  34.  
  35. enum hInfo
  36. {
  37.     hOwner[24],
  38.     Float: hEnterX,
  39.     Float: hEnterY,
  40.     Float: hEnterZ,
  41.     Float: hExitX,
  42.     Float: hExitY,
  43.     Float: hExitZ,
  44.     hInterior,
  45.     hPrice,
  46.     hVirtualWorld,
  47.     hOwned,
  48.     hLocked,
  49.     Text3D:hLabel,
  50.     hPickup,
  51.     hWeaponID1,
  52.     hWeaponID2,
  53.     hWeaponID3,
  54.     hWeaponID1Ammo,
  55.     hWeaponID2Ammo,
  56.     hWeaponID3Ammo,
  57.     hMoney,
  58.     hRentUser[24],
  59.     hRentPrice,
  60.     hRented,
  61.     hRentDisabled,
  62. };
  63. new HouseInfo[MAX_HOUSES][hInfo];
  64.  
  65. new hstring[128], HQuery[3000], HouseID, hsavingstring[4000], string[128], House_Weapon[MAX_PLAYERS][13], House_Ammo[MAX_PLAYERS][13];
  66. new bool: PlayerEnteredHisHouse[MAX_PLAYERS] = false;
  67.  
  68. forward OnPlayerEnterHouse(playerid, houseid);
  69. forward OnPlayerExitHouse(playerid, houseid);
  70. forward RentFeeUp();
  71.  
  72. //*****************************           *****************************
  73. //***************************** FUNCTIONS *****************************
  74. //*****************************           *****************************
  75.  
  76.  
  77.  
  78.  
  79. /*
  80.  
  81.  • Function: CreateHouse(Float: EnterX, Float: EnterY, Float: EnterZ, Interior, Float: InteriorX, Float: InteriorY, Float: InteriorZ, Price, VirtualWorld, RentPrice)
  82.  • Data storage: MySQL (G-Stylezzz's plugin)
  83.  • Usage: Creating house, use this in OnGameModeInit or OnFilterScriptInit!
  84.  • Parameters:
  85.         EnterX, EnterY, EnterZ: Coordinates where you can enter house, also on that coordiantes will create pickup and 3D text!
  86.         ExitX, ExitY, ExitZ: Coordinates where you can exit house, this coordinates are coordiantes of interior, you can find interiors on http://weedarr.wikidot.com/interior or http://wiki.sa-mp.com/wiki/InteriorIDs
  87.         Interior: ID od interior you want, see the web page on the parameter above
  88.         Price: Price for buying house
  89.         VirtulWorld: Always increase this because if you have 2 same interior and player are in the (Example one is in his house, second is in his too) they will see themself, It will look that they have same house! (Bad explained :/)
  90.         RentPrice: Price for renting house, when player buy house maximum rent price is 10000 so, if you put it 20000 than he change it, he won't be able to set it again on 20000
  91.  • Example: CreateHouse(-2521.3315,-623.4722,132.7717, 3, 1527.229980,-11.574499,1002.097106, 1000, 0, 5000);
  92.  
  93. */
  94.  
  95. stock CreateHouse(Float: EnterX, Float: EnterY, Float: EnterZ, Interior, Float: ExitX, Float: ExitY, Float: ExitZ, Price, VirtualWorld, RentPrice)
  96. {
  97.     format(HQuery, sizeof(HQuery), "SELECT * FROM `house` WHERE `HouseID` = %d", HouseID);
  98.     mysql_query(HQuery);
  99.     mysql_store_result();
  100.     if(mysql_num_rows() == 0)
  101.     {
  102.         format(HouseInfo[HouseID][hOwner], 24, "None");
  103.         format(HouseInfo[HouseID][hRentUser], 24, "None");
  104.         HouseInfo[HouseID][hEnterX] = EnterX;
  105.         HouseInfo[HouseID][hEnterY] = EnterY;
  106.         HouseInfo[HouseID][hEnterZ] = EnterZ;
  107.         HouseInfo[HouseID][hExitX] = ExitX;
  108.         HouseInfo[HouseID][hExitY] = ExitY;
  109.         HouseInfo[HouseID][hExitZ] = ExitZ;
  110.         HouseInfo[HouseID][hInterior] = Interior;
  111.         HouseInfo[HouseID][hVirtualWorld] = VirtualWorld;
  112.         HouseInfo[HouseID][hPrice] = Price;
  113.         HouseInfo[HouseID][hRentPrice] = RentPrice;
  114.         format(hstring, sizeof(hstring), "For sale!\nPrice: %d\nHouse ID: %d\nType /buyhouse to buy house!", Price, HouseID);
  115.         format(HQuery, sizeof(HQuery), "INSERT INTO `house` (`User`, `EnterX`, `EnterY`, `EnterZ`, `ExitX`, `ExitY`, `ExitZ`, `Interior`, `Price`, `VirtualWorld`, `Owned`, `Locked`, `Weapon ID 1`, `Weapon ID 2`, `Weapon ID 3`, `Weapon ID 1 Ammo`, `Weapon ID 2 Ammo`, `Weapon ID 3 Ammo`, `Money`, `Rent User`, `Rent Price`, `Rented`, `Rent Disabled`, `HouseID`) VALUES");
  116.         format(HQuery, sizeof(HQuery), "%s  ('None', %f, %f, %f, %f, %f, %f, %d, %d, %d, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'None', %d, 0, 0, %d)", HQuery, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], HouseInfo[HouseID][hExitX], HouseInfo[HouseID][hExitY], HouseInfo[HouseID][hExitZ], HouseInfo[HouseID][hInterior], HouseInfo[HouseID][hPrice], HouseInfo[HouseID][hVirtualWorld], HouseInfo[HouseID][hRentPrice], HouseID);
  117.         mysql_query(HQuery);
  118.         HouseInfo[HouseID][hLabel] = Create3DTextLabel(hstring, 0x21DD00FF, EnterX, EnterY, EnterZ, 40.0, 0);
  119.         HouseInfo[HouseID][hPickup] = CreatePickup(1273, 23, EnterX, EnterY, EnterZ, 0);
  120.     }
  121.     else
  122.     {
  123.         if(mysql_fetch_row_format(HQuery, "|"))
  124.         {
  125.             mysql_fetch_field_row(hsavingstring, "User"); format(HouseInfo[HouseID][hOwner], 24, "%s", hsavingstring);
  126.             mysql_fetch_field_row(hsavingstring, "EnterX"); HouseInfo[HouseID][hEnterX] = floatstr(hsavingstring);
  127.             mysql_fetch_field_row(hsavingstring, "EnterY"); HouseInfo[HouseID][hEnterY] = floatstr(hsavingstring);
  128.             mysql_fetch_field_row(hsavingstring, "EnterZ"); HouseInfo[HouseID][hEnterZ] = floatstr(hsavingstring);
  129.             mysql_fetch_field_row(hsavingstring, "ExitX"); HouseInfo[HouseID][hExitX] = floatstr(hsavingstring);
  130.             mysql_fetch_field_row(hsavingstring, "ExitY"); HouseInfo[HouseID][hExitY] = floatstr(hsavingstring);
  131.             mysql_fetch_field_row(hsavingstring, "ExitZ"); HouseInfo[HouseID][hExitZ] = floatstr(hsavingstring);
  132.             mysql_fetch_field_row(hsavingstring, "Interior"); HouseInfo[HouseID][hInterior] = strval(hsavingstring);
  133.             mysql_fetch_field_row(hsavingstring, "Price"); HouseInfo[HouseID][hPrice] = strval(hsavingstring);
  134.             mysql_fetch_field_row(hsavingstring, "VirtualWorld"); HouseInfo[HouseID][hVirtualWorld] = strval(hsavingstring);
  135.             mysql_fetch_field_row(hsavingstring, "Owned"); HouseInfo[HouseID][hOwned] = strval(hsavingstring);
  136.             mysql_fetch_field_row(hsavingstring, "Locked"); HouseInfo[HouseID][hLocked] = strval(hsavingstring);
  137.             mysql_fetch_field_row(hsavingstring, "Weapon ID 1"); HouseInfo[HouseID][hWeaponID1] = strval(hsavingstring);
  138.             mysql_fetch_field_row(hsavingstring, "Weapon ID 2"); HouseInfo[HouseID][hWeaponID2] = strval(hsavingstring);
  139.             mysql_fetch_field_row(hsavingstring, "Weapon ID 3"); HouseInfo[HouseID][hWeaponID3] = strval(hsavingstring);
  140.             mysql_fetch_field_row(hsavingstring, "Weapon ID 1 Ammo"); HouseInfo[HouseID][hWeaponID1Ammo] = strval(hsavingstring);
  141.             mysql_fetch_field_row(hsavingstring, "Weapon ID 2 Ammo"); HouseInfo[HouseID][hWeaponID2Ammo] = strval(hsavingstring);
  142.             mysql_fetch_field_row(hsavingstring, "Weapon ID 3 Ammo"); HouseInfo[HouseID][hWeaponID3Ammo] = strval(hsavingstring);
  143.             mysql_fetch_field_row(hsavingstring, "Money"); HouseInfo[HouseID][hMoney] = strval(hsavingstring);
  144.             mysql_fetch_field_row(hsavingstring, "Rent User"); format(HouseInfo[HouseID][hRentUser], 24, "%s", hsavingstring);
  145.             mysql_fetch_field_row(hsavingstring, "Rent Price"); HouseInfo[HouseID][hRentPrice] = strval(hsavingstring);
  146.             mysql_fetch_field_row(hsavingstring, "Rented"); HouseInfo[HouseID][hRented] = strval(hsavingstring);
  147.             mysql_fetch_field_row(hsavingstring, "Rent Disabled"); HouseInfo[HouseID][hRentDisabled] = strval(hsavingstring);
  148.             if(HouseInfo[HouseID][hOwned] == 1)
  149.             {
  150.                 if(HouseInfo[HouseID][hRentDisabled] == 0)
  151.                 {
  152.                     format(hstring, sizeof(hstring), "Owner: %s\nHouse ID: %d\nRent User: %s\nRent Price: %d", HouseInfo[HouseID][hOwner], HouseID, HouseInfo[HouseID][hRentUser], HouseInfo[HouseID][hRentPrice]);
  153.                     HouseInfo[HouseID][hLabel] = Create3DTextLabel(hstring, 0x21DD00FF, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], 40.0, 0);
  154.                     HouseInfo[HouseID][hPickup] = CreatePickup(1239, 23, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], 0);
  155.                 }
  156.                 else
  157.                 {
  158.                     format(hstring, sizeof(hstring), "Owner: %s\nHouse ID: %d\nRent Disabled", HouseInfo[HouseID][hOwner], HouseID);
  159.                     HouseInfo[HouseID][hLabel] = Create3DTextLabel(hstring, 0x21DD00FF, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], 40.0, 0);
  160.                     HouseInfo[HouseID][hPickup] = CreatePickup(1239, 23, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], 0);
  161.                 }
  162.             }
  163.             else
  164.             {
  165.                 format(hstring, sizeof(hstring), "For sale!\nPrice: %d\nHouse ID: %d\nType /buyhouse to buy house!", Price, HouseID);
  166.                 HouseInfo[HouseID][hLabel] = Create3DTextLabel(hstring, 0x21DD00FF, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], 40.0, 0);
  167.                 HouseInfo[HouseID][hPickup] = CreatePickup(1273, 23, HouseInfo[HouseID][hEnterX], HouseInfo[HouseID][hEnterY], HouseInfo[HouseID][hEnterZ], 0);
  168.             }
  169.         }
  170.     }
  171.     mysql_free_result();
  172.     HouseID++;
  173.     if(HouseID > MAX_HOUSES)
  174.     {
  175.         print("You reached maximum number of houses! Please enlarge the #define MAX_HOUSES\nin S32_House.inc! If you don't enlarge it, some houses won't work properly!");
  176.     }
  177.     return 1;
  178. }
  179.  
  180.  
  181.  
  182. /*
  183.  
  184.  • Function: GetHouseUser(houseid)
  185.  • Usage: Getting name of user of specific house!
  186.  • Parameters:
  187.         houseid: ID of house that you want to get user (owner)
  188.  • Example: format(string, sizeof(string), "House user of house id %d is %s", houseid, GetHouseUser(houseid));
  189.  
  190. */
  191.  
  192. stock GetHouseUser(houseid)
  193. {
  194.     new howner[24];
  195.     format(howner, sizeof(howner), "%s", HouseInfo[houseid][hOwner]);
  196.     return howner;
  197. }
  198.  
  199.  
  200.  
  201. /*
  202.  
  203.  • Function: GetHouseRentUser(houseid)
  204.  • Usage: Getting name of rent user of specific house!
  205.  • Parameters:
  206.         houseid: ID of house that you want to get rent user
  207.  • Example: format(string, sizeof(string), "House rent user of house id %d is %s", houseid, GetHouseRentUser(houseid));
  208.  
  209. */
  210.  
  211. stock GetHouseRentUser(houseid)
  212. {
  213.     new howner[24];
  214.     format(howner, sizeof(howner), "%s", HouseInfo[houseid][hRentUser]);
  215.     return howner;
  216. }
  217.  
  218.  
  219.  
  220. /*
  221.  
  222.  • Function: GetHouseEnterPos(houseid)
  223.  • Usage: Getting the enter position (XYZ) of specific house!
  224.  • Parameters:
  225.         houseid: ID of house that you want to get enter position
  226.  • Example: format(string, sizeof(string), "House enter XYZ of house id %d is %s", houseid, GetHouseEnterPos(houseid));
  227.  
  228. */
  229.  
  230. stock GetHouseEnterPos(houseid)
  231. {
  232.     new getxyz[128];
  233.     format(getxyz, sizeof(getxyz), "%f, %f, %f", HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ]);
  234.     return getxyz;
  235. }
  236.  
  237.  
  238.  
  239. /*
  240.  
  241.  • Function: GetHouseExitPos(houseid)
  242.  • Usage: Getting the exit position (XYZ) of specific house!
  243.  • Parameters:
  244.         houseid: ID of house that you want to get exit position
  245.  • Example: format(string, sizeof(string), "House exit XYZ of house id %d is %s", houseid, GetHouseExitPos(houseid));
  246.  
  247. */
  248.  
  249. stock GetHouseExitPos(houseid)
  250. {
  251.     new getxyz[128];
  252.     format(getxyz, sizeof(getxyz), "%f, %f, %f", HouseInfo[houseid][hExitX], HouseInfo[houseid][hExitY], HouseInfo[houseid][hExitZ]);
  253.     return getxyz;
  254. }
  255.  
  256.  
  257.  
  258. /*
  259.  
  260.  • Function: GetHouseEnterX(houseid)
  261.  • Usage: Getting the enter X position of specific house!
  262.  • Parameters:
  263.         houseid: ID of house that you want to get enter X position
  264.  • Example: format(string, sizeof(string), "House enter X of house id %d is %s", houseid, GetHouseEnterX(houseid));
  265.  
  266. */
  267.  
  268. stock GetHouseEnterX(houseid)
  269. {
  270.     new getx[128];
  271.     format(getx, sizeof(getx), "%f", HouseInfo[houseid][hEnterX]);
  272.     return getx;
  273. }
  274.  
  275.  
  276.  
  277. /*
  278.  
  279.  • Function: GetHouseEnterY(houseid)
  280.  • Usage: Getting the enter Y position of specific house!
  281.  • Parameters:
  282.         houseid: ID of house that you want to get enter Y position
  283.  • Example: format(string, sizeof(string), "House enter Y of house id %d is %s", houseid, GetHouseEnterY(houseid));
  284.  
  285. */
  286.  
  287. stock GetHouseEnterY(houseid)
  288. {
  289.     new gety[128];
  290.     format(gety, sizeof(gety), "%f", HouseInfo[houseid][hEnterY]);
  291.     return gety;
  292. }
  293.  
  294.  
  295.  
  296. /*
  297.  
  298.  • Function: GetHouseEnterZ(houseid)
  299.  • Usage: Getting the enter Z position of specific house!
  300.  • Parameters:
  301.         houseid: ID of house that you want to get enter Z position
  302.  • Example: format(string, sizeof(string), "House enter Z of house id %d is %s", houseid, GetHouseEnterZ(houseid));
  303.  
  304. */
  305.  
  306. stock GetHouseEnterZ(houseid)
  307. {
  308.     new getz[128];
  309.     format(getz, sizeof(getz), "%f", HouseInfo[houseid][hEnterZ]);
  310.     return getz;
  311. }
  312.  
  313.  
  314.  
  315. /*
  316.  
  317.  • Function: GetHouseExitX(houseid)
  318.  • Usage: Getting the enter X position of specific house!
  319.  • Parameters:
  320.         houseid: ID of house that you want to get enter X position
  321.  • Example: format(string, sizeof(string), "House exit X of house id %d is %s", houseid, GetHouseExitX(houseid));
  322.  
  323. */
  324.  
  325. stock GetHouseExitX(houseid)
  326. {
  327.     new getx[128];
  328.     format(getx, sizeof(getx), "%f", HouseInfo[houseid][hExitX]);
  329.     return getx;
  330. }
  331.  
  332.  
  333.  
  334. /*
  335.  
  336.  • Function: GetHouseExitY(houseid)
  337.  • Usage: Getting the enter Y position of specific house!
  338.  • Parameters:
  339.         houseid: ID of house that you want to get enter Y position
  340.  • Example: format(string, sizeof(string), "House exit Y of house id %d is %s", houseid, GetHouseExitY(houseid));
  341.  
  342. */
  343.  
  344. stock GetHouseExitY(houseid)
  345. {
  346.     new gety[128];
  347.     format(gety, sizeof(gety), "%f", HouseInfo[houseid][hExitY]);
  348.     return gety;
  349. }
  350.  
  351.  
  352.  
  353. /*
  354.  
  355.  • Function: GetHouseExitZ(houseid)
  356.  • Usage: Getting the enter Z position of specific house!
  357.  • Parameters:
  358.         houseid: ID of house that you want to get enter Z position
  359.  • Example: format(string, sizeof(string), "House exit Z of house id %d is %s", houseid, GetHouseExitZ(houseid));
  360.  
  361. */
  362.  
  363. stock GetHouseExitZ(houseid)
  364. {
  365.     new getz[128];
  366.     format(getz, sizeof(getz), "%f", HouseInfo[houseid][hExitZ]);
  367.     return getz;
  368. }
  369.  
  370.  
  371.  
  372. /*
  373.  
  374.  • Function: GetHousePrice(houseid)
  375.  • Usage: Getting the price of specific house!
  376.  • Parameters:
  377.         houseid: ID of house that you want to get price
  378.  • Example: format(string, sizeof(string), "House price of house id %d is %d", houseid, GetHousePrice(houseid));
  379.  
  380. */
  381.  
  382. stock GetHousePrice(houseid) return HouseInfo[houseid][hPrice];
  383.  
  384.  
  385.  
  386. /*
  387.  
  388.  • Function: GetHouseInterior(houseid)
  389.  • Usage: Getting the interior of specific house!
  390.  • Parameters:
  391.         houseid: ID of house that you want to get interior
  392.  • Example: format(string, sizeof(string), "House interior of house id %d is %d", houseid, GetHouseInterior(houseid));
  393.  
  394. */
  395.  
  396. stock GetHouseInterior(houseid) return HouseInfo[houseid][hInterior];
  397.  
  398.  
  399.  
  400. /*
  401.  
  402.  • Function: GetHouseVirtualWorld(houseid)
  403.  • Usage: Getting the virtualworld of specific house!
  404.  • Parameters:
  405.         houseid: ID of house that you want to get virtualworld
  406.  • Example: format(string, sizeof(string), "House virtualworld of house id %d is %d", houseid, GetHouseVirtualWorld(houseid));
  407.  
  408. */
  409.  
  410. stock GetHouseVirtualWorld(houseid) return HouseInfo[houseid][hVirtualWorld];
  411.  
  412.  
  413.  
  414. /*
  415.  
  416.  • Function: GetHouseRentPrice(houseid)
  417.  • Usage: Getting the rent price of specific house!
  418.  • Parameters:
  419.         houseid: ID of house that you want to get rent price
  420.  • Example: format(string, sizeof(string), "House rent priceof house id %d is %d", houseid, GetHouseRentPrice(houseid));
  421.  
  422. */
  423.  
  424. stock GetHouseRentPrice(houseid) return HouseInfo[houseid][hRentPrice];
  425.  
  426.  
  427.  
  428. /*
  429.  
  430.  • Function: GetHouseMoney(houseid)
  431.  • Usage: Getting the money (stored money) of specific house!
  432.  • Parameters:
  433.         houseid: ID of house that you want to get money
  434.  • Example: format(string, sizeof(string), "House money of house id %d is %d", houseid, GetHouseMoney(houseid));
  435.  
  436. */
  437.  
  438. stock GetHouseMoney(houseid) return HouseInfo[houseid][hMoney];
  439.  
  440.  
  441.  
  442. /*
  443.  
  444.  • Function: GetHouseWeaponID1(houseid)
  445.  • Usage: Getting the weapon id 1 of specific house!
  446.  • Parameters:
  447.         houseid: ID of house that you want to get the weapon id 1
  448.  • Example: format(string, sizeof(string), "House weapon id 1 of house id %d is %d", houseid, GetHouseWeaponID1(houseid));
  449.  
  450. */
  451.  
  452. stock GetHouseWeaponID1(houseid) return HouseInfo[houseid][hWeaponID1];
  453.  
  454.  
  455.  
  456. /*
  457.  
  458.  • Function: GetHouseWeaponID2(houseid)
  459.  • Usage: Getting the weapon id 2 of specific house!
  460.  • Parameters:
  461.         houseid: ID of house that you want to get the weapon id 2
  462.  • Example: format(string, sizeof(string), "House weapon id 2 of house id %d is %d", houseid, GetHouseWeaponID2(houseid));
  463.  
  464. */
  465. stock GetHouseWeaponID2(houseid) return HouseInfo[houseid][hWeaponID2];
  466.  
  467.  
  468.  
  469. /*
  470.  
  471.  • Function: GetHouseWeaponID3(houseid)
  472.  • Usage: Getting the weapon id 3 of specific house!
  473.  • Parameters:
  474.         houseid: ID of house that you want to get the weapon id 3
  475.  • Example: format(string, sizeof(string), "House weapon id 3 of house id %d is %d", houseid, GetHouseWeaponID3(houseid));
  476.  
  477. */
  478.  
  479. stock GetHouseWeaponID3(houseid) return HouseInfo[houseid][hWeaponID3];
  480.  
  481.  
  482.  
  483. /*
  484.  
  485.  • Function: GetHouseWeaponID1Ammo(houseid)
  486.  • Usage: Getting the weapon id 1 of specific house!
  487.  • Parameters:
  488.         houseid: ID of house that you want to get the weapon id 1 ammo
  489.  • Example: format(string, sizeof(string), "House weapon id 1 ammo of house id %d is %d", houseid, GetHouseWeaponID1Ammo(houseid));
  490.  
  491. */
  492.  
  493. stock GetHouseWeaponID1Ammo(houseid) return HouseInfo[houseid][hWeaponID1Ammo];
  494.  
  495.  
  496.  
  497. /*
  498.  
  499.  • Function: GetHouseWeaponID2Ammo(houseid)
  500.  • Usage: Getting the weapon id 2 of specific house!
  501.  • Parameters:
  502.         houseid: ID of house that you want to get the weapon id 2 ammo
  503.  • Example: format(string, sizeof(string), "House weapon id 2 ammo of house id %d is %d", houseid, GetHouseWeaponID2Ammo(houseid));
  504.  
  505. */
  506.  
  507. stock GetHouseWeaponID2Ammo(houseid) return HouseInfo[houseid][hWeaponID2Ammo];
  508.  
  509.  
  510.  
  511. /*
  512.  
  513.  • Function: GetHouseWeaponID3Ammo(houseid)
  514.  • Usage: Getting the weapon id 3 of specific house!
  515.  • Parameters:
  516.         houseid: ID of house that you want to get the weapon id 3 ammo
  517.  • Example: format(string, sizeof(string), "House weapon id 3 ammo of house id %d is %d", houseid, GetHouseWeaponID3Ammo(houseid));
  518.  
  519. */
  520.  
  521. stock GetHouseWeaponID3Ammo(houseid) return HouseInfo[houseid][hWeaponID3Ammo];
  522.  
  523.  
  524.  
  525. /*
  526.  
  527.  • Function: GetHouseWeaponID1Name(houseid)
  528.  • Usage: Getting the name of weapon id 1 of specific house!
  529.  • Parameters:
  530.         houseid: ID of house that you want to get the name of weapon id 1
  531.  • Example: format(string, sizeof(string), "House name of weapon id 1 of house id %d is %d", houseid, GetHouseWeaponID1Name(houseid));
  532.  
  533. */
  534.  
  535. stock GetHouseWeaponID1Name(houseid)
  536. {
  537.     new weaponid[128], weaponid2[128];
  538.     format(weaponid, sizeof(weaponid), "%s", GetWeapon(HouseInfo[houseid][hWeaponID1]));
  539.     format(weaponid2, sizeof(weaponid2), "Nothing");
  540.     if(HouseInfo[houseid][hWeaponID1] > 0) return weaponid;
  541.     else return weaponid2;
  542. }
  543.  
  544.  
  545.  
  546. /*
  547.  
  548.  • Function: GetHouseWeaponID2Name(houseid)
  549.  • Usage: Getting the name of weapon id 2 of specific house!
  550.  • Parameters:
  551.         houseid: ID of house that you want to get the name of weapon id 2
  552.  • Example: format(string, sizeof(string), "House name of weapon id 2 of house id %d is %d", houseid, GetHouseWeaponID2Name(houseid));
  553.  
  554. */
  555.  
  556. stock GetHouseWeaponID2Name(houseid)
  557. {
  558.     new weaponid[128], weaponid2[128];
  559.     format(weaponid, sizeof(weaponid), "%s", GetWeapon(HouseInfo[houseid][hWeaponID2]));
  560.     format(weaponid2, sizeof(weaponid2), "Nothing");
  561.     if(HouseInfo[houseid][hWeaponID2] > 0) return weaponid;
  562.     else return weaponid2;
  563. }
  564.  
  565.  
  566.  
  567. /*
  568.  
  569.  • Function: GetHouseWeaponID13Name(houseid)
  570.  • Usage: Getting the name of weapon id 3 of specific house!
  571.  • Parameters:
  572.         houseid: ID of house that you want to get the name of weapon id 3
  573.  • Example: format(string, sizeof(string), "House name of weapon id 3 of house id %d is %d", houseid, GetHouseWeaponID3Name(houseid));
  574.  
  575. */
  576.  
  577. stock GetHouseWeaponID3Name(houseid)
  578. {
  579.     new weaponid[128], weaponid2[128];
  580.     format(weaponid, sizeof(weaponid), "%s", GetWeapon(HouseInfo[houseid][hWeaponID3]));
  581.     format(weaponid2, sizeof(weaponid2), "Nothing");
  582.     if(HouseInfo[houseid][hWeaponID3] > 0) return weaponid;
  583.     else return weaponid2;
  584. }
  585.  
  586.  
  587.  
  588. /*
  589.  
  590.  • Function: IsHouseOwned(houseid)
  591.  • Usage: Checking if is house owned of specific house!
  592.  • Parameters:
  593.         houseid: ID of house that you want to check if is owned
  594.  • Example: if(IsHouseOwned(houseid)) return SendClientMessage(playerid, -1, "House is owned!");
  595.             else SendClientMessage(playerid, -1, "House is not owned!");
  596.  
  597. */
  598.  
  599. stock IsHouseOwned(houseid)
  600. {
  601.     if(HouseInfo[houseid][hOwned] == 1) return 1;
  602.     else return 0;
  603. }
  604.  
  605.  
  606.  
  607. /*
  608.  
  609.  • Function: IsHouseLocked(houseid)
  610.  • Usage: Checking if is house locked of specific house!
  611.  • Parameters:
  612.         houseid: ID of house that you want to check if is locked
  613.  • Example: if(IsHouseLocked(houseid)) return SendClientMessage(playerid, -1, "House is locked!");
  614.             else SendClientMessage(playerid, -1, "House is not locked!");
  615.  
  616. */
  617.  
  618. stock IsHouseLocked(houseid)
  619. {
  620.     if(HouseInfo[houseid][hLocked] == 1) return 1;
  621.     else return 0;
  622. }
  623.  
  624.  
  625.  
  626. /*
  627.  
  628.  • Function: IsHouseRented(houseid)
  629.  • Usage: Checking if is house owned of specific house!
  630.  • Parameters:
  631.         houseid: ID of house that you want to check if is rented
  632.  • Example: if(IsHouseRented(houseid)) return SendClientMessage(playerid, -1, "House is rented!");
  633.             else SendClientMessage(playerid, -1, "House is not rented!");
  634.  
  635. */
  636.  
  637. stock IsHouseRented(houseid)
  638. {
  639.     if(HouseInfo[houseid][hRented] == 1) return 1;
  640.     else return 0;
  641. }
  642.  
  643.  
  644.  
  645. /*
  646.  
  647.  • Function: IsHouseRentDisabled(houseid)
  648.  • Usage: Checking if is house owned of specific house!
  649.  • Parameters:
  650.         houseid: ID of house that you want to check if is rent disabled
  651.  • Example: if(IsHouseRentDisabled(houseid)) return SendClientMessage(playerid, -1, "House rent is disabled!");
  652.             else SendClientMessage(playerid, -1, "House rent is not disabled!");
  653.  
  654. */
  655.  
  656. stock IsHouseRentDisabled(houseid)
  657. {
  658.     if(HouseInfo[houseid][hRentDisabled] == 1) return 1;
  659.     else return 0;
  660. }
  661.  
  662.  
  663.  
  664. /*
  665.  
  666.  • Function: IsPlayerHouseOwner(playerid, houseid)
  667.  • Usage: Checking if is player owner of specific house!
  668.  • Parameters:
  669.         playerid: ID of player that you want preform check
  670.         houseid: ID of house that you want to check if is player owner
  671.  • Example: if(IsPlayerHouseOwner(playerid, houseid)) return SendClientMessage(playerid, -1, "You are owner of the house!");
  672.             else SendClientMessage(playerid, -1, "You are not owner of the house!");
  673.  
  674. */
  675.  
  676. stock IsPlayerHouseOwner(playerid, houseid)
  677. {
  678.     if(!strcmp(HouseInfo[houseid][hOwner], GetName(playerid), false)) return 1;
  679.     else return 0;
  680. }
  681.  
  682.  
  683.  
  684. /*
  685.  
  686.  • Function: IsPlayerBuyAnyHouse(playerid)
  687.  • Usage: Checking if is player buyed house and he is owner of any house (used when you try to rent room but you already have house)!
  688.  • Parameters:
  689.         playerid: ID of player that you want preform check
  690.  • Example: if(IsPlayerBuyAnyHouse(playerid)) return SendClientMessage(playerid, -1, "You have house already!");
  691.             else SendClientMessage(playerid, -1, "You don't have house!");
  692.  
  693. */
  694.  
  695. stock IsPlayerBuyAnyHouse(playerid)
  696. {
  697.     new HQuery2[200];
  698.     format(HQuery2, sizeof(HQuery2), "SELECT User FROM `house` WHERE `User` = '%s'", GetName(playerid));
  699.     mysql_query(HQuery2);
  700.     mysql_store_result();
  701.     if(mysql_num_rows() == 1)
  702.     {
  703.         mysql_free_result();
  704.         return 1;
  705.     }
  706.     else
  707.     {
  708.         mysql_free_result();
  709.         return 0;
  710.     }
  711. }
  712.  
  713.  
  714.  
  715. /*
  716.  
  717.  • Function: IsPlayerRentAnyHouse(playerid)
  718.  • Usage: Checking if is player rented house and he is rent user of any house (used when you try to rent room but you already rented some house)!
  719.  • Parameters:
  720.         playerid: ID of player that you want preform check
  721.  • Example: if(IsPlayerRentAnyHouse(playerid)) return SendClientMessage(playerid, -1, "You rent house already!");
  722.             else SendClientMessage(playerid, -1, "You don't rent house!");
  723.  
  724. */
  725.  
  726. stock IsPlayerRentAnyHouse(playerid)
  727. {
  728.     new HQuery2[200];
  729.     format(HQuery2, sizeof(HQuery2), "SELECT `Rent User` FROM `house` WHERE `Rent User` = '%s'", GetName(playerid));
  730.     mysql_query(HQuery2);
  731.     mysql_store_result();
  732.     if(mysql_num_rows() == 1)
  733.     {
  734.         mysql_free_result();
  735.         return 1;
  736.     }
  737.     else
  738.     {
  739.         mysql_free_result();
  740.         return 0;
  741.     }
  742. }
  743.  
  744.  
  745.  
  746. /*
  747.  
  748.  • Function: IsPlayerBuyHouse(playerid, houseid)
  749.  • Usage: Checking if is player rented house and he is rent user of any house (used when you try to rent room but you already rented some house)!
  750.  • Parameters:
  751.         playerid: ID of player that you want preform check
  752.         houseid: ID of house that you want to check if is player buy house
  753.  • Example: if(IsPlayerBuyHouse(playerid, houseid)) return SendClientMessage(playerid, -1, "You buy this house already!");
  754.             else SendClientMessage(playerid, -1, "You didn't buy rent this house!");
  755.  
  756. */
  757.  
  758. stock IsPlayerBuyHouse(playerid, houseid)
  759. {
  760.     new HQuery2[200];
  761.     format(HQuery2, sizeof(HQuery2), "SELECT User FROM `house` WHERE `User` = '%s' AND `HouseID` = %d", GetName(playerid), houseid);
  762.     mysql_query(HQuery2);
  763.     mysql_store_result();
  764.     if(mysql_num_rows() == 1)
  765.     {
  766.         mysql_free_result();
  767.         return 1;
  768.     }
  769.     else
  770.     {
  771.         mysql_free_result();
  772.         return 0;
  773.     }
  774. }
  775.  
  776.  
  777.  
  778. /*
  779.  
  780.  • Function: IsPlayerRentHouse(playerid, houseid)
  781.  • Usage: Checking if is player rented house and he is rent user of any house (used when you try to rent room but you already rented some house)!
  782.  • Parameters:
  783.         playerid: ID of player that you want preform check
  784.         houseid: ID of house that you want to check if is player rented user
  785.  • Example: if(IsPlayerRentAnyHouse(playerid, houseid)) return SendClientMessage(playerid, -1, "You rent this house already!");
  786.             else SendClientMessage(playerid, -1, "You don't rent this house!");
  787.  
  788. */
  789.  
  790. stock IsPlayerRentHouse(playerid, houseid)
  791. {
  792.     new HQuery2[200];
  793.     format(HQuery2, sizeof(HQuery2), "SELECT `Rent User` FROM `house` WHERE `Rent User` = '%s' AND `HouseID` = %d", GetName(playerid), houseid);
  794.     mysql_query(HQuery2);
  795.     mysql_store_result();
  796.     if(mysql_num_rows() == 1)
  797.     {
  798.         mysql_free_result();
  799.         return 1;
  800.     }
  801.     else
  802.     {
  803.         mysql_free_result();
  804.         return 0;
  805.     }
  806. }
  807.  
  808.  
  809.  
  810. /*
  811.  
  812.  • Function: IsHouseExist(houseid)
  813.  • Usage: Checking if is player rented house and he is rent user of any house (used when you try to rent room but you already rented some house)!
  814.  • Parameters:
  815.         houseid: ID of house that you want to check if is exist
  816.  • Example: if(IsHouseExist(houseid)) return SendClientMessage(playerid, -1, "House exist!");
  817.             else SendClientMessage(playerid, -1, "House doesn't exist!");
  818.  
  819. */
  820.  
  821. stock IsHouseExist(houseid)
  822. {
  823.     new HQuery2[200];
  824.     format(HQuery2, sizeof(HQuery2), "SELECT HouseID FROM `house` WHERE `HouseID` = '%d'", houseid);
  825.     mysql_query(HQuery2);
  826.     mysql_store_result();
  827.     if(mysql_num_rows() == 1)
  828.     {
  829.         mysql_free_result();
  830.         return 1;
  831.     }
  832.     else
  833.     {
  834.         mysql_free_result();
  835.         return 0;
  836.     }
  837. }
  838.  
  839.  
  840.  
  841. /*
  842.  
  843.  • Function: IsPlayerHouseRentUser(playerid, houseid)
  844.  • Usage: Checking if is player rent user of specific house!
  845.  • Parameters:
  846.         playerid: ID of player that you want preform check
  847.         houseid: ID of house that you want to check if is player rent user
  848.  • Example: if(IsPlayerHouseRentUser(playerid, houseid)) return SendClientMessage(playerid, -1, "You are rent user of the house!");
  849.             else SendClientMessage(playerid, -1, "You are not rent user of the house!");
  850.  
  851. */
  852.  
  853. stock IsPlayerHouseRentUser(playerid, houseid)
  854. {
  855.     if(!strcmp(HouseInfo[houseid][hRentUser], GetName(playerid), false)) return 1;
  856.     else return 0;
  857. }
  858.  
  859.  
  860.  
  861. /*
  862.  
  863.  • Function: IsHouseWeaponSlotFree(houseid, slot)
  864.  • Usage: Checking if is slot free in stored weapons of specific house!
  865.  • Parameters:
  866.         houseid: ID of house that you want to check if is slot free
  867.         slot: Slot of stored weapons from 1-3!
  868.  • Example: if(IsHouseWeaponSlotFree(houseid, 1)) return SendClientMessage(playerid, -1, "Slot 1 is free!");
  869.             else SendClientMessage(playerid, -1, "Slot 1 is not free!");
  870.  
  871. */
  872.  
  873. stock IsHouseWeaponSlotFree(houseid, slot)
  874. {
  875.     switch(slot)
  876.     {
  877.         case 1:
  878.         {
  879.             if(HouseInfo[houseid][hWeaponID1] < 1) return 1;
  880.             else return 0;
  881.         }
  882.         case 2:
  883.         {
  884.             if(HouseInfo[houseid][hWeaponID2] < 1) return 1;
  885.             else return 0;
  886.         }
  887.         case 3:
  888.         {
  889.             if(HouseInfo[houseid][hWeaponID3] < 1) return 1;
  890.             else return 0;
  891.         }
  892.     }
  893.     return slot;
  894. }
  895.  
  896.  
  897.  
  898. /*
  899.  
  900.  • Function: SpawnPlayerAtHouse(playerid)
  901.  • Usage: Spawning player at his house, use this in OnPlayerSpawn!
  902.  • Parameters:
  903.         playerid: ID of player that you want to spawn!
  904.  • Example: SpawnPlayerAtHouse(playerid);
  905.  
  906. */
  907.  
  908. stock SpawnPlayerAtHouse(playerid)
  909. {
  910.     for(new i = 0; i < MAX_HOUSES; i++)
  911.     {
  912.         if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false) || !strcmp(HouseInfo[i][hRentUser], GetName(playerid), false) && HouseInfo[i][hOwned] == 1)
  913.         {
  914.             new HQuery2[200];
  915.             format(HQuery2, sizeof(HQuery2), "SELECT HouseID FROM `house` WHERE `HouseID` = '%d'", i);
  916.             mysql_query(HQuery2);
  917.             mysql_store_result();
  918.             if(mysql_num_rows() == 1)
  919.             {
  920.                 SetPlayerPos(playerid, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]);
  921.                 SetPlayerInterior(playerid, HouseInfo[i][hInterior]);
  922.                 SetPlayerVirtualWorld(playerid, HouseInfo[i][hVirtualWorld]);
  923.                 PlayerEnteredHisHouse[playerid] = true;
  924.                 mysql_free_result();
  925.                 return 1;
  926.             }
  927.         }
  928.     }
  929.     return 0;
  930. }
  931.  
  932. //----Stocks for easier scripting!----
  933. stock GetName(playerid)
  934. {
  935.     new pName[MAX_PLAYER_NAME];
  936.     GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  937.     return pName;
  938. }
  939.  
  940. stock GetWeapon(weaponid)
  941. {
  942.     new gunname[32];
  943.     GetWeaponName(weaponid, gunname, sizeof(gunname));
  944.     return gunname;
  945. }
  946.  
  947. stock Custom_GetPlayerWeapon(playerid)
  948. {
  949.     for(new w = 0; w < 13; w++)
  950.     {
  951.         GetPlayerWeaponData(playerid, w, House_Weapon[playerid][w], House_Ammo[playerid][w]);
  952.     }
  953.     return 1;
  954. }
  955.  
  956. stock Custom_GetSlot(weaponid)
  957. {
  958.     new slot;
  959.     if(weaponid == 0 || weaponid == 1){slot = 0;}
  960.     else if(weaponid > 8 && weaponid < 10){slot = 1;}
  961.     else if(weaponid > 9 && weaponid < 16){slot = 10;}
  962.     else if(weaponid > 15 && weaponid < 20){slot = 8;}
  963.     else if(weaponid > 21 && weaponid < 25){slot = 2;}
  964.     else if(weaponid > 24 && weaponid < 28){slot = 3;}
  965.     else if(weaponid == 28 || weaponid == 29 || weaponid == 32){slot = 4;}
  966.     else if(weaponid == 30 || weaponid == 31){slot = 5;}
  967.     else if(weaponid == 33 || weaponid == 34){slot = 6;}
  968.     else if(weaponid > 34 || weaponid < 39){slot = 7;}
  969.     return slot;
  970. }
  971.  
  972. stock IsPlayerNearPlayer(playerid, playerid2, Float: radius)
  973. {
  974.     new Float: pPos[4];
  975.     GetPlayerPos(playerid2, pPos[0], pPos[1], pPos[2]);
  976.     if(IsPlayerInRangeOfPoint(playerid, radius, pPos[0], pPos[1], pPos[2])) return 1;
  977.     return 0;
  978. }
  979. //----End of stocks!----
  980.  
  981.  
  982. //*****************************          *****************************
  983. //***************************** COMMANDS *****************************
  984. //*****************************          *****************************
  985.  
  986.  
  987.  
  988.  
  989. /*
  990.  
  991.  • Command: /buyhouse
  992.  • Processor: y_commands (YCMD)
  993.  • Usage: Buying house (Player must be in range of house he want to buy!)
  994.  
  995. */
  996.  
  997. YCMD:buyhouse(playerid, params[], help)
  998. {
  999.     #pragma unused help
  1000.     #pragma unused params
  1001.     for(new i = 0; i < MAX_HOUSES; i++)
  1002.     {
  1003.         if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]))
  1004.         {
  1005.             if(HouseInfo[i][hOwned] == 1) return SendClientMessage(playerid, COLOR_KRED, "House is already owned!");
  1006.             if(GetPlayerMoney(playerid) < HouseInfo[i][hPrice]) return SendClientMessage(playerid, COLOR_KRED, "You don't have enough money!");
  1007.            
  1008.             new HQuery2[200];
  1009.             format(HQuery2, sizeof(HQuery2), "SELECT User FROM `house` WHERE `User` = '%s'", GetName(playerid));
  1010.             mysql_query(HQuery2);
  1011.             mysql_store_result();
  1012.             if(mysql_num_rows() == 1) return SendClientMessage(playerid, COLOR_KRED, "You have house already!");
  1013.             mysql_free_result();
  1014.  
  1015.             format(HouseInfo[i][hOwner], 24, "%s", GetName(playerid));
  1016.             HouseInfo[i][hOwned] = 1;
  1017.             DestroyPickup(HouseInfo[i][hPickup]);
  1018.             HouseInfo[i][hPickup] = CreatePickup(1239, 23, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ], 0);
  1019.             format(hstring, sizeof(hstring), "Owner: %s\nHouse ID: %d\nRent User: %s\nRent Price: %d", HouseInfo[i][hOwner], i, HouseInfo[i][hRentUser], HouseInfo[i][hRentPrice]);
  1020.             Update3DTextLabelText(HouseInfo[i][hLabel], 0x21DD00FF, hstring);
  1021.             GivePlayerMoney(playerid, -HouseInfo[i][hPrice]);
  1022.             SendClientMessage(playerid, COLOR_LIME, "House bought!");
  1023.            
  1024.             format(HQuery, sizeof(HQuery), "UPDATE `house` SET `User` = '%s', `Owned` = 1 WHERE `HouseID` = %d", GetName(playerid), i);
  1025.             mysql_query(HQuery);
  1026.         }
  1027.     }
  1028.     return 1;
  1029. }
  1030.  
  1031. /*
  1032.  
  1033.  • Command: /sellhouse
  1034.  • Processor: y_commands (YCMD)
  1035.  • Usage: Selling house (Player must be in range of house he want to sell!)
  1036.  
  1037. */
  1038.  
  1039. YCMD:sellhouse(playerid, params[], help)
  1040. {
  1041.     #pragma unused help
  1042.     #pragma unused params
  1043.     for(new i = 0; i < MAX_HOUSES; i++)
  1044.     {
  1045.         if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]))
  1046.         {
  1047.             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1048.             {
  1049.                 format(HouseInfo[i][hOwner], 24, "None");
  1050.                 format(HouseInfo[i][hRentUser], 24, "None");
  1051.                 HouseInfo[i][hOwned] = 0;
  1052.                 HouseInfo[i][hLocked] = 0;
  1053.                 HouseInfo[i][hRented] = 0;
  1054.                 DestroyPickup(HouseInfo[i][hPickup]);
  1055.                 HouseInfo[i][hPickup] = CreatePickup(1273, 23, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ], 0);
  1056.                 format(hstring, sizeof(hstring), "For sale!\nPrice: %d\nHouse ID: %d\nType /buyhouse to buy house!", HouseInfo[i][hPrice], i);
  1057.                 Update3DTextLabelText(HouseInfo[i][hLabel], 0x21DD00FF, hstring);
  1058.                 GivePlayerMoney(playerid, HouseInfo[i][hPrice]);
  1059.                 SendClientMessage(playerid, COLOR_LIME, "House sold!");
  1060.  
  1061.                 format(HQuery, sizeof(HQuery), "UPDATE `house` SET `User` = 'None', `Owned` = 0, `Locked` = 0, `Rent User` = 'None', `Rented` = 0 WHERE `HouseID` = %d", i);
  1062.                 mysql_query(HQuery);
  1063.             }
  1064.         }
  1065.     }
  1066.     return 1;
  1067. }
  1068.  
  1069. /*
  1070.  
  1071.  • Command: /sellhouseto
  1072.  • Processor: y_commands (YCMD)
  1073.  • Usage: Selling house to other player (must be near you!)
  1074.  • Parameters:
  1075.         id: The id of player you want to sell house
  1076.  
  1077. */
  1078.  
  1079. YCMD:sellhouseto(playerid, params[], help)
  1080. {
  1081.     #pragma unused help
  1082.     #pragma unused params
  1083.     new id, selltostring[128];
  1084.     for(new i = 0; i < MAX_HOUSES; i++)
  1085.     {
  1086.         if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]))
  1087.         {
  1088.             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1089.             {
  1090.                 if(sscanf(params, "i", id)) return SendClientMessage(playerid, -1, "Usage: /sellhouseto [ID]");
  1091.                 else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Invalid ID");
  1092.                 else if(id == playerid) return SendClientMessage(playerid, -1, "You can't sell house to yourself!");
  1093.                 if(!IsPlayerNearPlayer(playerid, id, 7.0)) return SendClientMessage(playerid, -1, "Player is not near you!");
  1094.                 format(selltostring, sizeof(selltostring), "Do you want to buy house from player %s for %d$?", GetName(playerid), HouseInfo[i][hPrice]);
  1095.                 ShowPlayerDialog(id, 5688, DIALOG_STYLE_MSGBOX, "  Buy house", selltostring, "Yes", "No");
  1096.                 SetPVarInt(id, "Seller", playerid);
  1097.             }
  1098.         }
  1099.     }
  1100.     return 1;
  1101. }
  1102.  
  1103. /*
  1104.  
  1105.  • Command: /lockhouse
  1106.  • Processor: y_commands (YCMD)
  1107.  • Usage: Locking house (Player must be in range of his house to lock it!)
  1108.  
  1109. */
  1110.  
  1111. YCMD:lockhouse(playerid, params[], help)
  1112. {
  1113.     #pragma unused help
  1114.     #pragma unused params
  1115.     for(new i = 0; i < MAX_HOUSES; i++)
  1116.     {
  1117.         if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) || IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1118.         {
  1119.             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false) || !strcmp(HouseInfo[i][hRentUser], GetName(playerid), false))
  1120.             {
  1121.                 HouseInfo[i][hLocked] = 1;
  1122.                 GameTextForPlayer(playerid, "House ~r~locked!", 2000, 5);
  1123.  
  1124.                 format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Locked` = 1 WHERE `HouseID` = %d", i);
  1125.                 mysql_query(HQuery);
  1126.             }
  1127.         }
  1128.     }
  1129.     return 1;
  1130. }
  1131.  
  1132. /*
  1133.  
  1134.  • Command: /unlockhouse
  1135.  • Processor: y_commands (YCMD)
  1136.  • Usage: Unlocking house (Player must be in range of his house to unlock it!)
  1137.  
  1138. */
  1139.  
  1140. YCMD:unlockhouse(playerid, params[], help)
  1141. {
  1142.     #pragma unused help
  1143.     #pragma unused params
  1144.     for(new i = 0; i < MAX_HOUSES; i++)
  1145.     {
  1146.         if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) || IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1147.         {
  1148.             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false) || !strcmp(HouseInfo[i][hRentUser], GetName(playerid), false))
  1149.             {
  1150.                 HouseInfo[i][hLocked] = 0;
  1151.                 GameTextForPlayer(playerid, "House ~g~unlocked!", 2000, 5);
  1152.  
  1153.                 format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Locked` = 0 WHERE `HouseID` = %d", i);
  1154.                 mysql_query(HQuery);
  1155.             }
  1156.         }
  1157.     }
  1158.     return 1;
  1159. }
  1160.  
  1161. /*
  1162.  
  1163.  • Command: /rentroom
  1164.  • Processor: y_commands (YCMD)
  1165.  • Usage: Renting room (house) (Player must be in range of house that he want to rent it!)
  1166.  
  1167. */
  1168.  
  1169. YCMD:rentroom(playerid, params[], help)
  1170. {
  1171.     #pragma unused help
  1172.     #pragma unused params
  1173.     for(new i = 0; i < MAX_HOUSES; i++)
  1174.     {
  1175.         if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]))
  1176.         {
  1177.             if(HouseInfo[i][hOwned] == 1)
  1178.             {
  1179.  
  1180.                 new HQuery2[200], HQuery3[200];
  1181.                 format(HQuery2, sizeof(HQuery2), "SELECT `Rent User` FROM `house` WHERE `Rent User` = '%s'", GetName(playerid));
  1182.                 mysql_query(HQuery2);
  1183.                 mysql_store_result();
  1184.                 if(mysql_num_rows() == 1) return SendClientMessage(playerid, COLOR_KRED, "You have rented house already!");
  1185.                 mysql_free_result();
  1186.                
  1187.                 format(HQuery3, sizeof(HQuery3), "SELECT User FROM `house` WHERE `User` = '%s'", GetName(playerid));
  1188.                 mysql_query(HQuery3);
  1189.                 mysql_store_result();
  1190.                 if(mysql_num_rows() == 1) return SendClientMessage(playerid, COLOR_KRED, "You have house!");
  1191.                 mysql_free_result();
  1192.            
  1193.                 if(GetPlayerMoney(playerid) < HouseInfo[i][hRentPrice]) return SendClientMessage(playerid, COLOR_KRED, "You don't have enough money!");
  1194.                 if(HouseInfo[i][hRented] == 1) return SendClientMessage(playerid, COLOR_KRED, "House is already rented!");
  1195.                 if(HouseInfo[i][hRentDisabled] == 1) return SendClientMessage(playerid, COLOR_KRED, "Renting this house is disabled!");
  1196.                 format(HouseInfo[i][hRentUser], 24, "%s", GetName(playerid));
  1197.                 HouseInfo[i][hRented] = 1;
  1198.                 GivePlayerMoney(playerid, -HouseInfo[i][hRentPrice]);
  1199.                 format(hstring, sizeof(hstring), "Owner: %s\nHouse ID: %d\nRent User: %s\nRent Price: %d", HouseInfo[i][hOwner], i, HouseInfo[i][hRentUser], HouseInfo[i][hRentPrice]);
  1200.                 Update3DTextLabelText(HouseInfo[i][hLabel], 0x21DD00FF, hstring);
  1201.                 SendClientMessage(playerid, COLOR_YELLOW, "Now you rent this house!");
  1202.  
  1203.                 format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Rent User` = '%s', `Rented` = 1 WHERE `HouseID` = %d", HouseInfo[i][hRentUser], i);
  1204.                 mysql_query(HQuery);
  1205.             }
  1206.             else SendClientMessage(playerid, COLOR_KRED, "That house is not owned! You can buy it but not rent it!");
  1207.         }
  1208.     }
  1209.     return 1;
  1210. }
  1211.  
  1212. /*
  1213.  
  1214.  • Command: /stoprent
  1215.  • Processor: y_commands (YCMD)
  1216.  • Usage: Stop renting room (house) (Player must be in range of his rented house to stop renting it!)
  1217.  
  1218. */
  1219.  
  1220. YCMD:stoprent(playerid, params[], help)
  1221. {
  1222.     #pragma unused help
  1223.     #pragma unused params
  1224.     for(new i = 0; i < MAX_HOUSES; i++)
  1225.     {
  1226.         if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]))
  1227.         {
  1228.             if(HouseInfo[i][hOwned] == 1)
  1229.             {
  1230.                 if(strcmp(HouseInfo[i][hRentUser], GetName(playerid), false)) return SendClientMessage(playerid, COLOR_KRED, "You don't rent this room!");
  1231.                 format(HouseInfo[i][hRentUser], 24, "None");
  1232.                 HouseInfo[i][hRented] = 0;
  1233.                 format(hstring, sizeof(hstring), "Owner: %s\nHouse ID: %d\nRent User: %s\nRent Price: %d", HouseInfo[i][hOwner], i, HouseInfo[i][hRentUser], HouseInfo[i][hRentPrice]);
  1234.                 Update3DTextLabelText(HouseInfo[i][hLabel], 0x21DD00FF, hstring);
  1235.                 SendClientMessage(playerid, COLOR_YELLOW, "You stop renting this house!");
  1236.  
  1237.                 format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Rent User` = 'None', `Rented` = 0 WHERE `HouseID` = %d", i);
  1238.                 mysql_query(HQuery);
  1239.             }
  1240.             else SendClientMessage(playerid, COLOR_KRED, "That house is not owned!");
  1241.         }
  1242.     }
  1243.     return 1;
  1244. }
  1245.  
  1246. /*
  1247.  
  1248.  • Command: /housecontrol
  1249.  • Processor: y_commands (YCMD)
  1250.  • Usage: Controling your house: lock house, unlock house, set rent price, storing weapons in house, taking weapons from house, storing money in house, taking money from house & kicking rented user from house (Player must be in his house to control it!)
  1251.  
  1252. */
  1253.  
  1254. YCMD:housecontrol(playerid, params[], help)
  1255. {
  1256.     #pragma unused help
  1257.     #pragma unused params
  1258.     for(new i = 0; i < MAX_HOUSES; i++)
  1259.     {
  1260.         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1261.         {
  1262.             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false) && PlayerEnteredHisHouse[playerid] == true)
  1263.             {
  1264.                 ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1265.             }
  1266.             else SendClientMessage(playerid, COLOR_KRED, "You must enter your house!");
  1267.         }
  1268.     }
  1269.     return 1;
  1270. }
  1271.  
  1272. /*
  1273.  
  1274.  • Command: /asellhouse (RCON Admins only)
  1275.  • Processor: y_commands (YCMD)
  1276.  • Usage: Selling specific house
  1277.  • Parameters:
  1278.         houseid: you don't need to be in range of house, just type ID of house that you want to sell!
  1279.  
  1280. */
  1281.  
  1282. YCMD:asellhouse(playerid, params[], help)
  1283. {
  1284.     #pragma unused help
  1285.     new houseid;
  1286.     if(IsPlayerAdmin(playerid))
  1287.     {
  1288.         if(sscanf(params, "i", houseid)) return SendClientMessage(playerid, -1, "Usage: /asellhouse [House ID]");
  1289.         else if(houseid <= -1) return SendClientMessage(playerid, -1, "Invalid ID");
  1290.         else if(HouseInfo[houseid][hOwned] == 0) return SendClientMessage(playerid, -1, "That house is not owned!");
  1291.         else
  1292.         format(HouseInfo[houseid][hOwner], 24, "None");
  1293.         format(HouseInfo[houseid][hRentUser], 24, "None");
  1294.         HouseInfo[houseid][hOwned] = 0;
  1295.         HouseInfo[houseid][hLocked] = 0;
  1296.         HouseInfo[houseid][hRented] = 0;
  1297.         DestroyPickup(HouseInfo[houseid][hPickup]);
  1298.         HouseInfo[houseid][hPickup] = CreatePickup(1273, 23, HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ], 0);
  1299.         format(hstring, sizeof(hstring), "For sale!\nPrice: %d\nHouse ID: %d\nType /buyhouse to buy house!", HouseInfo[houseid][hPrice], houseid);
  1300.         Update3DTextLabelText(HouseInfo[houseid][hLabel], 0x21DD00FF, hstring);
  1301.         SendClientMessage(playerid, COLOR_LIME, "House sold!");
  1302.  
  1303.         format(HQuery, sizeof(HQuery), "UPDATE `house` SET `User` = 'None', `Owned` = 0, `Locked` = 0, `Rent User` = 'None', `Rented` = 0 WHERE `HouseID` = %d", houseid);
  1304.         mysql_query(HQuery);
  1305.        
  1306.     }
  1307.     else SendClientMessage(playerid, COLOR_KRED, "Only RCON admin can use this!");
  1308.     return 1;
  1309. }
  1310.  
  1311. /*
  1312.  
  1313.  • Command: /asetprice (RCON Admins only)
  1314.  • Processor: y_commands (YCMD)
  1315.  • Usage: Setting price of specific house
  1316.  • Parameters:
  1317.         houseid: you don't need to be in range of house, just type ID of house that you want to sell!
  1318.         price: price that you want to set
  1319.  
  1320. */
  1321.  
  1322. YCMD:asetprice(playerid, params[], help)
  1323. {
  1324.     #pragma unused help
  1325.     new houseid, price, pricestring[128];
  1326.     if(IsPlayerAdmin(playerid))
  1327.     {
  1328.         if(sscanf(params, "ii", houseid, price)) return SendClientMessage(playerid, -1, "Usage: /asetprice [House ID][Price]");
  1329.         else if(houseid <= -1) return SendClientMessage(playerid, -1, "Invalid ID");
  1330.         else if(HouseInfo[houseid][hOwned] == 1) return SendClientMessage(playerid, -1, "That house is owned!");
  1331.         else
  1332.         HouseInfo[houseid][hPrice] = price;
  1333.         format(hstring, sizeof(hstring), "For sale!\nPrice: %d\nHouse ID: %d\nType /buyhouse to buy house!", HouseInfo[houseid][hPrice], houseid);
  1334.         Update3DTextLabelText(HouseInfo[houseid][hLabel], 0x21DD00FF, hstring);
  1335.         format(pricestring, sizeof(pricestring), "House price set on %d!", price);
  1336.         SendClientMessage(playerid, COLOR_LIME, pricestring);
  1337.  
  1338.         format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Price` = %d WHERE `HouseID` = %d", price, houseid);
  1339.         mysql_query(HQuery);
  1340.  
  1341.     }
  1342.     else SendClientMessage(playerid, COLOR_KRED, "Only RCON admin can use this!");
  1343.     return 1;
  1344. }
  1345.  
  1346. /*
  1347.  
  1348.  • Command: /agotohouse (RCON Admins only)
  1349.  • Processor: y_commands (YCMD)
  1350.  • Usage: Teleporting to a specific house
  1351.  • Parameters:
  1352.         houseid: you don't need to be in range of house, just type ID of house that you want to go!
  1353.  
  1354. */
  1355.  
  1356. YCMD:agotohouse(playerid, params[], help)
  1357. {
  1358.     #pragma unused help
  1359.     new houseid;
  1360.     if(IsPlayerAdmin(playerid))
  1361.     {
  1362.         if(sscanf(params, "i", houseid)) return SendClientMessage(playerid, -1, "Usage: /agotohouse [House ID]");
  1363.         else if(houseid <= -1) return SendClientMessage(playerid, -1, "Invalid ID");
  1364.         new HQuery2[200];
  1365.         format(HQuery2, sizeof(HQuery2), "SELECT HouseID FROM `house` WHERE `HouseID` = '%d'", houseid);
  1366.         mysql_query(HQuery2);
  1367.         mysql_store_result();
  1368.         if(mysql_num_rows() == 0) return SendClientMessage(playerid, COLOR_KRED, "House doesn't exist!");
  1369.         mysql_free_result();
  1370.            
  1371.         SetPlayerPos(playerid, HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ]);
  1372.         SendClientMessage(playerid, COLOR_LIME, "You have been teleported to the house!");
  1373.     }
  1374.     else SendClientMessage(playerid, COLOR_KRED, "Only RCON admin can use this!");
  1375.     return 1;
  1376. }
  1377.  
  1378. public RentFeeUp()
  1379. {
  1380.     for(new p = 0; p < MAX_PLAYERS; p++)
  1381.     {
  1382.         if(!IsPlayerConnected(p)) continue;
  1383.         for(new i = 0; i < MAX_HOUSES; i++)
  1384.         {
  1385.             new HQuery2[200];
  1386.             format(HQuery2, sizeof(HQuery2), "SELECT HouseID FROM `house` WHERE `HouseID` = '%d'", i);
  1387.             mysql_query(HQuery2);
  1388.             mysql_store_result();
  1389.             if(mysql_num_rows() == 1)
  1390.             {
  1391.                 if(!strcmp(HouseInfo[i][hRentUser], GetName(p), false))
  1392.                 {
  1393.                     GivePlayerMoney(p, -HouseInfo[i][hRentPrice]);
  1394.                     HouseInfo[i][hMoney] += HouseInfo[i][hRentPrice];
  1395.                     format(hstring, sizeof(hstring), "Rent fee: %d", HouseInfo[i][hRentPrice]);
  1396.                     printf("Rent fee: %d", HouseInfo[i][hRentPrice]);
  1397.                     SendClientMessage(p, COLOR_LIME, hstring);
  1398.                     mysql_free_result();
  1399.  
  1400.                     format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Money` = %d WHERE `HouseID` = %d", HouseInfo[i][hMoney], i);
  1401.                     mysql_query(HQuery);
  1402.                 }
  1403.             }
  1404.         }
  1405.     }
  1406.     return 1;
  1407. }
  1408.  
  1409.  
  1410. //*****************************           *****************************
  1411. //***************************** CALLBACKS *****************************
  1412. //*****************************           *****************************
  1413.  
  1414.  
  1415.  
  1416.  
  1417. /*
  1418.  
  1419.  • Callback: OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])  (Hooked using y_hook)
  1420.  • Action: Dialogs for house controling, later will be more for dynamic creating house!
  1421.  
  1422. */
  1423.  
  1424. Hook:H1_OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  1425. {
  1426.     switch(dialogid)
  1427.     {
  1428.         case 5678: //Dialog for house controling
  1429.         {
  1430.             if(!response) return 0;
  1431.             switch(listitem)
  1432.             {
  1433.                 case 0: //locking house
  1434.                 {
  1435.                     for(new i = 0; i < MAX_HOUSES; i++)
  1436.                     {
  1437.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1438.                         {
  1439.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1440.                             {
  1441.                                 HouseInfo[i][hLocked] = 1;
  1442.                                 GameTextForPlayer(playerid, "House ~r~locked!", 2000, 5);
  1443.                                 ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1444.  
  1445.                                 format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Locked` = 1 WHERE `HouseID` = %d", i);
  1446.                                 mysql_query(HQuery);
  1447.                             }
  1448.                         }
  1449.                     }
  1450.                 }
  1451.                 case 1: //unlocking house
  1452.                 {
  1453.                     for(new i = 0; i < MAX_HOUSES; i++)
  1454.                     {
  1455.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1456.                         {
  1457.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1458.                             {
  1459.                                 HouseInfo[i][hLocked] = 0;
  1460.                                 GameTextForPlayer(playerid, "House ~g~unlocked!", 2000, 5);
  1461.                                 ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1462.  
  1463.                                 format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Locked` = 0 WHERE `HouseID` = %d", i);
  1464.                                 mysql_query(HQuery);
  1465.                             }
  1466.                         }
  1467.                     }
  1468.                 }
  1469.                 case 2: //setting rent fee
  1470.                 {
  1471.                     if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1472.                     for(new i = 0; i < MAX_HOUSES; i++)
  1473.                     {
  1474.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1475.                         {
  1476.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1477.                             {
  1478.                                 format(hstring, sizeof(hstring), "Current rent price: %d\nType ammount of price that you want to set for renting\n0 for disabling rent!", HouseInfo[i][hRentPrice]);
  1479.                                 ShowPlayerDialog(playerid, 5686, DIALOG_STYLE_INPUT, "   Rent price", hstring, "Ok", "Back");
  1480.                             }
  1481.                         }
  1482.                     }
  1483.                 }
  1484.                 case 3: //storing a gun
  1485.                 {
  1486.                     if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1487.                     for(new i = 0; i < MAX_HOUSES; i++)
  1488.                     {
  1489.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1490.                         {
  1491.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1492.                             {
  1493.                                 new gunstring[128], gunstring1[128], gunstring2[128], gunstring3[128];
  1494.                                 if(HouseInfo[i][hWeaponID1] == 0) format(gunstring1, sizeof(gunstring1), "Nothing");
  1495.                                 else format(gunstring1, sizeof(gunstring1), "Weapon: %s | Ammo: %d", GetWeapon(HouseInfo[i][hWeaponID1]), HouseInfo[i][hWeaponID1Ammo]);
  1496.                                
  1497.                                 if(HouseInfo[i][hWeaponID2] == 0) format(gunstring2, sizeof(gunstring1), "Nothing");
  1498.                                 else format(gunstring2, sizeof(gunstring2), "Weapon: %s | Ammo: %d", GetWeapon(HouseInfo[i][hWeaponID2]), HouseInfo[i][hWeaponID2Ammo]);
  1499.                                
  1500.                                 if(HouseInfo[i][hWeaponID3] == 0) format(gunstring3, sizeof(gunstring1), "Nothing");
  1501.                                 else format(gunstring3, sizeof(gunstring3), "Weapon: %s | Ammo: %d", GetWeapon(HouseInfo[i][hWeaponID3]), HouseInfo[i][hWeaponID3Ammo]);
  1502.                                
  1503.                                 format(gunstring, sizeof(gunstring), "%s\n%s\n%s", gunstring1, gunstring2, gunstring3);
  1504.                                 ShowPlayerDialog(playerid, 5679, DIALOG_STYLE_LIST, "  Stored guns", gunstring, "Ok", "Back");
  1505.                             }
  1506.                         }
  1507.                     }
  1508.                 }
  1509.                 case 4: //taking a gun
  1510.                 {
  1511.                     if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1512.                     for(new i = 0; i < MAX_HOUSES; i++)
  1513.                     {
  1514.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1515.                         {
  1516.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1517.                             {
  1518.                                 new gunstring[128], gunstring1[128], gunstring2[128], gunstring3[128];
  1519.                                 if(HouseInfo[i][hWeaponID1] == 0) format(gunstring1, sizeof(gunstring1), "Nothing");
  1520.                                 else format(gunstring1, sizeof(gunstring1), "Weapon: %s | Ammo: %d", GetWeapon(HouseInfo[i][hWeaponID1]), HouseInfo[i][hWeaponID1Ammo]);
  1521.  
  1522.                                 if(HouseInfo[i][hWeaponID2] == 0) format(gunstring2, sizeof(gunstring1), "Nothing");
  1523.                                 else format(gunstring2, sizeof(gunstring2), "Weapon: %s | Ammo: %d", GetWeapon(HouseInfo[i][hWeaponID2]), HouseInfo[i][hWeaponID2Ammo]);
  1524.  
  1525.                                 if(HouseInfo[i][hWeaponID3] == 0) format(gunstring3, sizeof(gunstring1), "Nothing");
  1526.                                 else format(gunstring3, sizeof(gunstring3), "Weapon: %s | Ammo: %d", GetWeapon(HouseInfo[i][hWeaponID3]), HouseInfo[i][hWeaponID3Ammo]);
  1527.  
  1528.                                 format(gunstring, sizeof(gunstring), "%s\n%s\n%s", gunstring1, gunstring2, gunstring3);
  1529.                                 ShowPlayerDialog(playerid, 5683, DIALOG_STYLE_LIST, "  Stored guns", gunstring, "Ok", "Back");
  1530.                             }
  1531.                         }
  1532.                     }
  1533.                 }
  1534.                 case 5: //storing money
  1535.                 {
  1536.                     if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1537.                     for(new i = 0; i < MAX_HOUSES; i++)
  1538.                     {
  1539.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1540.                         {
  1541.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1542.                             {
  1543.                                 new moneystring[128];
  1544.                                 format(moneystring, sizeof(moneystring), "Current stored money: %d\n\nType ammount of money that you want to store", HouseInfo[i][hMoney]);
  1545.                                 ShowPlayerDialog(playerid, 5684, DIALOG_STYLE_INPUT, "   Stored money", moneystring, "Ok", "Back");
  1546.                             }
  1547.                         }
  1548.                     }
  1549.                 }
  1550.                 case 6: //taking money
  1551.                 {
  1552.                     if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1553.                     for(new i = 0; i < MAX_HOUSES; i++)
  1554.                     {
  1555.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1556.                         {
  1557.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1558.                             {
  1559.                                 new moneystring[128];
  1560.                                 format(moneystring, sizeof(moneystring), "Current stored money: %d\n\nType ammount of money that you want to take", HouseInfo[i][hMoney]);
  1561.                                 ShowPlayerDialog(playerid, 5685, DIALOG_STYLE_INPUT, "   Stored money", moneystring, "Ok", "Back");
  1562.                             }
  1563.                         }
  1564.                     }
  1565.                 }
  1566.                 case 7: //kicking rent user
  1567.                 {
  1568.                     if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1569.                     for(new i = 0; i < MAX_HOUSES; i++)
  1570.                     {
  1571.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1572.                         {
  1573.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1574.                             {
  1575.                                 if(HouseInfo[i][hRented] == 0)
  1576.                                 {
  1577.                                     SendClientMessage(playerid, COLOR_KRED, "No one doesn't rent this house!");
  1578.                                     ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1579.                                     return 1;
  1580.                                 }
  1581.                                 new moneystring[128];
  1582.                                 format(moneystring, sizeof(moneystring), "Current rent user: %s\n\nDo you want to kick him?", HouseInfo[i][hRentUser]);
  1583.                                 ShowPlayerDialog(playerid, 5687, DIALOG_STYLE_MSGBOX, "   Kick rent user", moneystring, "Yes", "No");
  1584.                             }
  1585.                         }
  1586.                     }
  1587.                 }
  1588.             }
  1589.         }
  1590.         case 5679: //dialog with all stored guns
  1591.         {
  1592.             if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1593.             switch(listitem)
  1594.             {
  1595.                 case 0: //slot 1
  1596.                 {
  1597.                     for(new i = 0; i < MAX_HOUSES; i++)
  1598.                     {
  1599.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1600.                         {
  1601.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1602.                             {
  1603.                                 ShowPlayerDialog(playerid, 5680, DIALOG_STYLE_INPUT, "  Gun", "Type a gun ID that you want to store!", "Ok", "Exit");
  1604.                             }
  1605.                         }
  1606.                     }
  1607.                 }
  1608.                 case 1: //slot 2
  1609.                 {
  1610.                     for(new i = 0; i < MAX_HOUSES; i++)
  1611.                     {
  1612.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1613.                         {
  1614.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1615.                             {
  1616.                                 ShowPlayerDialog(playerid, 5681, DIALOG_STYLE_INPUT, "  Gun", "Type a gun ID that you want to store!", "Ok", "Exit");
  1617.                             }
  1618.                         }
  1619.                     }
  1620.                 }
  1621.                 case 2: //slot 3
  1622.                 {
  1623.                     for(new i = 0; i < MAX_HOUSES; i++)
  1624.                     {
  1625.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1626.                         {
  1627.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1628.                             {
  1629.                                 ShowPlayerDialog(playerid, 5682, DIALOG_STYLE_INPUT, "  Gun", "Type a gun ID that you want to store!", "Ok", "Exit");
  1630.                             }
  1631.                         }
  1632.                     }
  1633.                 }
  1634.             }
  1635.         }
  1636.         case 5680: //dialog for storing gun in slot 1
  1637.         {
  1638.             if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1639.             for(new i = 0; i < MAX_HOUSES; i++)
  1640.             {
  1641.                 if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1642.                 {
  1643.                     if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1644.                     {
  1645.                         Custom_GetPlayerWeapon(playerid);
  1646.                         if(House_Weapon[playerid][Custom_GetSlot(strval(inputtext))] == strval(inputtext))
  1647.                         {
  1648.                             if(strval(inputtext) > 0 || strval(inputtext) < 46)
  1649.                             {
  1650.                                 HouseInfo[i][hWeaponID1] = strval(inputtext);
  1651.                                 HouseInfo[i][hWeaponID1Ammo] = House_Ammo[playerid][Custom_GetSlot(HouseInfo[i][hWeaponID1])];
  1652.                                 format(string, sizeof(string), "Gun ID %d stored in the slot 1", strval(inputtext));
  1653.                                 SendClientMessage(playerid, COLOR_LIME, string);
  1654.                                 ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nKick rent user", "Ok", "Exit");
  1655.  
  1656.                                 format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Weapon ID 1` = %d, `Weapon ID 1 Ammo` = %d WHERE `HouseID` = %d", strval(inputtext), HouseInfo[i][hWeaponID1Ammo], i);
  1657.                                 mysql_query(HQuery);
  1658.                             }
  1659.                             else
  1660.                             {
  1661.                                 SendClientMessage(playerid, COLOR_KRED, "Invalid gun ID!");
  1662.                                 ShowPlayerDialog(playerid, 5680, DIALOG_STYLE_INPUT, "  Gun", "Type a gun ID that you want to store!", "Ok", "Exit");
  1663.                             }
  1664.                         }
  1665.                         else
  1666.                         {
  1667.                             SendClientMessage(playerid, COLOR_KRED, "You don't have that gun!");
  1668.                             ShowPlayerDialog(playerid, 5680, DIALOG_STYLE_INPUT, "  Gun", "Type a gun ID that you want to store!", "Ok", "Exit");
  1669.                         }
  1670.                     }
  1671.                 }
  1672.             }
  1673.         }
  1674.         case 5681: //dialog for storing gun in slot 2
  1675.         {
  1676.             if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1677.             for(new i = 0; i < MAX_HOUSES; i++)
  1678.             {
  1679.                 if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1680.                 {
  1681.                     if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1682.                     {
  1683.                         Custom_GetPlayerWeapon(playerid);
  1684.                         if(House_Weapon[playerid][Custom_GetSlot(strval(inputtext))] == strval(inputtext))
  1685.                         {
  1686.                             if(strval(inputtext) > 0 || strval(inputtext) < 46)
  1687.                             {
  1688.                                 HouseInfo[i][hWeaponID2] = strval(inputtext);
  1689.                                 HouseInfo[i][hWeaponID2Ammo] = House_Ammo[playerid][Custom_GetSlot(HouseInfo[i][hWeaponID2])];
  1690.                                 format(string, sizeof(string), "Gun ID %d stored in the slot 2", strval(inputtext));
  1691.                                 SendClientMessage(playerid, COLOR_LIME, string);
  1692.                                 ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nKick rent user", "Ok", "Exit");
  1693.  
  1694.                                 format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Weapon ID 2` = %d, `Weapon ID 2 Ammo` = %d WHERE `HouseID` = %d", strval(inputtext), HouseInfo[i][hWeaponID2Ammo], i);
  1695.                                 mysql_query(HQuery);
  1696.                             }
  1697.                             else
  1698.                             {
  1699.                                 SendClientMessage(playerid, COLOR_KRED, "Invalid gun ID!");
  1700.                                 ShowPlayerDialog(playerid, 5680, DIALOG_STYLE_INPUT, "  Gun", "Type a gun ID that you want to store!", "Ok", "Exit");
  1701.                             }
  1702.                         }
  1703.                         else
  1704.                         {
  1705.                             SendClientMessage(playerid, COLOR_KRED, "You don't have that gun!");
  1706.                             ShowPlayerDialog(playerid, 5680, DIALOG_STYLE_INPUT, "  Gun", "Type a gun ID that you want to store!", "Ok", "Exit");
  1707.                         }
  1708.                     }
  1709.                 }
  1710.             }
  1711.         }
  1712.         case 5682: //dialog for storing gun in slot 3
  1713.         {
  1714.             if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1715.             for(new i = 0; i < MAX_HOUSES; i++)
  1716.             {
  1717.                 if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1718.                 {
  1719.                     if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1720.                     {
  1721.                         Custom_GetPlayerWeapon(playerid);
  1722.                         if(House_Weapon[playerid][Custom_GetSlot(strval(inputtext))] == strval(inputtext))
  1723.                         {
  1724.                             if(strval(inputtext) > 0 || strval(inputtext) < 46)
  1725.                             {
  1726.                                 HouseInfo[i][hWeaponID3] = strval(inputtext);
  1727.                                 HouseInfo[i][hWeaponID3Ammo] = House_Ammo[playerid][Custom_GetSlot(HouseInfo[i][hWeaponID3])];
  1728.                                 format(string, sizeof(string), "Gun ID %d stored in the slot 3", strval(inputtext));
  1729.                                 SendClientMessage(playerid, COLOR_LIME, string);
  1730.                                 ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nKick rent user", "Ok", "Exit");
  1731.  
  1732.                                 format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Weapon ID 3` = %d, `Weapon ID 3 Ammo` = %d WHERE `HouseID` = %d", strval(inputtext), HouseInfo[i][hWeaponID3Ammo], i);
  1733.                                 mysql_query(HQuery);
  1734.                             }
  1735.                             else
  1736.                             {
  1737.                                 SendClientMessage(playerid, COLOR_KRED, "Invalid gun ID!");
  1738.                                 ShowPlayerDialog(playerid, 5680, DIALOG_STYLE_INPUT, "  Gun", "Type a gun ID that you want to store!", "Ok", "Exit");
  1739.                             }
  1740.                         }
  1741.                         else
  1742.                         {
  1743.                             SendClientMessage(playerid, COLOR_KRED, "You don't have that gun!");
  1744.                             ShowPlayerDialog(playerid, 5680, DIALOG_STYLE_INPUT, "  Gun", "Type a gun ID that you want to store!", "Ok", "Exit");
  1745.                         }
  1746.                     }
  1747.                 }
  1748.             }
  1749.         }
  1750.         case 5683: //dialog for taking gun
  1751.         {
  1752.             if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1753.             switch(listitem)
  1754.             {
  1755.                 case 0: //slot 1
  1756.                 {
  1757.                     for(new i = 0; i < MAX_HOUSES; i++)
  1758.                     {
  1759.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1760.                         {
  1761.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1762.                             {
  1763.                                 if(HouseInfo[i][hWeaponID1] > 1) //if slot isn't empty (Emty slot is weapon ID 0 (Hand))
  1764.                                 {
  1765.                                     GivePlayerWeapon(playerid, HouseInfo[i][hWeaponID1], HouseInfo[i][hWeaponID1Ammo]);
  1766.                                     HouseInfo[i][hWeaponID1] = 0;
  1767.                                     HouseInfo[i][hWeaponID1Ammo] = 0;
  1768.                                    
  1769.                                     format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Weapon ID 1` = 0, `Weapon ID 1 Ammo` = 0 WHERE `HouseID` = %d", i);
  1770.                                     mysql_query(HQuery);
  1771.                                 }
  1772.                                 else
  1773.                                 {
  1774.                                     SendClientMessage(playerid, COLOR_KRED, "That slot is empty!");
  1775.                                     ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nKick rent user", "Ok", "Exit");
  1776.                                 }
  1777.                             }
  1778.                         }
  1779.                     }
  1780.                 }
  1781.                 case 1: //slot 2
  1782.                 {
  1783.                     for(new i = 0; i < MAX_HOUSES; i++)
  1784.                     {
  1785.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1786.                         {
  1787.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1788.                             {
  1789.                                 if(HouseInfo[i][hWeaponID2] > 1) //if slot isn't empty (Emty slot is weapon ID 0 (Hand))
  1790.                                 {
  1791.                                     GivePlayerWeapon(playerid, HouseInfo[i][hWeaponID2], HouseInfo[i][hWeaponID2Ammo]);
  1792.                                     HouseInfo[i][hWeaponID2] = 0;
  1793.                                     HouseInfo[i][hWeaponID2Ammo] = 0;
  1794.  
  1795.                                     format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Weapon ID 2` = 0, `Weapon ID 2 Ammo` = 0 WHERE `HouseID` = %d", i);
  1796.                                     mysql_query(HQuery);
  1797.                                 }
  1798.                                 else
  1799.                                 {
  1800.                                     SendClientMessage(playerid, COLOR_KRED, "That slot is empty!");
  1801.                                     ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nKick rent user", "Ok", "Exit");
  1802.                                 }
  1803.                             }
  1804.                         }
  1805.                     }
  1806.                 }
  1807.                 case 2: //slot 3
  1808.                 {
  1809.                     for(new i = 0; i < MAX_HOUSES; i++)
  1810.                     {
  1811.                         if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1812.                         {
  1813.                             if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1814.                             {
  1815.                                 if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1816.                                 {
  1817.                                     if(HouseInfo[i][hWeaponID3] > 1) //if slot isn't empty (Emty slot is weapon ID 0 (Hand))
  1818.                                     {
  1819.                                         GivePlayerWeapon(playerid, HouseInfo[i][hWeaponID3], HouseInfo[i][hWeaponID3Ammo]);
  1820.                                         HouseInfo[i][hWeaponID3] = 0;
  1821.                                         HouseInfo[i][hWeaponID3Ammo] = 0;
  1822.  
  1823.                                         format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Weapon ID 3` = 0, `Weapon ID 3 Ammo` = 0 WHERE `HouseID` = %d", i);
  1824.                                         mysql_query(HQuery);
  1825.                                     }
  1826.                                     else
  1827.                                     {
  1828.                                         SendClientMessage(playerid, COLOR_KRED, "That slot is empty!");
  1829.                                         ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nKick rent user", "Ok", "Exit");
  1830.                                     }
  1831.                                 }
  1832.                             }
  1833.                         }
  1834.                     }
  1835.                 }
  1836.             }
  1837.         }
  1838.         case 5684: //dialog for storing money
  1839.         {
  1840.             if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1841.             for(new i = 0; i < MAX_HOUSES; i++)
  1842.             {
  1843.                 if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1844.                 {
  1845.                     if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1846.                     {
  1847.                         new moneystring[128];
  1848.                         format(moneystring, sizeof(moneystring), "Current stored money: %d\n\nType ammount of money that you want to store", HouseInfo[i][hMoney]);
  1849.                         if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 5684, DIALOG_STYLE_INPUT, "   Stored money", moneystring, "Ok", "Back");
  1850.                         if(GetPlayerMoney(playerid) < strval(inputtext))
  1851.                         {
  1852.                             SendClientMessage(playerid, COLOR_KRED, "You don't have enoguh money to store!");
  1853.                             ShowPlayerDialog(playerid, 5684, DIALOG_STYLE_INPUT, "   Stored money", moneystring, "Ok", "Back");
  1854.                             return 1;
  1855.                         }
  1856.                         HouseInfo[i][hMoney] += strval(inputtext);
  1857.                         GivePlayerMoney(playerid, -strval(inputtext));
  1858.                         format(hstring, sizeof(hstring), "You store %d$! Current stored money: %d", strval(inputtext), HouseInfo[i][hMoney]);
  1859.                         SendClientMessage(playerid, COLOR_YELLOW, hstring);
  1860.                         ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1861.                        
  1862.                         format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Money` = %d WHERE `HouseID` = %d", HouseInfo[i][hMoney], i);
  1863.                         mysql_query(HQuery);
  1864.                     }
  1865.                 }
  1866.             }
  1867.         }
  1868.         case 5685: //dialog for taking money
  1869.         {
  1870.             if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1871.             for(new i = 0; i < MAX_HOUSES; i++)
  1872.             {
  1873.                 if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1874.                 {
  1875.                     if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1876.                     {
  1877.                         new moneystring[128];
  1878.                         format(moneystring, sizeof(moneystring), "Current stored money: %d\n\nType ammount of money that you want to take", HouseInfo[i][hMoney]);
  1879.                         if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 5685, DIALOG_STYLE_INPUT, "   Stored money", moneystring, "Ok", "Back");
  1880.                         if(strval(inputtext) > HouseInfo[i][hMoney])
  1881.                         {
  1882.                             SendClientMessage(playerid, COLOR_KRED, "House does not have that much money!");
  1883.                             ShowPlayerDialog(playerid, 5684, DIALOG_STYLE_INPUT, "   Stored money", moneystring, "Ok", "Back");
  1884.                             return 1;
  1885.                         }
  1886.                         HouseInfo[i][hMoney] -= strval(inputtext);
  1887.                         GivePlayerMoney(playerid, strval(inputtext));
  1888.                         format(hstring, sizeof(hstring), "You take %d$! Current stored money: %d", strval(inputtext), HouseInfo[i][hMoney]);
  1889.                         SendClientMessage(playerid, COLOR_YELLOW, hstring);
  1890.                         ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1891.  
  1892.                         format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Money` = %d WHERE `HouseID` = %d", HouseInfo[i][hMoney], i);
  1893.                         mysql_query(HQuery);
  1894.                     }
  1895.                 }
  1896.             }
  1897.         }
  1898.         case 5686: //dialog for setting rent price
  1899.         {
  1900.             if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1901.             for(new i = 0; i < MAX_HOUSES; i++)
  1902.             {
  1903.                 if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1904.                 {
  1905.                     if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1906.                     {
  1907.                         new rentstring[128], labelstring[128];
  1908.                         format(rentstring, sizeof(rentstring), "Current rent price: %d\nType ammount of price that you want to set for renting\n0 for disabling rent!", HouseInfo[i][hRentPrice]);
  1909.                         if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 5686, DIALOG_STYLE_INPUT, "   Rent price", rentstring, "Ok", "Back");
  1910.                         if(strval(inputtext) < 0 || strval(inputtext) > 10000) return ShowPlayerDialog(playerid, 5686, DIALOG_STYLE_INPUT, "   Rent price", rentstring, "Ok", "Back");
  1911.                         if(strval(inputtext) == 0)
  1912.                         {
  1913.                             HouseInfo[i][hRentDisabled] = 1;
  1914.                             HouseInfo[i][hRented] = 0;
  1915.                             format(HouseInfo[i][hRentUser], 24, "None");
  1916.                             SendClientMessage(playerid, COLOR_YELLOW, "Rent disabled!");
  1917.                             format(labelstring, sizeof(labelstring), "Owner: %s\nHouse ID: %d\nRent Disabled", HouseInfo[i][hOwner], i);
  1918.                             Update3DTextLabelText(HouseInfo[i][hLabel], 0x21DD00FF, labelstring);
  1919.  
  1920.                             format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Rent User` = 'None', `Rented` = 0, `Rent Disabled` = 1 WHERE `HouseID` = %d", i);
  1921.                             mysql_query(HQuery);
  1922.                             return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1923.                         }
  1924.                         HouseInfo[i][hRentDisabled] = 0;
  1925.                         HouseInfo[i][hRentPrice] = strval(inputtext);
  1926.                         format(labelstring, sizeof(labelstring), "Owner: %s\nHouse ID: %d\nRent User: %s\nRent Price: %d", HouseInfo[i][hOwner], i, HouseInfo[i][hRentUser], HouseInfo[i][hRentPrice]);
  1927.                         Update3DTextLabelText(HouseInfo[i][hLabel], 0x21DD00FF, labelstring);
  1928.                         format(hstring, sizeof(hstring), "Rent price set on %d", HouseInfo[i][hRentPrice]);
  1929.                         SendClientMessage(playerid, COLOR_YELLOW, hstring);
  1930.                         ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1931.                        
  1932.                         format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Rent Price` = %d, `Rent Disabled` = 0 WHERE `HouseID` = %d", HouseInfo[i][hRentPrice], i);
  1933.                         mysql_query(HQuery);
  1934.                     }
  1935.                 }
  1936.             }
  1937.         }
  1938.         case 5687: //dialog for kicking rent user
  1939.         {
  1940.             if(!response) return ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1941.             for(new i = 0; i < MAX_HOUSES; i++)
  1942.             {
  1943.                 if(IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
  1944.                 {
  1945.                     if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  1946.                     {
  1947.                         new labelstring[128];
  1948.                         HouseInfo[i][hRented] = 0;
  1949.                         format(hstring, sizeof(hstring), "You kicked %s", HouseInfo[i][hRentUser]);
  1950.                         SendClientMessage(playerid, COLOR_YELLOW, hstring);
  1951.                         format(HouseInfo[i][hRentUser], 24, "None");
  1952.                         format(labelstring, sizeof(labelstring), "Owner: %s\nHouse ID: %d\nRent User: %s\nRent Price: %d", HouseInfo[i][hOwner], i, HouseInfo[i][hRentUser], HouseInfo[i][hRentPrice]);
  1953.                         Update3DTextLabelText(HouseInfo[i][hLabel], 0x21DD00FF, labelstring);
  1954.                         ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_LIST, "   Control your house!", "Lock house\nUnlock house\nSet rent price\nStore weapon\nTake weapon\nStore money\nTake money\nKick rent user", "Ok", "Exit");
  1955.  
  1956.                         format(HQuery, sizeof(HQuery), "UPDATE `house` SET `Rent User` = 'None', `Rented` = 0 WHERE `HouseID` = %d", i);
  1957.                         mysql_query(HQuery);
  1958.                     }
  1959.                 }
  1960.             }
  1961.         }
  1962.         case 5688: //sell to player house
  1963.         {
  1964.             new selledstring[128], selledstring2[128];
  1965.             if(!response)
  1966.             {
  1967.                 SendClientMessage(playerid, COLOR_YELLOW, "You canceled buying house!");
  1968.                 SendClientMessage(GetPVarInt(playerid, "Seller"), COLOR_YELLOW, "Player canceled buying house!");
  1969.                 return 1;
  1970.             }
  1971.             print("Calls under response");
  1972.             for(new i = 0; i < MAX_HOUSES; i++)
  1973.             {
  1974.                 if(IsPlayerInRangeOfPoint(GetPVarInt(playerid, "Seller"), 3.0, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]))
  1975.                 {
  1976.                     if(!strcmp(HouseInfo[i][hOwner], GetName(GetPVarInt(playerid, "Seller")), false) && HouseInfo[i][hOwned] == 1)
  1977.                     {
  1978.                         new HQuery2[200];
  1979.                         format(HQuery2, sizeof(HQuery2), "SELECT HouseID FROM `house` WHERE `HouseID` = '%d'", i);
  1980.                         mysql_query(HQuery2);
  1981.                         mysql_store_result();
  1982.                         if(mysql_num_rows() == 1)
  1983.                         {
  1984.                             print("House sold!");
  1985.                             format(HouseInfo[i][hOwner], 24, "%s", GetName(playerid));
  1986.                             format(HouseInfo[i][hRentUser], 24, "None");
  1987.                             HouseInfo[i][hOwned] = 1;
  1988.                             HouseInfo[i][hLocked] = 0;
  1989.                             HouseInfo[i][hRented] = 0;
  1990.                             GivePlayerMoney(playerid, -HouseInfo[i][hPrice]);
  1991.                             GivePlayerMoney(GetPVarInt(playerid, "Seller"), HouseInfo[i][hPrice]);
  1992.                             if(HouseInfo[i][hRentDisabled] == 0)
  1993.                             {
  1994.                                 DestroyPickup(HouseInfo[i][hPickup]);
  1995.                                 HouseInfo[i][hPickup] = CreatePickup(1239, 23, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ], 0);
  1996.                                 format(hstring, sizeof(hstring), "Owner: %s\nHouse ID: %d\nRent User: %s\nRent Price: %d", HouseInfo[i][hOwner], i, HouseInfo[i][hRentUser], HouseInfo[i][hRentPrice]);
  1997.                                 Update3DTextLabelText(HouseInfo[i][hLabel], 0x21DD00FF, hstring);
  1998.                             }
  1999.                             else
  2000.                             {
  2001.                                 DestroyPickup(HouseInfo[i][hPickup]);
  2002.                                 HouseInfo[i][hPickup] = CreatePickup(1239, 23, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ], 0);
  2003.                                 format(hstring, sizeof(hstring), "Owner: %s\nHouse ID: %d\nRent Disabled", HouseInfo[i][hOwner], i);
  2004.                                 Update3DTextLabelText(HouseInfo[i][hLabel], 0x21DD00FF, hstring);
  2005.                             }
  2006.                             format(selledstring, sizeof(selledstring), "You bought house from player %s for %d$", GetName(GetPVarInt(playerid, "Seller")), HouseInfo[i][hPrice]);
  2007.                             SendClientMessage(playerid, COLOR_YELLOW, selledstring);
  2008.                             format(selledstring2, sizeof(selledstring2), "House sold to player %s for %d$", GetName(playerid), HouseInfo[i][hPrice]);
  2009.                             SendClientMessage(GetPVarInt(playerid, "Seller"), COLOR_YELLOW, selledstring2);
  2010.                             mysql_free_result();
  2011.  
  2012.                             format(HQuery, sizeof(HQuery), "UPDATE `house` SET `User` = '%s', `Owned` = 1, `Locked` = 0, `Rent User` = 'None', `Rented` = 0 WHERE `HouseID` = %d", GetName(playerid), i);
  2013.                             mysql_query(HQuery);
  2014.                         }
  2015.                     }
  2016.                 }
  2017.             }
  2018.         }
  2019.     }
  2020.     return 1;
  2021. }
  2022.  
  2023. /*
  2024.  
  2025.  • Callback: OnPlayerKeyStateChange(playerid, newkeys, oldkeys)  (Hooked using y_hook)
  2026.  • Action: Player can enter house (If is not locked!) using F or Enter (by default in GTA:SA)
  2027.  
  2028. */
  2029.  
  2030. Hook:H2_OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  2031. {
  2032.     if(newkeys & KEY_SECONDARY_ATTACK && !IsPlayerInAnyVehicle(playerid))
  2033.     {
  2034.         for(new i = 0; i < MAX_HOUSES; i++)
  2035.         {
  2036.             if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) && GetPlayerInterior(playerid) == 0 && GetPlayerVirtualWorld(playerid) == 0)
  2037.             {
  2038.                 if(HouseInfo[i][hLocked] == 0)
  2039.                 {
  2040.                     if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  2041.                     {
  2042.                         PlayerEnteredHisHouse[playerid] = true;
  2043.                     }
  2044.                     SetPlayerInterior(playerid, HouseInfo[i][hInterior]);
  2045.                     SetPlayerVirtualWorld(playerid, HouseInfo[i][hVirtualWorld]);
  2046.                     SetPlayerPos(playerid, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]);
  2047.                     return CallLocalFunction("OnPlayerEnterHouse", "dd", playerid, i);
  2048.                 }
  2049.                 else SendClientMessage(playerid, COLOR_KRED, "House is locked!");
  2050.             }
  2051.             else if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]) && GetPlayerInterior(playerid) == HouseInfo[i][hInterior] && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hVirtualWorld])
  2052.             {
  2053.                 if(HouseInfo[i][hLocked] == 0)
  2054.                 {
  2055.                     if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false))
  2056.                     {
  2057.                         PlayerEnteredHisHouse[playerid] = false;
  2058.                     }
  2059.                     SetPlayerInterior(playerid, 0);
  2060.                     SetPlayerVirtualWorld(playerid, 0);
  2061.                     SetPlayerPos(playerid, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]);
  2062.                     return CallLocalFunction("OnPlayerExitHouse", "dd", playerid, i);
  2063.                 }
  2064.                 else SendClientMessage(playerid, COLOR_KRED, "House is locked!");
  2065.             }
  2066.         }
  2067.     }
  2068.     return 1;
  2069. }
  2070.  
  2071. Hook:H3_OnPlayerSpawn(playerid) //credits
  2072. {
  2073.     new credits[128];
  2074.     format(credits, sizeof(credits), "This server use S32_House %s by System32!", house_version);
  2075.     SendClientMessage(playerid, COLOR_LIME, credits);
  2076.     return 1;
  2077. }
  2078.  
  2079. Hook:H4_OnGameModeInit()
  2080. {
  2081.     SetTimer("RentFeeUp", 3600000, 0);
  2082.     return 1;
  2083. }
  2084.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement