· 8 years ago · Jan 08, 2018, 05:52 PM
1/*
2 Yet Another House System by rootcause
3
4 Current Version: 1.3
5 Topic: http://forum.sa-mp.com/showthread.php?p=3409290
6
7 Changelog (v1.3):
8 - Added house selling, you can put your houses for sale. When your house is bought by an another player, you'll receive your money.
9 - Added a house buying limiter, a player can't buy more than LIMIT_PER_PLAYER houses. Set LIMIT_PER_PLAYER to 0 if you want no limits.
10 - Internal changes like replacing GetPlayerName with Player_GetName or replacing the DIALOG_HOUSE+x format with e_dialogids enum.
11*/
12
13#define FILTERSCRIPT
14#include <a_samp>
15#include <a_mysql>
16#include <streamer>
17#include <sscanf2>
18#include <YSI\y_iterate>
19#include <zcmd>
20
21#define MAX_HOUSES (100)
22#define MAX_HOUSE_NAME (48)
23#define MAX_HOUSE_PASSWORD (16)
24#define MAX_HOUSE_ADDRESS (48)
25#define MAX_INT_NAME (32)
26#define INVALID_HOUSE_ID (-1)
27#define HOUSE_COOLDOWN (6)
28#define LIMIT_PER_PLAYER (3)
29
30#define SQL_HOST "127.0.0.1"
31#define SQL_USER "root"
32#define SQL_PASSWORD ""
33#define SQL_DBNAME "housedb"
34
35enum _:e_lockmodes
36{
37 LOCK_MODE_NOLOCK,
38 LOCK_MODE_PASSWORD,
39 LOCK_MODE_KEYS,
40 LOCK_MODE_OWNER
41}
42
43enum _:e_selectmodes
44{
45 SELECT_MODE_NONE,
46 SELECT_MODE_EDIT,
47 SELECT_MODE_SELL
48}
49
50enum _:e_dialogids
51{
52 DIALOG_BUY_HOUSE = 7500,
53 DIALOG_HOUSE_PASSWORD,
54 DIALOG_HOUSE_MENU,
55 DIALOG_HOUSE_NAME,
56 DIALOG_HOUSE_NEW_PASSWORD,
57 DIALOG_HOUSE_LOCK,
58 DIALOG_SAFE_MENU,
59 DIALOG_SAFE_TAKE,
60 DIALOG_SAFE_PUT,
61 DIALOG_GUNS_MENU,
62 DIALOG_GUNS_TAKE,
63 DIALOG_FURNITURE_MENU,
64 DIALOG_FURNITURE_BUY,
65 DIALOG_FURNITURE_SELL,
66 DIALOG_VISITORS_MENU,
67 DIALOG_VISITORS,
68 DIALOG_KEYS_MENU,
69 DIALOG_KEYS,
70 DIALOG_SAFE_HISTORY,
71 DIALOG_MY_KEYS,
72 DIALOG_BUY_HOUSE_FROM_OWNER,
73 DIALOG_SELL_HOUSE,
74 DIALOG_SELLING_PRICE
75}
76
77enum e_house
78{
79 Name[MAX_HOUSE_NAME],
80 Owner[MAX_PLAYER_NAME],
81 Password[MAX_HOUSE_PASSWORD],
82 Address[MAX_HOUSE_ADDRESS],
83 Float: houseX,
84 Float: houseY,
85 Float: houseZ,
86 Price,
87 SalePrice,
88 Interior,
89 LockMode,
90 SafeMoney,
91 LastEntered,
92 Text3D: HouseLabel,
93 HousePickup,
94 HouseIcon,
95 bool: Save
96};
97
98enum e_interior
99{
100 IntName[MAX_INT_NAME],
101 Float: intX,
102 Float: intY,
103 Float: intZ,
104 intID,
105 Text3D: intLabel,
106 intPickup
107};
108
109enum e_furnituredata
110{
111 ModelID,
112 Name[32],
113 Price
114};
115
116enum e_furniture
117{
118 SQLID,
119 HouseID,
120 ArrayID,
121 Float: furnitureX,
122 Float: furnitureY,
123 Float: furnitureZ,
124 Float: furnitureRX,
125 Float: furnitureRY,
126 Float: furnitureRZ
127};
128
129enum e_sazone
130{
131 SAZONE_NAME[28],
132 Float: SAZONE_AREA[6]
133};
134
135new
136 SQLHandle,
137 HouseTimer = -1,
138 HouseData[MAX_HOUSES][e_house],
139 Iterator: Houses<MAX_HOUSES>,
140 Iterator: HouseKeys[MAX_PLAYERS]<MAX_HOUSES>,
141 InHouse[MAX_PLAYERS] = {INVALID_HOUSE_ID, ...},
142 SelectMode[MAX_PLAYERS] = {SELECT_MODE_NONE, ...},
143 LastVisitedHouse[MAX_PLAYERS] = {INVALID_HOUSE_ID, ...},
144 ListPage[MAX_PLAYERS] = {0, ...},
145 bool: EditingFurniture[MAX_PLAYERS] = {false, ...};
146
147new
148 HouseInteriors[][e_interior] = {
149 // int name, x, y, z, intid
150 {"Interior 1", 2233.4900, -1114.4435, 1050.8828, 5},
151 {"Interior 2", 2196.3943, -1204.1359, 1049.0234, 6},
152 {"Interior 3", 2318.1616, -1026.3762, 1050.2109, 9},
153 {"Interior 4", 421.8333, 2536.9814, 10.0000, 10},
154 {"Interior 5", 225.5707, 1240.0643, 1082.1406, 2},
155 {"Interior 6", 2496.2087, -1692.3149, 1014.7422, 3},
156 {"Interior 7", 226.7545, 1114.4180, 1080.9952, 5},
157 {"Interior 8", 2269.9636, -1210.3275, 1047.5625, 10}
158 };
159
160new
161 HouseFurnitures[][e_furnituredata] = {
162 // modelid, furniture name, price
163 {3111, "Building Plan", 500},
164 {2894, "Book", 20},
165 {2277, "Cat Picture", 100},
166 {1753, "Leather Couch", 150},
167 {1703, "Black Couch", 200},
168 {1255, "Lounger", 75},
169 {19581, "Frying Pan", 10},
170 {19584, "Sauce Pan", 12},
171 {19590, "Woozie's Sword", 1000},
172 {19525, "Wedding Cake", 50},
173 {1742, "Bookshelf", 80},
174 {1518, "TV 1", 130},
175 {19609, "Drum Kit", 500},
176 {19787, "Small LCD TV", 2000},
177 {19786, "Big LCD TV", 4000},
178 {2627, "Treadmill", 130}
179 };
180
181new
182 SAZones[][e_sazone] = {
183 {"The Big Ear", {-410.00,1403.30,-3.00,-137.90,1681.20,200.00}},
184 {"Aldea Malvada", {-1372.10,2498.50,0.00,-1277.50,2615.30,200.00}},
185 {"Angel Pine", {-2324.90,-2584.20,-6.10,-1964.20,-2212.10,200.00}},
186 {"Arco del Oeste", {-901.10,2221.80,0.00,-592.00,2571.90,200.00}},
187 {"Avispa Country Club", {-2646.40,-355.40,0.00,-2270.00,-222.50,200.00}},
188 {"Avispa Country Club", {-2831.80,-430.20,-6.10,-2646.40,-222.50,200.00}},
189 {"Avispa Country Club", {-2361.50,-417.10,0.00,-2270.00,-355.40,200.00}},
190 {"Avispa Country Club", {-2667.80,-302.10,-28.80,-2646.40,-262.30,71.10}},
191 {"Avispa Country Club", {-2470.00,-355.40,0.00,-2270.00,-318.40,46.10}},
192 {"Avispa Country Club", {-2550.00,-355.40,0.00,-2470.00,-318.40,39.70}},
193 {"Back o Beyond", {-1166.90,-2641.10,0.00,-321.70,-1856.00,200.00}},
194 {"Battery Point", {-2741.00,1268.40,-4.50,-2533.00,1490.40,200.00}},
195 {"Bayside", {-2741.00,2175.10,0.00,-2353.10,2722.70,200.00}},
196 {"Bayside Marina", {-2353.10,2275.70,0.00,-2153.10,2475.70,200.00}},
197 {"Beacon Hill", {-399.60,-1075.50,-1.40,-319.00,-977.50,198.50}},
198 {"Blackfield", {964.30,1203.20,-89.00,1197.30,1403.20,110.90}},
199 {"Blackfield", {964.30,1403.20,-89.00,1197.30,1726.20,110.90}},
200 {"Blackfield Chapel", {1375.60,596.30,-89.00,1558.00,823.20,110.90}},
201 {"Blackfield Chapel", {1325.60,596.30,-89.00,1375.60,795.00,110.90}},
202 {"Blackfield Intersection", {1197.30,1044.60,-89.00,1277.00,1163.30,110.90}},
203 {"Blackfield Intersection", {1166.50,795.00,-89.00,1375.60,1044.60,110.90}},
204 {"Blackfield Intersection", {1277.00,1044.60,-89.00,1315.30,1087.60,110.90}},
205 {"Blackfield Intersection", {1375.60,823.20,-89.00,1457.30,919.40,110.90}},
206 {"Blueberry", {104.50,-220.10,2.30,349.60,152.20,200.00}},
207 {"Blueberry", {19.60,-404.10,3.80,349.60,-220.10,200.00}},
208 {"Blueberry Acres", {-319.60,-220.10,0.00,104.50,293.30,200.00}},
209 {"Caligula's Palace", {2087.30,1543.20,-89.00,2437.30,1703.20,110.90}},
210 {"Caligula's Palace", {2137.40,1703.20,-89.00,2437.30,1783.20,110.90}},
211 {"Calton Heights", {-2274.10,744.10,-6.10,-1982.30,1358.90,200.00}},
212 {"Chinatown", {-2274.10,578.30,-7.60,-2078.60,744.10,200.00}},
213 {"City Hall", {-2867.80,277.40,-9.10,-2593.40,458.40,200.00}},
214 {"Come-A-Lot", {2087.30,943.20,-89.00,2623.10,1203.20,110.90}},
215 {"Commerce", {1323.90,-1842.20,-89.00,1701.90,-1722.20,110.90}},
216 {"Commerce", {1323.90,-1722.20,-89.00,1440.90,-1577.50,110.90}},
217 {"Commerce", {1370.80,-1577.50,-89.00,1463.90,-1384.90,110.90}},
218 {"Commerce", {1463.90,-1577.50,-89.00,1667.90,-1430.80,110.90}},
219 {"Commerce", {1583.50,-1722.20,-89.00,1758.90,-1577.50,110.90}},
220 {"Commerce", {1667.90,-1577.50,-89.00,1812.60,-1430.80,110.90}},
221 {"Conference Center", {1046.10,-1804.20,-89.00,1323.90,-1722.20,110.90}},
222 {"Conference Center", {1073.20,-1842.20,-89.00,1323.90,-1804.20,110.90}},
223 {"Cranberry Station", {-2007.80,56.30,0.00,-1922.00,224.70,100.00}},
224 {"Creek", {2749.90,1937.20,-89.00,2921.60,2669.70,110.90}},
225 {"Dillimore", {580.70,-674.80,-9.50,861.00,-404.70,200.00}},
226 {"Doherty", {-2270.00,-324.10,-0.00,-1794.90,-222.50,200.00}},
227 {"Doherty", {-2173.00,-222.50,-0.00,-1794.90,265.20,200.00}},
228 {"Downtown", {-1982.30,744.10,-6.10,-1871.70,1274.20,200.00}},
229 {"Downtown", {-1871.70,1176.40,-4.50,-1620.30,1274.20,200.00}},
230 {"Downtown", {-1700.00,744.20,-6.10,-1580.00,1176.50,200.00}},
231 {"Downtown", {-1580.00,744.20,-6.10,-1499.80,1025.90,200.00}},
232 {"Downtown", {-2078.60,578.30,-7.60,-1499.80,744.20,200.00}},
233 {"Downtown", {-1993.20,265.20,-9.10,-1794.90,578.30,200.00}},
234 {"Downtown Los Santos", {1463.90,-1430.80,-89.00,1724.70,-1290.80,110.90}},
235 {"Downtown Los Santos", {1724.70,-1430.80,-89.00,1812.60,-1250.90,110.90}},
236 {"Downtown Los Santos", {1463.90,-1290.80,-89.00,1724.70,-1150.80,110.90}},
237 {"Downtown Los Santos", {1370.80,-1384.90,-89.00,1463.90,-1170.80,110.90}},
238 {"Downtown Los Santos", {1724.70,-1250.90,-89.00,1812.60,-1150.80,110.90}},
239 {"Downtown Los Santos", {1370.80,-1170.80,-89.00,1463.90,-1130.80,110.90}},
240 {"Downtown Los Santos", {1378.30,-1130.80,-89.00,1463.90,-1026.30,110.90}},
241 {"Downtown Los Santos", {1391.00,-1026.30,-89.00,1463.90,-926.90,110.90}},
242 {"Downtown Los Santos", {1507.50,-1385.20,110.90,1582.50,-1325.30,335.90}},
243 {"East Beach", {2632.80,-1852.80,-89.00,2959.30,-1668.10,110.90}},
244 {"East Beach", {2632.80,-1668.10,-89.00,2747.70,-1393.40,110.90}},
245 {"East Beach", {2747.70,-1668.10,-89.00,2959.30,-1498.60,110.90}},
246 {"East Beach", {2747.70,-1498.60,-89.00,2959.30,-1120.00,110.90}},
247 {"East Los Santos", {2421.00,-1628.50,-89.00,2632.80,-1454.30,110.90}},
248 {"East Los Santos", {2222.50,-1628.50,-89.00,2421.00,-1494.00,110.90}},
249 {"East Los Santos", {2266.20,-1494.00,-89.00,2381.60,-1372.00,110.90}},
250 {"East Los Santos", {2381.60,-1494.00,-89.00,2421.00,-1454.30,110.90}},
251 {"East Los Santos", {2281.40,-1372.00,-89.00,2381.60,-1135.00,110.90}},
252 {"East Los Santos", {2381.60,-1454.30,-89.00,2462.10,-1135.00,110.90}},
253 {"East Los Santos", {2462.10,-1454.30,-89.00,2581.70,-1135.00,110.90}},
254 {"Easter Basin", {-1794.90,249.90,-9.10,-1242.90,578.30,200.00}},
255 {"Easter Basin", {-1794.90,-50.00,-0.00,-1499.80,249.90,200.00}},
256 {"Easter Bay Airport", {-1499.80,-50.00,-0.00,-1242.90,249.90,200.00}},
257 {"Easter Bay Airport", {-1794.90,-730.10,-3.00,-1213.90,-50.00,200.00}},
258 {"Easter Bay Airport", {-1213.90,-730.10,0.00,-1132.80,-50.00,200.00}},
259 {"Easter Bay Airport", {-1242.90,-50.00,0.00,-1213.90,578.30,200.00}},
260 {"Easter Bay Airport", {-1213.90,-50.00,-4.50,-947.90,578.30,200.00}},
261 {"Easter Bay Airport", {-1315.40,-405.30,15.40,-1264.40,-209.50,25.40}},
262 {"Easter Bay Airport", {-1354.30,-287.30,15.40,-1315.40,-209.50,25.40}},
263 {"Easter Bay Airport", {-1490.30,-209.50,15.40,-1264.40,-148.30,25.40}},
264 {"Easter Bay Chemicals", {-1132.80,-768.00,0.00,-956.40,-578.10,200.00}},
265 {"Easter Bay Chemicals", {-1132.80,-787.30,0.00,-956.40,-768.00,200.00}},
266 {"El Castillo del Diablo", {-464.50,2217.60,0.00,-208.50,2580.30,200.00}},
267 {"El Castillo del Diablo", {-208.50,2123.00,-7.60,114.00,2337.10,200.00}},
268 {"El Castillo del Diablo", {-208.50,2337.10,0.00,8.40,2487.10,200.00}},
269 {"El Corona", {1812.60,-2179.20,-89.00,1970.60,-1852.80,110.90}},
270 {"El Corona", {1692.60,-2179.20,-89.00,1812.60,-1842.20,110.90}},
271 {"El Quebrados", {-1645.20,2498.50,0.00,-1372.10,2777.80,200.00}},
272 {"Esplanade East", {-1620.30,1176.50,-4.50,-1580.00,1274.20,200.00}},
273 {"Esplanade East", {-1580.00,1025.90,-6.10,-1499.80,1274.20,200.00}},
274 {"Esplanade East", {-1499.80,578.30,-79.60,-1339.80,1274.20,20.30}},
275 {"Esplanade North", {-2533.00,1358.90,-4.50,-1996.60,1501.20,200.00}},
276 {"Esplanade North", {-1996.60,1358.90,-4.50,-1524.20,1592.50,200.00}},
277 {"Esplanade North", {-1982.30,1274.20,-4.50,-1524.20,1358.90,200.00}},
278 {"Fallen Tree", {-792.20,-698.50,-5.30,-452.40,-380.00,200.00}},
279 {"Fallow Bridge", {434.30,366.50,0.00,603.00,555.60,200.00}},
280 {"Fern Ridge", {508.10,-139.20,0.00,1306.60,119.50,200.00}},
281 {"Financial", {-1871.70,744.10,-6.10,-1701.30,1176.40,300.00}},
282 {"Fisher's Lagoon", {1916.90,-233.30,-100.00,2131.70,13.80,200.00}},
283 {"Flint Intersection", {-187.70,-1596.70,-89.00,17.00,-1276.60,110.90}},
284 {"Flint Range", {-594.10,-1648.50,0.00,-187.70,-1276.60,200.00}},
285 {"Fort Carson", {-376.20,826.30,-3.00,123.70,1220.40,200.00}},
286 {"Foster Valley", {-2270.00,-430.20,-0.00,-2178.60,-324.10,200.00}},
287 {"Foster Valley", {-2178.60,-599.80,-0.00,-1794.90,-324.10,200.00}},
288 {"Foster Valley", {-2178.60,-1115.50,0.00,-1794.90,-599.80,200.00}},
289 {"Foster Valley", {-2178.60,-1250.90,0.00,-1794.90,-1115.50,200.00}},
290 {"Frederick Bridge", {2759.20,296.50,0.00,2774.20,594.70,200.00}},
291 {"Gant Bridge", {-2741.40,1659.60,-6.10,-2616.40,2175.10,200.00}},
292 {"Gant Bridge", {-2741.00,1490.40,-6.10,-2616.40,1659.60,200.00}},
293 {"Ganton", {2222.50,-1852.80,-89.00,2632.80,-1722.30,110.90}},
294 {"Ganton", {2222.50,-1722.30,-89.00,2632.80,-1628.50,110.90}},
295 {"Garcia", {-2411.20,-222.50,-0.00,-2173.00,265.20,200.00}},
296 {"Garcia", {-2395.10,-222.50,-5.30,-2354.00,-204.70,200.00}},
297 {"Garver Bridge", {-1339.80,828.10,-89.00,-1213.90,1057.00,110.90}},
298 {"Garver Bridge", {-1213.90,950.00,-89.00,-1087.90,1178.90,110.90}},
299 {"Garver Bridge", {-1499.80,696.40,-179.60,-1339.80,925.30,20.30}},
300 {"Glen Park", {1812.60,-1449.60,-89.00,1996.90,-1350.70,110.90}},
301 {"Glen Park", {1812.60,-1100.80,-89.00,1994.30,-973.30,110.90}},
302 {"Glen Park", {1812.60,-1350.70,-89.00,2056.80,-1100.80,110.90}},
303 {"Green Palms", {176.50,1305.40,-3.00,338.60,1520.70,200.00}},
304 {"Greenglass College", {964.30,1044.60,-89.00,1197.30,1203.20,110.90}},
305 {"Greenglass College", {964.30,930.80,-89.00,1166.50,1044.60,110.90}},
306 {"Hampton Barns", {603.00,264.30,0.00,761.90,366.50,200.00}},
307 {"Hankypanky Point", {2576.90,62.10,0.00,2759.20,385.50,200.00}},
308 {"Harry Gold Parkway", {1777.30,863.20,-89.00,1817.30,2342.80,110.90}},
309 {"Hashbury", {-2593.40,-222.50,-0.00,-2411.20,54.70,200.00}},
310 {"Hilltop Farm", {967.30,-450.30,-3.00,1176.70,-217.90,200.00}},
311 {"Hunter Quarry", {337.20,710.80,-115.20,860.50,1031.70,203.70}},
312 {"Idlewood", {1812.60,-1852.80,-89.00,1971.60,-1742.30,110.90}},
313 {"Idlewood", {1812.60,-1742.30,-89.00,1951.60,-1602.30,110.90}},
314 {"Idlewood", {1951.60,-1742.30,-89.00,2124.60,-1602.30,110.90}},
315 {"Idlewood", {1812.60,-1602.30,-89.00,2124.60,-1449.60,110.90}},
316 {"Idlewood", {2124.60,-1742.30,-89.00,2222.50,-1494.00,110.90}},
317 {"Idlewood", {1971.60,-1852.80,-89.00,2222.50,-1742.30,110.90}},
318 {"Jefferson", {1996.90,-1449.60,-89.00,2056.80,-1350.70,110.90}},
319 {"Jefferson", {2124.60,-1494.00,-89.00,2266.20,-1449.60,110.90}},
320 {"Jefferson", {2056.80,-1372.00,-89.00,2281.40,-1210.70,110.90}},
321 {"Jefferson", {2056.80,-1210.70,-89.00,2185.30,-1126.30,110.90}},
322 {"Jefferson", {2185.30,-1210.70,-89.00,2281.40,-1154.50,110.90}},
323 {"Jefferson", {2056.80,-1449.60,-89.00,2266.20,-1372.00,110.90}},
324 {"Julius Thruway East", {2623.10,943.20,-89.00,2749.90,1055.90,110.90}},
325 {"Julius Thruway East", {2685.10,1055.90,-89.00,2749.90,2626.50,110.90}},
326 {"Julius Thruway East", {2536.40,2442.50,-89.00,2685.10,2542.50,110.90}},
327 {"Julius Thruway East", {2625.10,2202.70,-89.00,2685.10,2442.50,110.90}},
328 {"Julius Thruway North", {2498.20,2542.50,-89.00,2685.10,2626.50,110.90}},
329 {"Julius Thruway North", {2237.40,2542.50,-89.00,2498.20,2663.10,110.90}},
330 {"Julius Thruway North", {2121.40,2508.20,-89.00,2237.40,2663.10,110.90}},
331 {"Julius Thruway North", {1938.80,2508.20,-89.00,2121.40,2624.20,110.90}},
332 {"Julius Thruway North", {1534.50,2433.20,-89.00,1848.40,2583.20,110.90}},
333 {"Julius Thruway North", {1848.40,2478.40,-89.00,1938.80,2553.40,110.90}},
334 {"Julius Thruway North", {1704.50,2342.80,-89.00,1848.40,2433.20,110.90}},
335 {"Julius Thruway North", {1377.30,2433.20,-89.00,1534.50,2507.20,110.90}},
336 {"Julius Thruway South", {1457.30,823.20,-89.00,2377.30,863.20,110.90}},
337 {"Julius Thruway South", {2377.30,788.80,-89.00,2537.30,897.90,110.90}},
338 {"Julius Thruway West", {1197.30,1163.30,-89.00,1236.60,2243.20,110.90}},
339 {"Julius Thruway West", {1236.60,2142.80,-89.00,1297.40,2243.20,110.90}},
340 {"Juniper Hill", {-2533.00,578.30,-7.60,-2274.10,968.30,200.00}},
341 {"Juniper Hollow", {-2533.00,968.30,-6.10,-2274.10,1358.90,200.00}},
342 {"K.A.C.C. Military Fuels", {2498.20,2626.50,-89.00,2749.90,2861.50,110.90}},
343 {"Kincaid Bridge", {-1339.80,599.20,-89.00,-1213.90,828.10,110.90}},
344 {"Kincaid Bridge", {-1213.90,721.10,-89.00,-1087.90,950.00,110.90}},
345 {"Kincaid Bridge", {-1087.90,855.30,-89.00,-961.90,986.20,110.90}},
346 {"King's", {-2329.30,458.40,-7.60,-1993.20,578.30,200.00}},
347 {"King's", {-2411.20,265.20,-9.10,-1993.20,373.50,200.00}},
348 {"King's", {-2253.50,373.50,-9.10,-1993.20,458.40,200.00}},
349 {"LVA Freight Depot", {1457.30,863.20,-89.00,1777.40,1143.20,110.90}},
350 {"LVA Freight Depot", {1375.60,919.40,-89.00,1457.30,1203.20,110.90}},
351 {"LVA Freight Depot", {1277.00,1087.60,-89.00,1375.60,1203.20,110.90}},
352 {"LVA Freight Depot", {1315.30,1044.60,-89.00,1375.60,1087.60,110.90}},
353 {"LVA Freight Depot", {1236.60,1163.40,-89.00,1277.00,1203.20,110.90}},
354 {"Las Barrancas", {-926.10,1398.70,-3.00,-719.20,1634.60,200.00}},
355 {"Las Brujas", {-365.10,2123.00,-3.00,-208.50,2217.60,200.00}},
356 {"Las Colinas", {1994.30,-1100.80,-89.00,2056.80,-920.80,110.90}},
357 {"Las Colinas", {2056.80,-1126.30,-89.00,2126.80,-920.80,110.90}},
358 {"Las Colinas", {2185.30,-1154.50,-89.00,2281.40,-934.40,110.90}},
359 {"Las Colinas", {2126.80,-1126.30,-89.00,2185.30,-934.40,110.90}},
360 {"Las Colinas", {2747.70,-1120.00,-89.00,2959.30,-945.00,110.90}},
361 {"Las Colinas", {2632.70,-1135.00,-89.00,2747.70,-945.00,110.90}},
362 {"Las Colinas", {2281.40,-1135.00,-89.00,2632.70,-945.00,110.90}},
363 {"Las Payasadas", {-354.30,2580.30,2.00,-133.60,2816.80,200.00}},
364 {"Las Venturas Airport", {1236.60,1203.20,-89.00,1457.30,1883.10,110.90}},
365 {"Las Venturas Airport", {1457.30,1203.20,-89.00,1777.30,1883.10,110.90}},
366 {"Las Venturas Airport", {1457.30,1143.20,-89.00,1777.40,1203.20,110.90}},
367 {"Las Venturas Airport", {1515.80,1586.40,-12.50,1729.90,1714.50,87.50}},
368 {"Last Dime Motel", {1823.00,596.30,-89.00,1997.20,823.20,110.90}},
369 {"Leafy Hollow", {-1166.90,-1856.00,0.00,-815.60,-1602.00,200.00}},
370 {"Liberty City", {-1000.00,400.00,1300.00,-700.00,600.00,1400.00}},
371 {"Lil' Probe Inn", {-90.20,1286.80,-3.00,153.80,1554.10,200.00}},
372 {"Linden Side", {2749.90,943.20,-89.00,2923.30,1198.90,110.90}},
373 {"Linden Station", {2749.90,1198.90,-89.00,2923.30,1548.90,110.90}},
374 {"Linden Station", {2811.20,1229.50,-39.50,2861.20,1407.50,60.40}},
375 {"Little Mexico", {1701.90,-1842.20,-89.00,1812.60,-1722.20,110.90}},
376 {"Little Mexico", {1758.90,-1722.20,-89.00,1812.60,-1577.50,110.90}},
377 {"Los Flores", {2581.70,-1454.30,-89.00,2632.80,-1393.40,110.90}},
378 {"Los Flores", {2581.70,-1393.40,-89.00,2747.70,-1135.00,110.90}},
379 {"Los Santos International", {1249.60,-2394.30,-89.00,1852.00,-2179.20,110.90}},
380 {"Los Santos International", {1852.00,-2394.30,-89.00,2089.00,-2179.20,110.90}},
381 {"Los Santos International", {1382.70,-2730.80,-89.00,2201.80,-2394.30,110.90}},
382 {"Los Santos International", {1974.60,-2394.30,-39.00,2089.00,-2256.50,60.90}},
383 {"Los Santos International", {1400.90,-2669.20,-39.00,2189.80,-2597.20,60.90}},
384 {"Los Santos International", {2051.60,-2597.20,-39.00,2152.40,-2394.30,60.90}},
385 {"Marina", {647.70,-1804.20,-89.00,851.40,-1577.50,110.90}},
386 {"Marina", {647.70,-1577.50,-89.00,807.90,-1416.20,110.90}},
387 {"Marina", {807.90,-1577.50,-89.00,926.90,-1416.20,110.90}},
388 {"Market", {787.40,-1416.20,-89.00,1072.60,-1310.20,110.90}},
389 {"Market", {952.60,-1310.20,-89.00,1072.60,-1130.80,110.90}},
390 {"Market", {1072.60,-1416.20,-89.00,1370.80,-1130.80,110.90}},
391 {"Market", {926.90,-1577.50,-89.00,1370.80,-1416.20,110.90}},
392 {"Market Station", {787.40,-1410.90,-34.10,866.00,-1310.20,65.80}},
393 {"Martin Bridge", {-222.10,293.30,0.00,-122.10,476.40,200.00}},
394 {"Missionary Hill", {-2994.40,-811.20,0.00,-2178.60,-430.20,200.00}},
395 {"Montgomery", {1119.50,119.50,-3.00,1451.40,493.30,200.00}},
396 {"Montgomery", {1451.40,347.40,-6.10,1582.40,420.80,200.00}},
397 {"Montgomery Intersection", {1546.60,208.10,0.00,1745.80,347.40,200.00}},
398 {"Montgomery Intersection", {1582.40,347.40,0.00,1664.60,401.70,200.00}},
399 {"Mulholland", {1414.00,-768.00,-89.00,1667.60,-452.40,110.90}},
400 {"Mulholland", {1281.10,-452.40,-89.00,1641.10,-290.90,110.90}},
401 {"Mulholland", {1269.10,-768.00,-89.00,1414.00,-452.40,110.90}},
402 {"Mulholland", {1357.00,-926.90,-89.00,1463.90,-768.00,110.90}},
403 {"Mulholland", {1318.10,-910.10,-89.00,1357.00,-768.00,110.90}},
404 {"Mulholland", {1169.10,-910.10,-89.00,1318.10,-768.00,110.90}},
405 {"Mulholland", {768.60,-954.60,-89.00,952.60,-860.60,110.90}},
406 {"Mulholland", {687.80,-860.60,-89.00,911.80,-768.00,110.90}},
407 {"Mulholland", {737.50,-768.00,-89.00,1142.20,-674.80,110.90}},
408 {"Mulholland", {1096.40,-910.10,-89.00,1169.10,-768.00,110.90}},
409 {"Mulholland", {952.60,-937.10,-89.00,1096.40,-860.60,110.90}},
410 {"Mulholland", {911.80,-860.60,-89.00,1096.40,-768.00,110.90}},
411 {"Mulholland", {861.00,-674.80,-89.00,1156.50,-600.80,110.90}},
412 {"Mulholland Intersection", {1463.90,-1150.80,-89.00,1812.60,-768.00,110.90}},
413 {"North Rock", {2285.30,-768.00,0.00,2770.50,-269.70,200.00}},
414 {"Ocean Docks", {2373.70,-2697.00,-89.00,2809.20,-2330.40,110.90}},
415 {"Ocean Docks", {2201.80,-2418.30,-89.00,2324.00,-2095.00,110.90}},
416 {"Ocean Docks", {2324.00,-2302.30,-89.00,2703.50,-2145.10,110.90}},
417 {"Ocean Docks", {2089.00,-2394.30,-89.00,2201.80,-2235.80,110.90}},
418 {"Ocean Docks", {2201.80,-2730.80,-89.00,2324.00,-2418.30,110.90}},
419 {"Ocean Docks", {2703.50,-2302.30,-89.00,2959.30,-2126.90,110.90}},
420 {"Ocean Docks", {2324.00,-2145.10,-89.00,2703.50,-2059.20,110.90}},
421 {"Ocean Flats", {-2994.40,277.40,-9.10,-2867.80,458.40,200.00}},
422 {"Ocean Flats", {-2994.40,-222.50,-0.00,-2593.40,277.40,200.00}},
423 {"Ocean Flats", {-2994.40,-430.20,-0.00,-2831.80,-222.50,200.00}},
424 {"Octane Springs", {338.60,1228.50,0.00,664.30,1655.00,200.00}},
425 {"Old Venturas Strip", {2162.30,2012.10,-89.00,2685.10,2202.70,110.90}},
426 {"Palisades", {-2994.40,458.40,-6.10,-2741.00,1339.60,200.00}},
427 {"Palomino Creek", {2160.20,-149.00,0.00,2576.90,228.30,200.00}},
428 {"Paradiso", {-2741.00,793.40,-6.10,-2533.00,1268.40,200.00}},
429 {"Pershing Square", {1440.90,-1722.20,-89.00,1583.50,-1577.50,110.90}},
430 {"Pilgrim", {2437.30,1383.20,-89.00,2624.40,1783.20,110.90}},
431 {"Pilgrim", {2624.40,1383.20,-89.00,2685.10,1783.20,110.90}},
432 {"Pilson Intersection", {1098.30,2243.20,-89.00,1377.30,2507.20,110.90}},
433 {"Pirates in Men's Pants", {1817.30,1469.20,-89.00,2027.40,1703.20,110.90}},
434 {"Playa del Seville", {2703.50,-2126.90,-89.00,2959.30,-1852.80,110.90}},
435 {"Prickle Pine", {1534.50,2583.20,-89.00,1848.40,2863.20,110.90}},
436 {"Prickle Pine", {1117.40,2507.20,-89.00,1534.50,2723.20,110.90}},
437 {"Prickle Pine", {1848.40,2553.40,-89.00,1938.80,2863.20,110.90}},
438 {"Prickle Pine", {1938.80,2624.20,-89.00,2121.40,2861.50,110.90}},
439 {"Queens", {-2533.00,458.40,0.00,-2329.30,578.30,200.00}},
440 {"Queens", {-2593.40,54.70,0.00,-2411.20,458.40,200.00}},
441 {"Queens", {-2411.20,373.50,0.00,-2253.50,458.40,200.00}},
442 {"Randolph Industrial Estate", {1558.00,596.30,-89.00,1823.00,823.20,110.90}},
443 {"Redsands East", {1817.30,2011.80,-89.00,2106.70,2202.70,110.90}},
444 {"Redsands East", {1817.30,2202.70,-89.00,2011.90,2342.80,110.90}},
445 {"Redsands East", {1848.40,2342.80,-89.00,2011.90,2478.40,110.90}},
446 {"Redsands West", {1236.60,1883.10,-89.00,1777.30,2142.80,110.90}},
447 {"Redsands West", {1297.40,2142.80,-89.00,1777.30,2243.20,110.90}},
448 {"Redsands West", {1377.30,2243.20,-89.00,1704.50,2433.20,110.90}},
449 {"Redsands West", {1704.50,2243.20,-89.00,1777.30,2342.80,110.90}},
450 {"Regular Tom", {-405.70,1712.80,-3.00,-276.70,1892.70,200.00}},
451 {"Richman", {647.50,-1118.20,-89.00,787.40,-954.60,110.90}},
452 {"Richman", {647.50,-954.60,-89.00,768.60,-860.60,110.90}},
453 {"Richman", {225.10,-1369.60,-89.00,334.50,-1292.00,110.90}},
454 {"Richman", {225.10,-1292.00,-89.00,466.20,-1235.00,110.90}},
455 {"Richman", {72.60,-1404.90,-89.00,225.10,-1235.00,110.90}},
456 {"Richman", {72.60,-1235.00,-89.00,321.30,-1008.10,110.90}},
457 {"Richman", {321.30,-1235.00,-89.00,647.50,-1044.00,110.90}},
458 {"Richman", {321.30,-1044.00,-89.00,647.50,-860.60,110.90}},
459 {"Richman", {321.30,-860.60,-89.00,687.80,-768.00,110.90}},
460 {"Richman", {321.30,-768.00,-89.00,700.70,-674.80,110.90}},
461 {"Robada Intersection", {-1119.00,1178.90,-89.00,-862.00,1351.40,110.90}},
462 {"Roca Escalante", {2237.40,2202.70,-89.00,2536.40,2542.50,110.90}},
463 {"Roca Escalante", {2536.40,2202.70,-89.00,2625.10,2442.50,110.90}},
464 {"Rockshore East", {2537.30,676.50,-89.00,2902.30,943.20,110.90}},
465 {"Rockshore West", {1997.20,596.30,-89.00,2377.30,823.20,110.90}},
466 {"Rockshore West", {2377.30,596.30,-89.00,2537.30,788.80,110.90}},
467 {"Rodeo", {72.60,-1684.60,-89.00,225.10,-1544.10,110.90}},
468 {"Rodeo", {72.60,-1544.10,-89.00,225.10,-1404.90,110.90}},
469 {"Rodeo", {225.10,-1684.60,-89.00,312.80,-1501.90,110.90}},
470 {"Rodeo", {225.10,-1501.90,-89.00,334.50,-1369.60,110.90}},
471 {"Rodeo", {334.50,-1501.90,-89.00,422.60,-1406.00,110.90}},
472 {"Rodeo", {312.80,-1684.60,-89.00,422.60,-1501.90,110.90}},
473 {"Rodeo", {422.60,-1684.60,-89.00,558.00,-1570.20,110.90}},
474 {"Rodeo", {558.00,-1684.60,-89.00,647.50,-1384.90,110.90}},
475 {"Rodeo", {466.20,-1570.20,-89.00,558.00,-1385.00,110.90}},
476 {"Rodeo", {422.60,-1570.20,-89.00,466.20,-1406.00,110.90}},
477 {"Rodeo", {466.20,-1385.00,-89.00,647.50,-1235.00,110.90}},
478 {"Rodeo", {334.50,-1406.00,-89.00,466.20,-1292.00,110.90}},
479 {"Royal Casino", {2087.30,1383.20,-89.00,2437.30,1543.20,110.90}},
480 {"San Andreas Sound", {2450.30,385.50,-100.00,2759.20,562.30,200.00}},
481 {"Santa Flora", {-2741.00,458.40,-7.60,-2533.00,793.40,200.00}},
482 {"Santa Maria Beach", {342.60,-2173.20,-89.00,647.70,-1684.60,110.90}},
483 {"Santa Maria Beach", {72.60,-2173.20,-89.00,342.60,-1684.60,110.90}},
484 {"Shady Cabin", {-1632.80,-2263.40,-3.00,-1601.30,-2231.70,200.00}},
485 {"Shady Creeks", {-1820.60,-2643.60,-8.00,-1226.70,-1771.60,200.00}},
486 {"Shady Creeks", {-2030.10,-2174.80,-6.10,-1820.60,-1771.60,200.00}},
487 {"Sobell Rail Yards", {2749.90,1548.90,-89.00,2923.30,1937.20,110.90}},
488 {"Spinybed", {2121.40,2663.10,-89.00,2498.20,2861.50,110.90}},
489 {"Starfish Casino", {2437.30,1783.20,-89.00,2685.10,2012.10,110.90}},
490 {"Starfish Casino", {2437.30,1858.10,-39.00,2495.00,1970.80,60.90}},
491 {"Starfish Casino", {2162.30,1883.20,-89.00,2437.30,2012.10,110.90}},
492 {"Temple", {1252.30,-1130.80,-89.00,1378.30,-1026.30,110.90}},
493 {"Temple", {1252.30,-1026.30,-89.00,1391.00,-926.90,110.90}},
494 {"Temple", {1252.30,-926.90,-89.00,1357.00,-910.10,110.90}},
495 {"Temple", {952.60,-1130.80,-89.00,1096.40,-937.10,110.90}},
496 {"Temple", {1096.40,-1130.80,-89.00,1252.30,-1026.30,110.90}},
497 {"Temple", {1096.40,-1026.30,-89.00,1252.30,-910.10,110.90}},
498 {"The Camel's Toe", {2087.30,1203.20,-89.00,2640.40,1383.20,110.90}},
499 {"The Clown's Pocket", {2162.30,1783.20,-89.00,2437.30,1883.20,110.90}},
500 {"The Emerald Isle", {2011.90,2202.70,-89.00,2237.40,2508.20,110.90}},
501 {"The Farm", {-1209.60,-1317.10,114.90,-908.10,-787.30,251.90}},
502 {"The Four Dragons Casino", {1817.30,863.20,-89.00,2027.30,1083.20,110.90}},
503 {"The High Roller", {1817.30,1283.20,-89.00,2027.30,1469.20,110.90}},
504 {"The Mako Span", {1664.60,401.70,0.00,1785.10,567.20,200.00}},
505 {"The Panopticon", {-947.90,-304.30,-1.10,-319.60,327.00,200.00}},
506 {"The Pink Swan", {1817.30,1083.20,-89.00,2027.30,1283.20,110.90}},
507 {"The Sherman Dam", {-968.70,1929.40,-3.00,-481.10,2155.20,200.00}},
508 {"The Strip", {2027.40,863.20,-89.00,2087.30,1703.20,110.90}},
509 {"The Strip", {2106.70,1863.20,-89.00,2162.30,2202.70,110.90}},
510 {"The Strip", {2027.40,1783.20,-89.00,2162.30,1863.20,110.90}},
511 {"The Strip", {2027.40,1703.20,-89.00,2137.40,1783.20,110.90}},
512 {"The Visage", {1817.30,1863.20,-89.00,2106.70,2011.80,110.90}},
513 {"The Visage", {1817.30,1703.20,-89.00,2027.40,1863.20,110.90}},
514 {"Unity Station", {1692.60,-1971.80,-20.40,1812.60,-1932.80,79.50}},
515 {"Valle Ocultado", {-936.60,2611.40,2.00,-715.90,2847.90,200.00}},
516 {"Verdant Bluffs", {930.20,-2488.40,-89.00,1249.60,-2006.70,110.90}},
517 {"Verdant Bluffs", {1073.20,-2006.70,-89.00,1249.60,-1842.20,110.90}},
518 {"Verdant Bluffs", {1249.60,-2179.20,-89.00,1692.60,-1842.20,110.90}},
519 {"Verdant Meadows", {37.00,2337.10,-3.00,435.90,2677.90,200.00}},
520 {"Verona Beach", {647.70,-2173.20,-89.00,930.20,-1804.20,110.90}},
521 {"Verona Beach", {930.20,-2006.70,-89.00,1073.20,-1804.20,110.90}},
522 {"Verona Beach", {851.40,-1804.20,-89.00,1046.10,-1577.50,110.90}},
523 {"Verona Beach", {1161.50,-1722.20,-89.00,1323.90,-1577.50,110.90}},
524 {"Verona Beach", {1046.10,-1722.20,-89.00,1161.50,-1577.50,110.90}},
525 {"Vinewood", {787.40,-1310.20,-89.00,952.60,-1130.80,110.90}},
526 {"Vinewood", {787.40,-1130.80,-89.00,952.60,-954.60,110.90}},
527 {"Vinewood", {647.50,-1227.20,-89.00,787.40,-1118.20,110.90}},
528 {"Vinewood", {647.70,-1416.20,-89.00,787.40,-1227.20,110.90}},
529 {"Whitewood Estates", {883.30,1726.20,-89.00,1098.30,2507.20,110.90}},
530 {"Whitewood Estates", {1098.30,1726.20,-89.00,1197.30,2243.20,110.90}},
531 {"Willowfield", {1970.60,-2179.20,-89.00,2089.00,-1852.80,110.90}},
532 {"Willowfield", {2089.00,-2235.80,-89.00,2201.80,-1989.90,110.90}},
533 {"Willowfield", {2089.00,-1989.90,-89.00,2324.00,-1852.80,110.90}},
534 {"Willowfield", {2201.80,-2095.00,-89.00,2324.00,-1989.90,110.90}},
535 {"Willowfield", {2541.70,-1941.40,-89.00,2703.50,-1852.80,110.90}},
536 {"Willowfield", {2324.00,-2059.20,-89.00,2541.70,-1852.80,110.90}},
537 {"Willowfield", {2541.70,-2059.20,-89.00,2703.50,-1941.40,110.90}},
538 {"Yellow Bell Station", {1377.40,2600.40,-21.90,1492.40,2687.30,78.00}},
539 {"Los Santos", {44.60,-2892.90,-242.90,2997.00,-768.00,900.00}},
540 {"Las Venturas", {869.40,596.30,-242.90,2997.00,2993.80,900.00}},
541 {"Bone County", {-480.50,596.30,-242.90,869.40,2993.80,900.00}},
542 {"Tierra Robada", {-2997.40,1659.60,-242.90,-480.50,2993.80,900.00}},
543 {"Tierra Robada", {-1213.90,596.30,-242.90,-480.50,1659.60,900.00}},
544 {"San Fierro", {-2997.40,-1115.50,-242.90,-1213.90,1659.60,900.00}},
545 {"Red County", {-1213.90,-768.00,-242.90,2997.00,596.30,900.00}},
546 {"Flint County", {-1213.90,-2892.90,-242.90,44.60,-768.00,900.00}},
547 {"Whetstone", {-2997.40,-2892.90,-242.90,-1213.90,-1115.50,900.00}}
548 };
549
550new
551 LockNames[4][32] = {"{2ECC71}Not Locked", "{E74C3C}Password Locked", "{E74C3C}Requires Keys", "{E74C3C}Owner Only"},
552 TransactionNames[2][16] = {"{E74C3C}Taken", "{2ECC71}Added"};
553
554stock LoadHouseKeys(playerid)
555{
556 Iter_Clear(HouseKeys[playerid]);
557
558 new query[72];
559 mysql_format(SQLHandle, query, sizeof(query), "SELECT * FROM housekeys WHERE Player='%e'", Player_GetName(playerid));
560 mysql_tquery(SQLHandle, query, "GiveHouseKeys", "i", playerid);
561 return 1;
562}
563
564stock GetZoneName(Float: x, Float: y, Float: z)
565{
566 new zone[28];
567 for(new i = 0; i < sizeof(SAZones); i++)
568 {
569 if(x >= SAZones[i][SAZONE_AREA][0] && x <= SAZones[i][SAZONE_AREA][3] && y >= SAZones[i][SAZONE_AREA][1] && y <= SAZones[i][SAZONE_AREA][4] && z >= SAZones[i][SAZONE_AREA][2] && z <= SAZones[i][SAZONE_AREA][5])
570 {
571 strcat(zone, SAZones[i][SAZONE_NAME]);
572 return zone;
573 }
574 }
575
576 strcat(zone, "Unknown");
577 return zone;
578}
579
580stock GetCityName(Float: x, Float: y, Float: z)
581{
582 new city[28];
583 for(new i = 356; i < sizeof(SAZones); i++)
584 {
585 if(x >= SAZones[i][SAZONE_AREA][0] && x <= SAZones[i][SAZONE_AREA][3] && y >= SAZones[i][SAZONE_AREA][1] && y <= SAZones[i][SAZONE_AREA][4] && z >= SAZones[i][SAZONE_AREA][2] && z <= SAZones[i][SAZONE_AREA][5])
586 {
587 strcat(city, SAZones[i][SAZONE_NAME]);
588 return city;
589 }
590 }
591
592 strcat(city, "San Andreas");
593 return city;
594}
595
596stock convertNumber(value)
597{
598 // http://forum.sa-mp.com/showthread.php?p=843781#post843781
599 new string[24];
600 format(string, sizeof(string), "%d", value);
601
602 for(new i = (strlen(string) - 3); i > (value < 0 ? 1 : 0) ; i -= 3)
603 {
604 strins(string[i], ",", 0);
605 }
606
607 return string;
608}
609
610stock RemovePlayerWeapon(playerid, weapon)
611{
612 new weapons[13], ammo[13];
613 for(new i; i < 13; i++) GetPlayerWeaponData(playerid, i, weapons[i], ammo[i]);
614 ResetPlayerWeapons(playerid);
615 for(new i; i < 13; i++)
616 {
617 if(weapons[i] == weapon) continue;
618 GivePlayerWeapon(playerid, weapons[i], ammo[i]);
619 }
620
621 return 1;
622}
623
624stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
625{
626 new Float: a;
627 GetPlayerPos(playerid, x, y, a);
628 GetPlayerFacingAngle(playerid, a);
629 if (GetPlayerVehicleID(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
630 x += (distance * floatsin(-a, degrees));
631 y += (distance * floatcos(-a, degrees));
632}
633
634stock Player_GetName(playerid)
635{
636 new name[MAX_PLAYER_NAME];
637 GetPlayerName(playerid, name, MAX_PLAYER_NAME);
638 return name;
639}
640
641stock SendToHouse(playerid, id)
642{
643 if(!Iter_Contains(Houses, id)) return 0;
644 SetPVarInt(playerid, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
645 InHouse[playerid] = id;
646 SetPlayerVirtualWorld(playerid, id);
647 SetPlayerInterior(playerid, HouseInteriors[ HouseData[id][Interior] ][intID]);
648 SetPlayerPos(playerid, HouseInteriors[ HouseData[id][Interior] ][intX], HouseInteriors[ HouseData[id][Interior] ][intY], HouseInteriors[ HouseData[id][Interior] ][intZ]);
649
650 new string[128];
651 format(string, sizeof(string), "Welcome to %s's house, %s{FFFFFF}!", HouseData[id][Owner], HouseData[id][Name]);
652 SendClientMessage(playerid, 0xFFFFFFFF, string);
653
654 if(!strcmp(HouseData[id][Owner], Player_GetName(playerid)))
655 {
656 HouseData[id][LastEntered] = gettime();
657 HouseData[id][Save] = true;
658 SendClientMessage(playerid, 0xFFFFFFFF, "Use {3498DB}/house {FFFFFF}to open the house menu.");
659 }
660
661 if(HouseData[id][LockMode] == LOCK_MODE_NOLOCK && LastVisitedHouse[playerid] != id)
662 {
663 new query[128];
664 mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO housevisitors SET HouseID=%d, Visitor='%e', Date=UNIX_TIMESTAMP()", id, Player_GetName(playerid));
665 mysql_tquery(SQLHandle, query, "", "");
666 LastVisitedHouse[playerid] = id;
667 }
668
669 return 1;
670}
671
672stock ShowHouseMenu(playerid)
673{
674 if(strcmp(HouseData[ InHouse[playerid] ][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
675
676 new string[256], id = InHouse[playerid];
677 format(string, sizeof(string), "House Name: %s\nPassword: %s\nLock: %s\nHouse Safe {2ECC71}($%s)\nFurnitures\nGuns\nVisitors\nKeys\nKick Everybody\nSell House", HouseData[id][Name], HouseData[id][Password], LockNames[ HouseData[id][LockMode] ], convertNumber(HouseData[id][SafeMoney]));
678 ShowPlayerDialog(playerid, DIALOG_HOUSE_MENU, DIALOG_STYLE_LIST, HouseData[id][Name], string, "Select", "Close");
679 return 1;
680}
681
682stock ResetHouse(id)
683{
684 if(!Iter_Contains(Houses, id)) return 0;
685 format(HouseData[id][Name], MAX_HOUSE_NAME, "House For Sale");
686 format(HouseData[id][Owner], MAX_PLAYER_NAME, "-");
687 format(HouseData[id][Password], MAX_HOUSE_PASSWORD, "-");
688 HouseData[id][LockMode] = LOCK_MODE_NOLOCK;
689 HouseData[id][SalePrice] = HouseData[id][SafeMoney] = HouseData[id][LastEntered] = 0;
690 HouseData[id][Save] = true;
691
692 new label[200];
693 format(label, sizeof(label), "{2ECC71}House For Sale (ID: %d)\n{FFFFFF}%s\n{F1C40F}Price: {2ECC71}$%s", id, HouseInteriors[ HouseData[id][Interior] ][IntName], convertNumber(HouseData[id][Price]));
694 UpdateDynamic3DTextLabelText(HouseData[id][HouseLabel], 0xFFFFFFFF, label);
695 Streamer_SetIntData(STREAMER_TYPE_PICKUP, HouseData[id][HousePickup], E_STREAMER_MODEL_ID, 1273);
696 Streamer_SetIntData(STREAMER_TYPE_MAP_ICON, HouseData[id][HouseIcon], E_STREAMER_TYPE, 31);
697
698 foreach(new i : Player)
699 {
700 if(InHouse[i] == id)
701 {
702 SetPVarInt(i, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
703 SetPlayerVirtualWorld(i, 0);
704 SetPlayerInterior(i, 0);
705 SetPlayerPos(i, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]);
706 InHouse[i] = INVALID_HOUSE_ID;
707 }
708
709 if(Iter_Contains(HouseKeys[i], id)) Iter_Remove(HouseKeys[i], id);
710 }
711
712 new query[64], data[e_furniture];
713 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM houseguns WHERE HouseID=%d", id);
714 mysql_tquery(SQLHandle, query, "", "");
715
716 for(new i, maxval = Streamer_GetUpperBound(STREAMER_TYPE_OBJECT); i <= maxval; ++i)
717 {
718 if(!IsValidDynamicObject(i)) continue;
719 Streamer_GetArrayData(STREAMER_TYPE_OBJECT, i, E_STREAMER_EXTRA_ID, data);
720 if(data[SQLID] > 0 && data[HouseID] == id) DestroyDynamicObject(i);
721 }
722
723 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housefurnitures WHERE HouseID=%d", id);
724 mysql_tquery(SQLHandle, query, "", "");
725
726 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housevisitors WHERE HouseID=%d", id);
727 mysql_tquery(SQLHandle, query, "", "");
728
729 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housekeys WHERE HouseID=%d", id);
730 mysql_tquery(SQLHandle, query, "", "");
731
732 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housesafelogs WHERE HouseID=%d", id);
733 mysql_tquery(SQLHandle, query, "", "");
734 return 1;
735}
736
737stock SaveHouse(id)
738{
739 if(!Iter_Contains(Houses, id)) return 0;
740 new query[256];
741 mysql_format(SQLHandle, query, sizeof(query), "UPDATE houses SET HouseName='%e', HouseOwner='%e', HousePassword='%e', HouseSalePrice=%d, HouseLock=%d, HouseMoney=%d, LastEntered=%d WHERE ID=%d",
742 HouseData[id][Name], HouseData[id][Owner], HouseData[id][Password], HouseData[id][SalePrice], HouseData[id][LockMode], HouseData[id][SafeMoney], HouseData[id][LastEntered], id);
743 mysql_tquery(SQLHandle, query, "", "");
744 HouseData[id][Save] = false;
745 return 1;
746}
747
748stock UpdateHouseLabel(id)
749{
750 if(!Iter_Contains(Houses, id)) return 0;
751 new label[256];
752 if(!strcmp(HouseData[id][Owner], "-")) {
753 format(label, sizeof(label), "{2ECC71}House For Sale (ID: %d)\n{FFFFFF}%s\n{F1C40F}Price: {2ECC71}$%s", id, HouseInteriors[ HouseData[id][Interior] ][IntName], convertNumber(HouseData[id][Price]));
754 }else{
755 if(HouseData[id][SalePrice] > 0) {
756 format(label, sizeof(label), "{E67E22}%s's House For Sale (ID: %d)\n{FFFFFF}%s\n{FFFFFF}%s\n{F1C40F}Price: {2ECC71}$%s", HouseData[id][Owner], id, HouseData[id][Name], HouseInteriors[ HouseData[id][Interior] ][IntName], convertNumber(HouseData[id][SalePrice]));
757 }else{
758 format(label, sizeof(label), "{E67E22}%s's House (ID: %d)\n{FFFFFF}%s\n{FFFFFF}%s\n%s\n{FFFFFF}%s", HouseData[id][Owner], id, HouseData[id][Name], HouseInteriors[ HouseData[id][Interior] ][IntName], LockNames[ HouseData[id][LockMode] ], HouseData[id][Address]);
759 }
760 }
761
762 UpdateDynamic3DTextLabelText(HouseData[id][HouseLabel], 0xFFFFFFFF, label);
763 return 1;
764}
765
766stock House_PlayerInit(playerid)
767{
768 InHouse[playerid] = LastVisitedHouse[playerid] = INVALID_HOUSE_ID;
769 ListPage[playerid] = SelectMode[playerid] = SELECT_MODE_NONE;
770 EditingFurniture[playerid] = false;
771 LoadHouseKeys(playerid);
772 return 1;
773}
774
775stock OwnedHouses(playerid)
776{
777 #if LIMIT_PER_PLAYER != 0
778 new count;
779
780 foreach(new i : Houses) if(!strcmp(HouseData[i][Owner], Player_GetName(playerid), true)) count++;
781 return count;
782 #else
783 return 0;
784 #endif
785}
786
787forward ResetAndSaveHouses();
788forward LoadHouses();
789forward LoadFurnitures();
790forward GiveHouseKeys(playerid);
791forward HouseSaleMoney(playerid);
792
793public ResetAndSaveHouses()
794{
795 foreach(new i : Houses)
796 {
797 if(HouseData[i][LastEntered] > 0 && gettime()-HouseData[i][LastEntered] > 604800) ResetHouse(i);
798 if(HouseData[i][Save]) SaveHouse(i);
799 }
800
801 return 1;
802}
803
804public LoadHouses()
805{
806 new rows = cache_num_rows();
807 if(rows)
808 {
809 new id, loaded, for_sale, label[256];
810 while(loaded < rows)
811 {
812 id = cache_get_field_content_int(loaded, "ID");
813 cache_get_field_content(loaded, "HouseName", HouseData[id][Name], .max_len = MAX_HOUSE_NAME);
814 cache_get_field_content(loaded, "HouseOwner", HouseData[id][Owner], .max_len = MAX_PLAYER_NAME);
815 cache_get_field_content(loaded, "HousePassword", HouseData[id][Password], .max_len = MAX_HOUSE_PASSWORD);
816 HouseData[id][houseX] = cache_get_field_content_float(loaded, "HouseX");
817 HouseData[id][houseY] = cache_get_field_content_float(loaded, "HouseY");
818 HouseData[id][houseZ] = cache_get_field_content_float(loaded, "HouseZ");
819 HouseData[id][Price] = cache_get_field_content_int(loaded, "HousePrice");
820 HouseData[id][SalePrice] = cache_get_field_content_int(loaded, "HouseSalePrice");
821 HouseData[id][Interior] = cache_get_field_content_int(loaded, "HouseInterior");
822 HouseData[id][LockMode] = cache_get_field_content_int(loaded, "HouseLock");
823 HouseData[id][SafeMoney] = cache_get_field_content_int(loaded, "HouseMoney");
824 HouseData[id][LastEntered] = cache_get_field_content_int(loaded, "LastEntered");
825 format(HouseData[id][Address], MAX_HOUSE_ADDRESS, "%d, %s, %s", id, GetZoneName(HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]), GetCityName(HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]));
826
827 if(strcmp(HouseData[id][Owner], "-")) {
828 if(HouseData[id][SalePrice] > 0) {
829 for_sale = 1;
830 format(label, sizeof(label), "{E67E22}%s's House For Sale (ID: %d)\n{FFFFFF}%s\n{FFFFFF}%s\n{F1C40F}Price: {2ECC71}$%s", HouseData[id][Owner], id, HouseData[id][Name], HouseInteriors[ HouseData[id][Interior] ][IntName], convertNumber(HouseData[id][SalePrice]));
831 }else{
832 for_sale = 0;
833 format(label, sizeof(label), "{E67E22}%s's House (ID: %d)\n{FFFFFF}%s\n{FFFFFF}%s\n%s\n{FFFFFF}%s", HouseData[id][Owner], id, HouseData[id][Name], HouseInteriors[ HouseData[id][Interior] ][IntName], LockNames[ HouseData[id][LockMode] ], HouseData[id][Address]);
834 }
835 }else{
836 for_sale = 1;
837 format(label, sizeof(label), "{2ECC71}House For Sale (ID: %d)\n{FFFFFF}%s\n{F1C40F}Price: {2ECC71}$%s", id, HouseInteriors[ HouseData[id][Interior] ][IntName], convertNumber(HouseData[id][Price]));
838 }
839
840 HouseData[id][HousePickup] = CreateDynamicPickup((!for_sale) ? 19522 : 1273, 1, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]);
841 HouseData[id][HouseIcon] = CreateDynamicMapIcon(HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ], (!for_sale) ? 32 : 31, 0);
842 HouseData[id][HouseLabel] = CreateDynamic3DTextLabel(label, 0xFFFFFFFF, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]+0.35, 15.0, .testlos = 1);
843 Iter_Add(Houses, id);
844 loaded++;
845 }
846
847 printf(" [House System] Loaded %d houses.", loaded);
848 }
849
850 return 1;
851}
852
853public LoadFurnitures()
854{
855 new rows = cache_num_rows();
856 if(rows)
857 {
858 new id, loaded, data[e_furniture];
859 while(loaded < rows)
860 {
861 data[SQLID] = cache_get_field_content_int(loaded, "ID");
862 data[HouseID] = cache_get_field_content_int(loaded, "HouseID");
863 data[ArrayID] = cache_get_field_content_int(loaded, "FurnitureID");
864 data[furnitureX] = cache_get_field_content_float(loaded, "FurnitureX");
865 data[furnitureY] = cache_get_field_content_float(loaded, "FurnitureY");
866 data[furnitureZ] = cache_get_field_content_float(loaded, "FurnitureZ");
867 data[furnitureRX] = cache_get_field_content_float(loaded, "FurnitureRX");
868 data[furnitureRY] = cache_get_field_content_float(loaded, "FurnitureRY");
869 data[furnitureRZ] = cache_get_field_content_float(loaded, "FurnitureRZ");
870
871 id = CreateDynamicObject(
872 HouseFurnitures[ data[ArrayID] ][ModelID],
873 data[furnitureX], data[furnitureY], data[furnitureZ],
874 data[furnitureRX], data[furnitureRY], data[furnitureRZ],
875 cache_get_field_content_int(loaded, "FurnitureVW"), cache_get_field_content_int(loaded, "FurnitureInt")
876 );
877
878 Streamer_SetArrayData(STREAMER_TYPE_OBJECT, id, E_STREAMER_EXTRA_ID, data);
879 loaded++;
880 }
881
882 printf(" [House System] Loaded %d furnitures.", loaded);
883 }
884
885 return 1;
886}
887
888public GiveHouseKeys(playerid)
889{
890 if(!IsPlayerConnected(playerid)) return 1;
891 new rows = cache_num_rows();
892 if(rows)
893 {
894 new loaded;
895 while(loaded < rows)
896 {
897 Iter_Add(HouseKeys[playerid], cache_get_field_content_int(loaded, "HouseID"));
898 loaded++;
899 }
900 }
901
902 return 1;
903}
904
905public HouseSaleMoney(playerid)
906{
907 new rows = cache_num_rows();
908 if(rows)
909 {
910 new new_owner[MAX_PLAYER_NAME], price, string[128];
911 for(new i; i < rows; i++)
912 {
913 cache_get_field_content(i, "NewOwner", new_owner);
914 price = cache_get_field_content_int(i, "Price");
915
916 format(string, sizeof(string), "You sold a house to %s for $%s. (Transaction ID: #%d)", new_owner, convertNumber(price), cache_get_field_content_int(i, "ID"));
917 SendClientMessage(playerid, -1, string);
918 GivePlayerMoney(playerid, price);
919 }
920
921 new query[128];
922 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housesales WHERE OldOwner='%e'", Player_GetName(playerid));
923 mysql_tquery(SQLHandle, query, "", "");
924 }
925
926 return 1;
927}
928
929public OnFilterScriptInit()
930{
931 for(new i; i < MAX_HOUSES; ++i)
932 {
933 HouseData[i][HouseLabel] = Text3D: INVALID_3DTEXT_ID;
934 HouseData[i][HousePickup] = -1;
935 HouseData[i][HouseIcon] = -1;
936 HouseData[i][Save] = false;
937 }
938
939 for(new i; i < sizeof(HouseInteriors); ++i)
940 {
941 HouseInteriors[i][intLabel] = CreateDynamic3DTextLabel("Leave House", 0xE67E22FF, HouseInteriors[i][intX], HouseInteriors[i][intY], HouseInteriors[i][intZ]+0.35, 10.0, .testlos = 1, .interiorid = HouseInteriors[i][intID]);
942 HouseInteriors[i][intPickup] = CreateDynamicPickup(1318, 1, HouseInteriors[i][intX], HouseInteriors[i][intY], HouseInteriors[i][intZ], .interiorid = HouseInteriors[i][intID]);
943 }
944
945 Iter_Init(HouseKeys);
946 DisableInteriorEnterExits();
947 SQLHandle = mysql_connect(SQL_HOST, SQL_USER, SQL_DBNAME, SQL_PASSWORD);
948 mysql_log(LOG_ERROR | LOG_WARNING, LOG_TYPE_HTML);
949 if(mysql_errno() != 0) return print(" [House System] Can't connect to MySQL.");
950
951 /* Create Tables */
952 new query[1024];
953 strcat(query, "CREATE TABLE IF NOT EXISTS `houses` (\
954 `ID` int(11) NOT NULL,\
955 `HouseName` varchar(48) NOT NULL default 'House For Sale',\
956 `HouseOwner` varchar(24) NOT NULL default '-',\
957 `HousePassword` varchar(16) NOT NULL default '-',\
958 `HouseX` float NOT NULL,\
959 `HouseY` float NOT NULL,\
960 `HouseZ` float NOT NULL,\
961 `HousePrice` int(11) NOT NULL,\
962 `HouseInterior` tinyint(4) NOT NULL default '0',\
963 `HouseLock` tinyint(4) NOT NULL default '0',\
964 `HouseMoney` int(11) NOT NULL default '0',"
965 );
966
967 strcat(query, "`LastEntered` int(11) NOT NULL,\
968 PRIMARY KEY (`ID`),\
969 UNIQUE KEY `ID_2` (`ID`),\
970 KEY `ID` (`ID`)\
971 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
972 );
973
974 mysql_tquery(SQLHandle, query, "", "");
975
976 mysql_tquery(SQLHandle, "CREATE TABLE IF NOT EXISTS `housefurnitures` (\
977 `ID` int(11) NOT NULL auto_increment,\
978 `HouseID` int(11) NOT NULL,\
979 `FurnitureID` tinyint(11) NOT NULL,\
980 `FurnitureX` float NOT NULL,\
981 `FurnitureY` float NOT NULL,\
982 `FurnitureZ` float NOT NULL,\
983 `FurnitureRX` float NOT NULL,\
984 `FurnitureRY` float NOT NULL,\
985 `FurnitureRZ` float NOT NULL,\
986 `FurnitureVW` int(11) NOT NULL,\
987 `FurnitureInt` int(11) NOT NULL,\
988 PRIMARY KEY (`ID`)\
989 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", "", "");
990
991 mysql_tquery(SQLHandle, "CREATE TABLE IF NOT EXISTS `houseguns` (\
992 `HouseID` int(11) NOT NULL,\
993 `WeaponID` tinyint(4) NOT NULL,\
994 `Ammo` int(11) NOT NULL,\
995 UNIQUE KEY `HouseID_2` (`HouseID`,`WeaponID`),\
996 KEY `HouseID` (`HouseID`),\
997 CONSTRAINT `houseguns_ibfk_1` FOREIGN KEY (`HouseID`) REFERENCES `houses` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE\
998 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "", "");
999
1000 mysql_tquery(SQLHandle, "CREATE TABLE IF NOT EXISTS `housevisitors` (\
1001 `HouseID` int(11) NOT NULL,\
1002 `Visitor` varchar(24) NOT NULL,\
1003 `Date` int(11) NOT NULL\
1004 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", "", "");
1005
1006 mysql_tquery(SQLHandle, "CREATE TABLE IF NOT EXISTS `housekeys` (\
1007 `HouseID` int(11) NOT NULL,\
1008 `Player` varchar(24) NOT NULL,\
1009 `Date` int(11) NOT NULL\
1010 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", "", "");
1011
1012 mysql_tquery(SQLHandle, "CREATE TABLE IF NOT EXISTS `housesafelogs` (\
1013 `HouseID` int(11) NOT NULL,\
1014 `Type` int(11) NOT NULL,\
1015 `Amount` int(11) NOT NULL,\
1016 `Date` int(11) NOT NULL\
1017 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", "", "");
1018
1019 mysql_tquery(SQLHandle, "CREATE TABLE IF NOT EXISTS `housesales` (\
1020 `ID` int(11) NOT NULL AUTO_INCREMENT,\
1021 `OldOwner` varchar(24) NOT NULL,\
1022 `NewOwner` varchar(24) NOT NULL,\
1023 `Price` int(11) NOT NULL,\
1024 PRIMARY KEY (`ID`)\
1025 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", "", "");
1026
1027 // 1.3 update, add HouseSalePrice to the houses table
1028 if(!fexist("house_updated.txt"))
1029 {
1030 mysql_tquery(SQLHandle, "ALTER TABLE houses ADD HouseSalePrice INT(11) NOT NULL AFTER HousePrice");
1031
1032 new File: updateFile = fopen("house_updated.txt", io_append);
1033 if(updateFile)
1034 {
1035 fwrite(updateFile, "Don't remove this file.");
1036 fclose(updateFile);
1037 }
1038 }
1039
1040 /* Loading & Stuff */
1041 mysql_tquery(SQLHandle, "SELECT * FROM houses", "LoadHouses", "");
1042 mysql_tquery(SQLHandle, "SELECT * FROM housefurnitures", "LoadFurnitures", "");
1043 foreach(new i : Player) House_PlayerInit(i);
1044
1045 HouseTimer = SetTimer("ResetAndSaveHouses", 10 * 60000, true);
1046 return 1;
1047}
1048
1049public OnFilterScriptExit()
1050{
1051 foreach(new i : Houses) if(HouseData[i][Save]) SaveHouse(i);
1052 KillTimer(HouseTimer);
1053 return 1;
1054}
1055
1056public OnPlayerConnect(playerid)
1057{
1058 House_PlayerInit(playerid);
1059 return 1;
1060}
1061
1062public OnPlayerSpawn(playerid)
1063{
1064 InHouse[playerid] = INVALID_HOUSE_ID;
1065
1066 new query[128];
1067 mysql_format(SQLHandle, query, sizeof(query), "SELECT * FROM housesales WHERE OldOwner='%e'", Player_GetName(playerid));
1068 mysql_tquery(SQLHandle, query, "HouseSaleMoney", "i", playerid);
1069 return 1;
1070}
1071
1072public OnPlayerPickUpDynamicPickup(playerid, pickupid)
1073{
1074 if(GetPVarInt(playerid, "HousePickupCooldown") < gettime())
1075 {
1076 if(InHouse[playerid] == INVALID_HOUSE_ID) {
1077 foreach(new i : Houses)
1078 {
1079 if(pickupid == HouseData[i][HousePickup])
1080 {
1081 SetPVarInt(playerid, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
1082 SetPVarInt(playerid, "PickupHouseID", i);
1083
1084 if(!strcmp(HouseData[i][Owner], "-")) {
1085 new string[64];
1086 format(string, sizeof(string), "This house is for sale!\n\nPrice: {2ECC71}$%s", convertNumber(HouseData[i][Price]));
1087 ShowPlayerDialog(playerid, DIALOG_BUY_HOUSE, DIALOG_STYLE_MSGBOX, "House For Sale", string, "Buy", "Close");
1088 }else{
1089 if(HouseData[i][SalePrice] > 0 && strcmp(HouseData[i][Owner], Player_GetName(playerid)))
1090 {
1091 new string[64];
1092 format(string, sizeof(string), "This house is for sale!\n\nPrice: {2ECC71}$%s", convertNumber(HouseData[i][SalePrice]));
1093 ShowPlayerDialog(playerid, DIALOG_BUY_HOUSE_FROM_OWNER, DIALOG_STYLE_MSGBOX, "House For Sale", string, "Buy", "Close");
1094 return 1;
1095 }
1096
1097 switch(HouseData[i][LockMode])
1098 {
1099 case LOCK_MODE_NOLOCK: SendToHouse(playerid, i);
1100 case LOCK_MODE_PASSWORD: ShowPlayerDialog(playerid, DIALOG_HOUSE_PASSWORD, DIALOG_STYLE_INPUT, "House Password", "This house is password protected.\n\nEnter house password:", "Done", "Close");
1101 case LOCK_MODE_KEYS:
1102 {
1103 new gotkeys = Iter_Contains(HouseKeys[playerid], i);
1104 if(!gotkeys) if(!strcmp(HouseData[i][Owner], Player_GetName(playerid))) gotkeys = 1;
1105
1106 if(gotkeys) {
1107 SendToHouse(playerid, i);
1108 }else{
1109 SendClientMessage(playerid, 0xE74C3CFF, "You don't have keys for this house, you can't enter.");
1110 }
1111 }
1112
1113 case LOCK_MODE_OWNER:
1114 {
1115 if(!strcmp(HouseData[i][Owner], Player_GetName(playerid))) {
1116 SetPVarInt(playerid, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
1117 SendToHouse(playerid, i);
1118 }else{
1119 SendClientMessage(playerid, 0xE74C3CFF, "Sorry, only the owner can enter this house.");
1120 }
1121 }
1122 }
1123 }
1124
1125 return 1;
1126 }
1127 }
1128 }else{
1129 for(new i; i < sizeof(HouseInteriors); ++i)
1130 {
1131 if(pickupid == HouseInteriors[i][intPickup])
1132 {
1133 SetPVarInt(playerid, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
1134 SetPlayerVirtualWorld(playerid, 0);
1135 SetPlayerInterior(playerid, 0);
1136 SetPlayerPos(playerid, HouseData[ InHouse[playerid] ][houseX], HouseData[ InHouse[playerid] ][houseY], HouseData[ InHouse[playerid] ][houseZ]);
1137 InHouse[playerid] = INVALID_HOUSE_ID;
1138 return 1;
1139 }
1140 }
1141 }
1142 }
1143
1144 return 1;
1145}
1146
1147public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
1148{
1149 if(dialogid == DIALOG_BUY_HOUSE)
1150 {
1151 if(!response) return 1;
1152 new id = GetPVarInt(playerid, "PickupHouseID");
1153 if(!IsPlayerInRangeOfPoint(playerid, 2.0, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ])) return SendClientMessage(playerid, 0xE74C3CFF, "You're not near any house.");
1154 #if LIMIT_PER_PLAYER > 0
1155 if(OwnedHouses(playerid) + 1 > LIMIT_PER_PLAYER) return SendClientMessage(playerid, 0xE74C3CFF, "You can't buy any more houses.");
1156 #endif
1157 if(HouseData[id][Price] > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't afford this house.");
1158 if(strcmp(HouseData[id][Owner], "-")) return SendClientMessage(playerid, 0xE74C3CFF, "Someone already owns this house.");
1159 GivePlayerMoney(playerid, -HouseData[id][Price]);
1160 GetPlayerName(playerid, HouseData[id][Owner], MAX_PLAYER_NAME);
1161 HouseData[id][LastEntered] = gettime();
1162 HouseData[id][Save] = true;
1163
1164 UpdateHouseLabel(id);
1165 Streamer_SetIntData(STREAMER_TYPE_PICKUP, HouseData[id][HousePickup], E_STREAMER_MODEL_ID, 19522);
1166 Streamer_SetIntData(STREAMER_TYPE_MAP_ICON, HouseData[id][HouseIcon], E_STREAMER_TYPE, 32);
1167 SendToHouse(playerid, id);
1168 SaveHouse(id);
1169 return 1;
1170 }
1171
1172 if(dialogid == DIALOG_HOUSE_PASSWORD)
1173 {
1174 if(!response) return 1;
1175 new id = GetPVarInt(playerid, "PickupHouseID");
1176 if(!IsPlayerInRangeOfPoint(playerid, 2.0, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ])) return SendClientMessage(playerid, 0xE74C3CFF, "You're not near any house.");
1177 if(!(1 <= strlen(inputtext) <= MAX_HOUSE_PASSWORD)) return ShowPlayerDialog(playerid, DIALOG_HOUSE_PASSWORD, DIALOG_STYLE_INPUT, "House Password", "This house is password protected.\n\nEnter house password:\n\n{E74C3C}The password you entered is either too short or too long.", "Try Again", "Close");
1178 if(strcmp(HouseData[id][Password], inputtext)) return ShowPlayerDialog(playerid, DIALOG_HOUSE_PASSWORD, DIALOG_STYLE_INPUT, "House Password", "This house is password protected.\n\nEnter house password:\n\n{E74C3C}Wrong password.", "Try Again", "Close");
1179 SendToHouse(playerid, id);
1180 return 1;
1181 }
1182
1183 if(dialogid == DIALOG_HOUSE_MENU)
1184 {
1185 if(!response) return 1;
1186 new id = InHouse[playerid];
1187 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1188 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1189
1190 if(listitem == 0) ShowPlayerDialog(playerid, DIALOG_HOUSE_NAME, DIALOG_STYLE_INPUT, "House Name", "Write a new name for this house:", "Change", "Back");
1191 if(listitem == 1) ShowPlayerDialog(playerid, DIALOG_HOUSE_NEW_PASSWORD, DIALOG_STYLE_INPUT, "House Password", "Write a new password for this house:", "Change", "Back");
1192 if(listitem == 2) ShowPlayerDialog(playerid, DIALOG_HOUSE_LOCK, DIALOG_STYLE_LIST, "House Lock", "Not Locked\nPassword Lock\nKeys\nOwner Only", "Change", "Back");
1193 if(listitem == 3)
1194 {
1195 if(HouseData[id][SalePrice] > 0)
1196 {
1197 SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1198 return ShowHouseMenu(playerid);
1199 }
1200
1201 new string[144];
1202 format(string, sizeof(string), "Take Money From Safe {2ECC71}($%s)\nPut Money To Safe {2ECC71}($%s)\nView Safe History\nClear Safe History", convertNumber(HouseData[id][SafeMoney]), convertNumber(GetPlayerMoney(playerid)));
1203 ShowPlayerDialog(playerid, DIALOG_SAFE_MENU, DIALOG_STYLE_LIST, "House Safe", string, "Choose", "Back");
1204 }
1205
1206 if(listitem == 4)
1207 {
1208 if(HouseData[id][SalePrice] > 0)
1209 {
1210 SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1211 return ShowHouseMenu(playerid);
1212 }
1213
1214 ShowPlayerDialog(playerid, DIALOG_FURNITURE_MENU, DIALOG_STYLE_LIST, "Furnitures", "Buy Furniture\nEdit Furniture\nSell Furniture\nSell All Furnitures", "Choose", "Back");
1215 }
1216
1217 if(listitem == 5) ShowPlayerDialog(playerid, DIALOG_GUNS_MENU, DIALOG_STYLE_LIST, "Guns", "Put Gun\nTake Gun", "Choose", "Back");
1218 if(listitem == 6)
1219 {
1220 ListPage[playerid] = 0;
1221 ShowPlayerDialog(playerid, DIALOG_VISITORS_MENU, DIALOG_STYLE_LIST, "Visitors", "Look Visitor History\nClear Visitor History", "Choose", "Back");
1222 }
1223
1224 if(listitem == 7)
1225 {
1226 ListPage[playerid] = 0;
1227 ShowPlayerDialog(playerid, DIALOG_KEYS_MENU, DIALOG_STYLE_LIST, "Keys", "View Key Owners\nChange Locks", "Choose", "Back");
1228 }
1229
1230 if(listitem == 8)
1231 {
1232 new string[128];
1233 format(string, sizeof(string), "House owner %s kicked everybody from the house.", HouseData[id][Owner]);
1234
1235 foreach(new i : Player)
1236 {
1237 if(i == playerid) continue;
1238 if(InHouse[i] == id)
1239 {
1240 SetPVarInt(i, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
1241 SetPlayerVirtualWorld(i, 0);
1242 SetPlayerInterior(i, 0);
1243 SetPlayerPos(i, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]);
1244 InHouse[i] = INVALID_HOUSE_ID;
1245 SendClientMessage(i, -1, string);
1246 }
1247 }
1248
1249 SendClientMessage(playerid, -1, "You kicked everybody from your house.");
1250 }
1251
1252 if(listitem == 9)
1253 {
1254 new string[128];
1255 format(string, sizeof(string), "Sell Instantly\t{2ECC71}$%s\n%s", convertNumber(floatround(HouseData[id][Price]*0.85)), (HouseData[id][SalePrice] > 0) ? ("Remove From Sale") : ("Put For Sale"));
1256 ShowPlayerDialog(playerid, DIALOG_SELL_HOUSE, DIALOG_STYLE_TABLIST, "Sell House", string, "Choose", "Back");
1257 }
1258
1259 return 1;
1260 }
1261
1262 if(dialogid == DIALOG_HOUSE_NAME)
1263 {
1264 if(!response) return ShowHouseMenu(playerid);
1265 new id = InHouse[playerid];
1266 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1267 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1268 if(!(1 <= strlen(inputtext) <= MAX_HOUSE_NAME)) return ShowPlayerDialog(playerid, DIALOG_HOUSE_NAME, DIALOG_STYLE_INPUT, "House Name", "Write a new name for this house:\n\n{E74C3C}The name you entered is either too short or too long.", "Change", "Back");
1269 format(HouseData[id][Name], MAX_HOUSE_NAME, "%s", inputtext);
1270 HouseData[id][Save] = true;
1271
1272 UpdateHouseLabel(id);
1273 ShowHouseMenu(playerid);
1274 return 1;
1275 }
1276
1277 if(dialogid == DIALOG_HOUSE_NEW_PASSWORD)
1278 {
1279 if(!response) return ShowHouseMenu(playerid);
1280 new id = InHouse[playerid];
1281 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1282 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1283 if(!(1 <= strlen(inputtext) <= MAX_HOUSE_PASSWORD)) return ShowPlayerDialog(playerid, DIALOG_HOUSE_NEW_PASSWORD, DIALOG_STYLE_INPUT, "House Password", "Write a new password for this house:\n\n{E74C3C}The pasword you entered is either too short or too long.", "Change", "Back");
1284 format(HouseData[id][Password], MAX_HOUSE_PASSWORD, "%s", inputtext);
1285 HouseData[id][Save] = true;
1286 ShowHouseMenu(playerid);
1287 return 1;
1288 }
1289
1290 if(dialogid == DIALOG_HOUSE_LOCK)
1291 {
1292 if(!response) return ShowHouseMenu(playerid);
1293 new id = InHouse[playerid];
1294 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1295 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1296 HouseData[id][LockMode] = listitem;
1297 HouseData[id][Save] = true;
1298
1299 UpdateHouseLabel(id);
1300 ShowHouseMenu(playerid);
1301 return 1;
1302 }
1303
1304 if(dialogid == DIALOG_SAFE_MENU)
1305 {
1306 if(!response) return ShowHouseMenu(playerid);
1307 new id = InHouse[playerid];
1308 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1309 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1310 if(HouseData[id][SalePrice] > 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1311 if(listitem == 0) ShowPlayerDialog(playerid, DIALOG_SAFE_TAKE, DIALOG_STYLE_INPUT, "Safe: Take Money", "Write the amount you want to take from safe:", "Take", "Back");
1312 if(listitem == 1) ShowPlayerDialog(playerid, DIALOG_SAFE_PUT, DIALOG_STYLE_INPUT, "Safe: Put Money", "Write the amount you want to put to safe:", "Put", "Back");
1313 if(listitem == 2)
1314 {
1315 ListPage[playerid] = 0;
1316
1317 new query[200], Cache: safelog;
1318 mysql_format(SQLHandle, query, sizeof(query), "SELECT Type, Amount, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as TransactionDate FROM housesafelogs WHERE HouseID=%d ORDER BY Date DESC LIMIT 0, 15", id);
1319 safelog = mysql_query(SQLHandle, query);
1320 new rows = cache_num_rows();
1321 if(rows) {
1322 new list[1024], date[20];
1323 format(list, sizeof(list), "Action\tDate\n");
1324 for(new i; i < rows; ++i)
1325 {
1326 cache_get_field_content(i, "TransactionDate", date);
1327 format(list, sizeof(list), "%s%s $%s\t{FFFFFF}%s\n", list, TransactionNames[ cache_get_field_content_int(i, "Type") ], convertNumber(cache_get_field_content_int(i, "Amount")), date);
1328 }
1329
1330 ShowPlayerDialog(playerid, DIALOG_SAFE_HISTORY, DIALOG_STYLE_TABLIST_HEADERS, "Safe History (Page 1)", list, "Next", "Previous");
1331 }else{
1332 SendClientMessage(playerid, 0xE74C3CFF, "Can't find any safe history.");
1333 }
1334
1335 cache_delete(safelog);
1336 }
1337
1338 if(listitem == 3)
1339 {
1340 new query[64];
1341 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housesafelogs WHERE HouseID=%d", id);
1342 mysql_tquery(SQLHandle, query, "", "");
1343 ShowHouseMenu(playerid);
1344 }
1345
1346 return 1;
1347 }
1348
1349 if(dialogid == DIALOG_SAFE_TAKE)
1350 {
1351 if(!response) return ShowHouseMenu(playerid);
1352 new id = InHouse[playerid];
1353 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1354 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1355 if(HouseData[id][SalePrice] > 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1356 new amount = strval(inputtext);
1357 if(!(1 <= amount <= 10000000)) return ShowPlayerDialog(playerid, DIALOG_SAFE_TAKE, DIALOG_STYLE_INPUT, "Safe: Take Money", "Write the amount you want to take from safe:\n\n{E74C3C}Invalid amount. You can take between $1 - $10,000,000 at a time.", "Take", "Back");
1358 if(amount > HouseData[id][SafeMoney]) return ShowPlayerDialog(playerid, DIALOG_SAFE_TAKE, DIALOG_STYLE_INPUT, "Safe: Take Money", "Write the amount you want to take from safe:\n\n{E74C3C}You don't have that much money in your safe.", "Take", "Back");
1359 new query[128];
1360 mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO housesafelogs SET HouseID=%d, Type=0, Amount=%d, Date=UNIX_TIMESTAMP()", id, amount);
1361 mysql_tquery(SQLHandle, query, "", "");
1362
1363 GivePlayerMoney(playerid, amount);
1364 HouseData[id][SafeMoney] -= amount;
1365 HouseData[id][Save] = true;
1366 ShowHouseMenu(playerid);
1367 return 1;
1368 }
1369
1370 if(dialogid == DIALOG_SAFE_PUT)
1371 {
1372 if(!response) return ShowHouseMenu(playerid);
1373 new id = InHouse[playerid];
1374 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1375 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1376 new amount = strval(inputtext);
1377 if(!(1 <= amount <= 10000000)) return ShowPlayerDialog(playerid, DIALOG_SAFE_PUT, DIALOG_STYLE_INPUT, "Safe: Put Money", "Write the amount you want to put to safe:\n\n{E74C3C}Invalid amount. You can put between $1 - $10,000,000 at a time.", "Put", "Back");
1378 if(amount > GetPlayerMoney(playerid)) return ShowPlayerDialog(playerid, DIALOG_SAFE_PUT, DIALOG_STYLE_INPUT, "Safe: Put Money", "Write the amount you want to put to safe:\n\n{E74C3C}You don't have that much money on you.", "Put", "Back");
1379 new query[128];
1380 mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO housesafelogs SET HouseID=%d, Type=1, Amount=%d, Date=UNIX_TIMESTAMP()", id, amount);
1381 mysql_tquery(SQLHandle, query, "", "");
1382
1383 GivePlayerMoney(playerid, -amount);
1384 HouseData[id][SafeMoney] += amount;
1385 HouseData[id][Save] = true;
1386 ShowHouseMenu(playerid);
1387 return 1;
1388 }
1389
1390 if(dialogid == DIALOG_GUNS_MENU)
1391 {
1392 if(!response) return ShowHouseMenu(playerid);
1393 new id = InHouse[playerid];
1394 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1395 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1396 if(listitem == 0)
1397 {
1398 if(GetPlayerWeapon(playerid) == 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't put your fists in your house.");
1399 new query[128], weapon = GetPlayerWeapon(playerid), ammo = GetPlayerAmmo(playerid);
1400 RemovePlayerWeapon(playerid, weapon);
1401 mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO houseguns VALUES (%d, %d, %d) ON DUPLICATE KEY UPDATE Ammo=Ammo+%d", id, weapon, ammo, ammo);
1402 mysql_tquery(SQLHandle, query, "", "");
1403 ShowHouseMenu(playerid);
1404 }
1405
1406 if(listitem == 1)
1407 {
1408 new query[80], Cache: weapons;
1409 mysql_format(SQLHandle, query, sizeof(query), "SELECT WeaponID, Ammo FROM houseguns WHERE HouseID=%d ORDER BY WeaponID ASC", id);
1410 weapons = mysql_query(SQLHandle, query);
1411 new rows = cache_num_rows();
1412 if(rows) {
1413 new list[512], weapname[32];
1414 format(list, sizeof(list), "#\tWeapon Name\tAmmo\n");
1415 for(new i; i < rows; ++i)
1416 {
1417 GetWeaponName(cache_get_field_content_int(i, "WeaponID"), weapname, sizeof(weapname));
1418 format(list, sizeof(list), "%s%d\t%s\t%s\n", list, i+1, weapname, convertNumber(cache_get_field_content_int(i, "Ammo")));
1419 }
1420
1421 ShowPlayerDialog(playerid, DIALOG_GUNS_TAKE, DIALOG_STYLE_TABLIST_HEADERS, "House Guns", list, "Take", "Back");
1422 }else{
1423 SendClientMessage(playerid, 0xE74C3CFF, "You don't have any guns in your house.");
1424 }
1425
1426 cache_delete(weapons);
1427 }
1428
1429 return 1;
1430 }
1431
1432 if(dialogid == DIALOG_GUNS_TAKE)
1433 {
1434 if(!response) return ShowHouseMenu(playerid);
1435 new id = InHouse[playerid];
1436 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1437 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1438 new query[96], Cache: weapon;
1439 mysql_format(SQLHandle, query, sizeof(query), "SELECT WeaponID, Ammo FROM houseguns WHERE HouseID=%d ORDER BY WeaponID ASC LIMIT %d, 1", id, listitem);
1440 weapon = mysql_query(SQLHandle, query);
1441 new rows = cache_num_rows();
1442 if(rows) {
1443 new string[64], weapname[32], weaponid = cache_get_field_content_int(0, "WeaponID");
1444 GetWeaponName(weaponid, weapname, sizeof(weapname));
1445 GivePlayerWeapon(playerid, weaponid, cache_get_field_content_int(0, "Ammo"));
1446 format(string, sizeof(string), "You've taken a %s from your house.", weapname);
1447 SendClientMessage(playerid, 0xFFFFFFFF, string);
1448 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM houseguns WHERE HouseID=%d AND WeaponID=%d", id, weaponid);
1449 mysql_tquery(SQLHandle, query, "", "");
1450 }else{
1451 SendClientMessage(playerid, 0xE74C3CFF, "Can't find that weapon.");
1452 }
1453
1454 cache_delete(weapon);
1455 return 1;
1456 }
1457
1458 if(dialogid == DIALOG_FURNITURE_MENU)
1459 {
1460 if(!response) return ShowHouseMenu(playerid);
1461 new id = InHouse[playerid];
1462 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1463 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1464 if(HouseData[id][SalePrice] > 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1465
1466 if(listitem == 0)
1467 {
1468 new list[512];
1469 format(list, sizeof(list), "#\tFurniture Name\tPrice\n");
1470 for(new i; i < sizeof(HouseFurnitures); ++i)
1471 {
1472 format(list, sizeof(list), "%s%d\t%s\t$%s\n", list, i+1, HouseFurnitures[i][Name], convertNumber(HouseFurnitures[i][Price]));
1473 }
1474
1475 ShowPlayerDialog(playerid, DIALOG_FURNITURE_BUY, DIALOG_STYLE_TABLIST_HEADERS, "Buy Furniture", list, "Buy", "Back");
1476 }
1477
1478 if(listitem == 1)
1479 {
1480 SelectMode[playerid] = SELECT_MODE_EDIT;
1481 SelectObject(playerid);
1482 SendClientMessage(playerid, 0xFFFFFFFF, "Click on the furniture you want to edit.");
1483 }
1484
1485 if(listitem == 2)
1486 {
1487 SelectMode[playerid] = SELECT_MODE_SELL;
1488 SelectObject(playerid);
1489 SendClientMessage(playerid, 0xFFFFFFFF, "Click on the furniture you want to sell.");
1490 }
1491
1492 if(listitem == 3)
1493 {
1494 new money, sold, data[e_furniture], query[64];
1495 for(new i; i < Streamer_GetUpperBound(STREAMER_TYPE_OBJECT); ++i)
1496 {
1497 if(!IsValidDynamicObject(i)) continue;
1498 Streamer_GetArrayData(STREAMER_TYPE_OBJECT, i, E_STREAMER_EXTRA_ID, data);
1499 if(data[SQLID] > 0 && data[HouseID] == id)
1500 {
1501 sold++;
1502 money += HouseFurnitures[ data[ArrayID] ][Price];
1503 DestroyDynamicObject(i);
1504 }
1505 }
1506
1507 new string[64];
1508 format(string, sizeof(string), "Sold %d furnitures for $%s.", sold, convertNumber(money));
1509 SendClientMessage(playerid, -1, string);
1510 GivePlayerMoney(playerid, money);
1511
1512 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housefurnitures WHERE HouseID=%d", id);
1513 mysql_tquery(SQLHandle, query, "", "");
1514 }
1515
1516 return 1;
1517 }
1518
1519 if(dialogid == DIALOG_FURNITURE_BUY)
1520 {
1521 if(!response) return ShowHouseMenu(playerid);
1522 new id = InHouse[playerid];
1523 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1524 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1525 if(HouseData[id][SalePrice] > 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1526 if(HouseFurnitures[listitem][Price] > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't afford this furniture.");
1527 GivePlayerMoney(playerid, -HouseFurnitures[listitem][Price]);
1528 new Float: x, Float: y, Float: z;
1529 GetPlayerPos(playerid, x, y, z);
1530 GetXYInFrontOfPlayer(playerid, x, y, 3.0);
1531 new objectid = CreateDynamicObject(HouseFurnitures[listitem][ModelID], x, y, z, 0.0, 0.0, 0.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)), query[256];
1532 mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO housefurnitures SET HouseID=%d, FurnitureID=%d, FurnitureX=%f, FurnitureY=%f, FurnitureZ=%f, FurnitureVW=%d, FurnitureInt=%d", id, listitem, x, y, z, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
1533 new Cache: add = mysql_query(SQLHandle, query), data[e_furniture];
1534 data[SQLID] = cache_insert_id();
1535 data[HouseID] = id;
1536 data[ArrayID] = listitem;
1537 data[furnitureX] = x;
1538 data[furnitureY] = y;
1539 data[furnitureZ] = z;
1540 data[furnitureRX] = 0.0;
1541 data[furnitureRY] = 0.0;
1542 data[furnitureRZ] = 0.0;
1543 cache_delete(add);
1544 Streamer_SetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
1545
1546 EditingFurniture[playerid] = true;
1547 EditDynamicObject(playerid, objectid);
1548 return 1;
1549 }
1550
1551 if(dialogid == DIALOG_FURNITURE_SELL)
1552 {
1553 if(!response) return 1;
1554 new id = InHouse[playerid];
1555 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1556 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1557 if(HouseData[id][SalePrice] > 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1558 new objectid = GetPVarInt(playerid, "SelectedFurniture"), query[64], data[e_furniture];
1559 Streamer_GetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
1560 GivePlayerMoney(playerid, HouseFurnitures[ data[ArrayID] ][Price]);
1561 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housefurnitures WHERE ID=%d", data[SQLID]);
1562 mysql_tquery(SQLHandle, query, "", "");
1563 DestroyDynamicObject(objectid);
1564 DeletePVar(playerid, "SelectedFurniture");
1565 return 1;
1566 }
1567
1568 if(dialogid == DIALOG_VISITORS_MENU)
1569 {
1570 if(!response) return ShowHouseMenu(playerid);
1571 new id = InHouse[playerid];
1572 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1573 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1574 if(listitem == 0)
1575 {
1576 new query[200], Cache: visitors;
1577 mysql_format(SQLHandle, query, sizeof(query), "SELECT Visitor, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as VisitDate FROM housevisitors WHERE HouseID=%d ORDER BY Date DESC LIMIT 0, 15", id);
1578 visitors = mysql_query(SQLHandle, query);
1579 new rows = cache_num_rows();
1580 if(rows) {
1581 new list[1024], visitor_name[MAX_PLAYER_NAME], visit_date[20];
1582 format(list, sizeof(list), "Visitor Name\tDate\n");
1583 for(new i; i < rows; ++i)
1584 {
1585 cache_get_field_content(i, "Visitor", visitor_name);
1586 cache_get_field_content(i, "VisitDate", visit_date);
1587 format(list, sizeof(list), "%s%s\t%s\n", list, visitor_name, visit_date);
1588 }
1589
1590 ShowPlayerDialog(playerid, DIALOG_VISITORS, DIALOG_STYLE_TABLIST_HEADERS, "House Visitors (Page 1)", list, "Next", "Previous");
1591 }else{
1592 SendClientMessage(playerid, 0xE74C3CFF, "You didn't had any visitors.");
1593 }
1594
1595 cache_delete(visitors);
1596 }
1597
1598 if(listitem == 1)
1599 {
1600 new query[64];
1601 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housevisitors WHERE HouseID=%d", id);
1602 mysql_tquery(SQLHandle, query, "", "");
1603 ShowHouseMenu(playerid);
1604 }
1605
1606 return 1;
1607 }
1608
1609 if(dialogid == DIALOG_VISITORS)
1610 {
1611 if(!response) {
1612 ListPage[playerid]--;
1613 if(ListPage[playerid] < 0)
1614 {
1615 ListPage[playerid] = 0;
1616 ShowHouseMenu(playerid);
1617 return 1;
1618 }
1619 }else{
1620 ListPage[playerid]++;
1621 }
1622
1623 new id = InHouse[playerid];
1624 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1625 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1626 new query[200], Cache: visitors;
1627 mysql_format(SQLHandle, query, sizeof(query), "SELECT Visitor, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as VisitDate FROM housevisitors WHERE HouseID=%d ORDER BY Date DESC LIMIT %d, 15", id, ListPage[playerid]*15);
1628 visitors = mysql_query(SQLHandle, query);
1629 new rows = cache_num_rows();
1630 if(rows) {
1631 new list[1024], visitor_name[MAX_PLAYER_NAME], visit_date[20];
1632 format(list, sizeof(list), "Visitor Name\tDate\n");
1633 for(new i; i < rows; ++i)
1634 {
1635 cache_get_field_content(i, "Visitor", visitor_name);
1636 cache_get_field_content(i, "VisitDate", visit_date);
1637 format(list, sizeof(list), "%s%s\t%s\n", list, visitor_name, visit_date);
1638 }
1639
1640 new title[32];
1641 format(title, sizeof(title), "House Visitors (Page %d)", ListPage[playerid]+1);
1642 ShowPlayerDialog(playerid, DIALOG_VISITORS, DIALOG_STYLE_TABLIST_HEADERS, title, list, "Next", "Previous");
1643 }else{
1644 SendClientMessage(playerid, 0xE74C3CFF, "Can't find any more visitors.");
1645 ListPage[playerid] = 0;
1646 ShowHouseMenu(playerid);
1647 }
1648
1649 cache_delete(visitors);
1650 return 1;
1651 }
1652
1653 if(dialogid == DIALOG_KEYS_MENU)
1654 {
1655 if(!response) return ShowHouseMenu(playerid);
1656 new id = InHouse[playerid];
1657 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1658 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1659 if(listitem == 0)
1660 {
1661 new query[200], Cache: keyowners;
1662 mysql_format(SQLHandle, query, sizeof(query), "SELECT Player, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as KeyDate FROM housekeys WHERE HouseID=%d ORDER BY Date DESC LIMIT %d, 15", id, ListPage[playerid]*15);
1663 keyowners = mysql_query(SQLHandle, query);
1664 new rows = cache_num_rows();
1665 if(rows) {
1666 new list[1024], key_name[MAX_PLAYER_NAME], key_date[20];
1667 format(list, sizeof(list), "Key Owner\tKey Given On\n");
1668 for(new i; i < rows; ++i)
1669 {
1670 cache_get_field_content(i, "Player", key_name);
1671 cache_get_field_content(i, "KeyDate", key_date);
1672 format(list, sizeof(list), "%s%s\t%s\n", list, key_name, key_date);
1673 }
1674
1675 ShowPlayerDialog(playerid, DIALOG_KEYS, DIALOG_STYLE_TABLIST_HEADERS, "Key Owners (Page 1)", list, "Next", "Previous");
1676 }else{
1677 SendClientMessage(playerid, 0xE74C3CFF, "Can't find any key owners.");
1678 }
1679
1680 cache_delete(keyowners);
1681 }
1682
1683 if(listitem == 1)
1684 {
1685 foreach(new i : Player)
1686 {
1687 if(Iter_Contains(HouseKeys[i], id)) Iter_Remove(HouseKeys[i], id);
1688 }
1689
1690 new query[64];
1691 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housekeys WHERE HouseID=%d", id);
1692 mysql_tquery(SQLHandle, query, "", "");
1693 ShowHouseMenu(playerid);
1694 }
1695
1696 return 1;
1697 }
1698
1699 if(dialogid == DIALOG_KEYS)
1700 {
1701 if(!response) {
1702 ListPage[playerid]--;
1703 if(ListPage[playerid] < 0)
1704 {
1705 ListPage[playerid] = 0;
1706 ShowHouseMenu(playerid);
1707 return 1;
1708 }
1709 }else{
1710 ListPage[playerid]++;
1711 }
1712
1713 new id = InHouse[playerid];
1714 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1715 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1716 new query[200], Cache: keyowners;
1717 mysql_format(SQLHandle, query, sizeof(query), "SELECT Player, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as KeyDate FROM housekeys WHERE HouseID=%d ORDER BY Date DESC LIMIT %d, 15", id, ListPage[playerid]*15);
1718 keyowners = mysql_query(SQLHandle, query);
1719 new rows = cache_num_rows();
1720 if(rows) {
1721 new list[1024], key_name[MAX_PLAYER_NAME], key_date[20];
1722 format(list, sizeof(list), "Key Owner\tKey Given On\n");
1723 for(new i; i < rows; ++i)
1724 {
1725 cache_get_field_content(i, "Player", key_name);
1726 cache_get_field_content(i, "KeyDate", key_date);
1727 format(list, sizeof(list), "%s%s\t%s\n", list, key_name, key_date);
1728 }
1729
1730 new title[32];
1731 format(title, sizeof(title), "Key Owners (Page %d)", ListPage[playerid]+1);
1732 ShowPlayerDialog(playerid, DIALOG_KEYS, DIALOG_STYLE_TABLIST_HEADERS, title, list, "Next", "Previous");
1733 }else{
1734 ListPage[playerid] = 0;
1735 ShowHouseMenu(playerid);
1736 SendClientMessage(playerid, 0xE74C3CFF, "Can't find any more key owners.");
1737 }
1738
1739 cache_delete(keyowners);
1740 return 1;
1741 }
1742
1743 if(dialogid == DIALOG_SAFE_HISTORY)
1744 {
1745 if(!response) {
1746 ListPage[playerid]--;
1747 if(ListPage[playerid] < 0)
1748 {
1749 ListPage[playerid] = 0;
1750 ShowHouseMenu(playerid);
1751 return 1;
1752 }
1753 }else{
1754 ListPage[playerid]++;
1755 }
1756
1757 new id = InHouse[playerid];
1758 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1759 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1760 new query[200], Cache: safelog;
1761 mysql_format(SQLHandle, query, sizeof(query), "SELECT Type, Amount, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as TransactionDate FROM housesafelogs WHERE HouseID=%d ORDER BY Date DESC LIMIT %d, 15", id, ListPage[playerid]*15);
1762 safelog = mysql_query(SQLHandle, query);
1763 new rows = cache_num_rows();
1764 if(rows) {
1765 new list[1024], date[20];
1766 format(list, sizeof(list), "Action\tDate\n");
1767 for(new i; i < rows; ++i)
1768 {
1769 cache_get_field_content(i, "TransactionDate", date);
1770 format(list, sizeof(list), "%s%s $%s\t{FFFFFF}%s\n", list, TransactionNames[ cache_get_field_content_int(i, "Type") ], convertNumber(cache_get_field_content_int(i, "Amount")), date);
1771 }
1772
1773 new title[32];
1774 format(title, sizeof(title), "Safe History (Page %d)", ListPage[playerid]+1);
1775 ShowPlayerDialog(playerid, DIALOG_SAFE_HISTORY, DIALOG_STYLE_TABLIST_HEADERS, title, list, "Next", "Previous");
1776 }else{
1777 SendClientMessage(playerid, 0xE74C3CFF, "Can't find any more safe history.");
1778 }
1779
1780 cache_delete(safelog);
1781 return 1;
1782 }
1783
1784 if(dialogid == DIALOG_MY_KEYS)
1785 {
1786 if(!response) {
1787 ListPage[playerid]--;
1788 if(ListPage[playerid] < 0)
1789 {
1790 ListPage[playerid] = 0;
1791 return 1;
1792 }
1793 }else{
1794 ListPage[playerid]++;
1795 }
1796
1797 new query[200], Cache: mykeys;
1798 mysql_format(SQLHandle, query, sizeof(query), "SELECT HouseID, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as KeyDate FROM housekeys WHERE Player='%e' ORDER BY Date DESC LIMIT %d, 15", Player_GetName(playerid), ListPage[playerid]*15);
1799 mykeys = mysql_query(SQLHandle, query);
1800
1801 new rows = cache_num_rows();
1802 if(rows) {
1803 new list[1024], id, key_date[20];
1804 format(list, sizeof(list), "House Info\tKey Given On\n");
1805 for(new i; i < rows; ++i)
1806 {
1807 id = cache_get_field_content_int(i, "HouseID");
1808 cache_get_field_content(i, "KeyDate", key_date);
1809 format(list, sizeof(list), "%s%s's %s\t%s\n", list, HouseData[id][Owner], HouseData[id][Name], key_date);
1810 }
1811
1812 new title[32];
1813 format(title, sizeof(title), "My Keys (Page %d)", ListPage[playerid]+1);
1814 ShowPlayerDialog(playerid, DIALOG_MY_KEYS, DIALOG_STYLE_TABLIST_HEADERS, title, list, "Next", "Previous");
1815 }else{
1816 ListPage[playerid] = 0;
1817 SendClientMessage(playerid, 0xE74C3CFF, "Can't find any more keys.");
1818 }
1819
1820 cache_delete(mykeys);
1821 return 1;
1822 }
1823
1824 if(dialogid == DIALOG_BUY_HOUSE_FROM_OWNER)
1825 {
1826 if(!response) return 1;
1827 new id = GetPVarInt(playerid, "PickupHouseID");
1828 if(!IsPlayerInRangeOfPoint(playerid, 2.0, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ])) return SendClientMessage(playerid, 0xE74C3CFF, "You're not near any house.");
1829 #if LIMIT_PER_PLAYER > 0
1830 if(OwnedHouses(playerid) + 1 > LIMIT_PER_PLAYER) return SendClientMessage(playerid, 0xE74C3CFF, "You can't buy any more houses.");
1831 #endif
1832 if(HouseData[id][SalePrice] > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't afford this house.");
1833 if(HouseData[id][SalePrice] < 1) return SendClientMessage(playerid, 0xE74C3CFF, "Someone already owns this house.");
1834 new old_owner[MAX_PLAYER_NAME], price = HouseData[id][SalePrice], owner_id = INVALID_PLAYER_ID;
1835 format(old_owner, MAX_PLAYER_NAME, "%s", HouseData[id][Owner]);
1836
1837 foreach(new i : Player)
1838 {
1839 if(!strcmp(HouseData[id][Owner], Player_GetName(i)))
1840 {
1841 owner_id = i;
1842 break;
1843 }
1844 }
1845
1846 GivePlayerMoney(playerid, -HouseData[id][SalePrice]);
1847 GetPlayerName(playerid, HouseData[id][Owner], MAX_PLAYER_NAME);
1848 HouseData[id][LastEntered] = gettime();
1849 HouseData[id][SalePrice] = 0;
1850 HouseData[id][Save] = true;
1851
1852 UpdateHouseLabel(id);
1853 Streamer_SetIntData(STREAMER_TYPE_PICKUP, HouseData[id][HousePickup], E_STREAMER_MODEL_ID, 19522);
1854 Streamer_SetIntData(STREAMER_TYPE_MAP_ICON, HouseData[id][HouseIcon], E_STREAMER_TYPE, 32);
1855 SendToHouse(playerid, id);
1856
1857 foreach(new i : Player)
1858 {
1859 if(i == playerid) continue;
1860 if(InHouse[i] == id)
1861 {
1862 SetPVarInt(i, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
1863 SetPlayerVirtualWorld(i, 0);
1864 SetPlayerInterior(i, 0);
1865 SetPlayerPos(i, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]);
1866 InHouse[i] = INVALID_HOUSE_ID;
1867 }
1868
1869 if(Iter_Contains(HouseKeys[i], id)) Iter_Remove(HouseKeys[i], id);
1870 }
1871
1872 new query[128];
1873 if(IsPlayerConnected(owner_id)) {
1874 GivePlayerMoney(owner_id, price);
1875
1876 new string[128];
1877 format(string, sizeof(string), "%s(%d) has bought your house for $%s.", HouseData[id][Owner], playerid, convertNumber(price));
1878 SendClientMessage(owner_id, -1, string);
1879 }else{
1880 mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO housesales SET OldOwner='%e', NewOwner='%e', Price=%d", old_owner, HouseData[id][Owner], price);
1881 mysql_tquery(SQLHandle, query, "", "");
1882 }
1883
1884 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housevisitors WHERE HouseID=%d", id);
1885 mysql_tquery(SQLHandle, query, "", "");
1886
1887 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housekeys WHERE HouseID=%d", id);
1888 mysql_tquery(SQLHandle, query, "", "");
1889
1890 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housesafelogs WHERE HouseID=%d", id);
1891 mysql_tquery(SQLHandle, query, "", "");
1892 return 1;
1893 }
1894
1895 if(dialogid == DIALOG_SELL_HOUSE)
1896 {
1897 if(!response) return ShowHouseMenu(playerid);
1898 new id = InHouse[playerid];
1899 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1900 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1901 if(listitem == 0)
1902 {
1903 new money = floatround(HouseData[id][Price] * 0.85) + HouseData[id][SafeMoney];
1904 GivePlayerMoney(playerid, money);
1905 ResetHouse(id);
1906 }
1907
1908 if(listitem == 1)
1909 {
1910 if(HouseData[id][SalePrice] > 0) {
1911 HouseData[id][SalePrice] = 0;
1912 HouseData[id][Save] = true;
1913
1914 UpdateHouseLabel(id);
1915 Streamer_SetIntData(STREAMER_TYPE_PICKUP, HouseData[id][HousePickup], E_STREAMER_MODEL_ID, 19522);
1916 Streamer_SetIntData(STREAMER_TYPE_MAP_ICON, HouseData[id][HouseIcon], E_STREAMER_TYPE, 32);
1917 SendClientMessage(playerid, -1, "Your house is no longer for sale.");
1918 }else{
1919 if(HouseData[id][SafeMoney] > 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't put your house for sale if there's money in the safe.");
1920 ShowPlayerDialog(playerid, DIALOG_SELLING_PRICE, DIALOG_STYLE_INPUT, "Sell House", "How much do you want for your house?", "Put For Sale", "Cancel");
1921 }
1922 }
1923
1924 return 1;
1925 }
1926
1927 if(dialogid == DIALOG_SELLING_PRICE)
1928 {
1929 if(!response) return ShowHouseMenu(playerid);
1930 new id = InHouse[playerid];
1931 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1932 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1933 new amount = strval(inputtext);
1934 if(!(1 <= amount <= 10000000)) return ShowPlayerDialog(playerid, DIALOG_SELLING_PRICE, DIALOG_STYLE_INPUT, "Sell House", "{E74C3C}You can't put your house for sale for less than $1 or more than $100,000,000.\n\n{FFFFFF}How much do you want for your house?", "Put For Sale", "Cancel");
1935 HouseData[id][SalePrice] = amount;
1936 HouseData[id][Save] = true;
1937
1938 UpdateHouseLabel(id);
1939 Streamer_SetIntData(STREAMER_TYPE_PICKUP, HouseData[id][HousePickup], E_STREAMER_MODEL_ID, 1273);
1940 Streamer_SetIntData(STREAMER_TYPE_MAP_ICON, HouseData[id][HouseIcon], E_STREAMER_TYPE, 31);
1941
1942 new string[128];
1943 format(string, sizeof(string), "You put your house for sale for $%s.", convertNumber(amount));
1944 SendClientMessage(playerid, -1, string);
1945 return 1;
1946 }
1947
1948 return 0;
1949}
1950
1951public OnPlayerSelectDynamicObject(playerid, objectid, modelid, Float: x, Float: y, Float: z)
1952{
1953 switch(SelectMode[playerid])
1954 {
1955 case SELECT_MODE_EDIT:
1956 {
1957 EditingFurniture[playerid] = true;
1958 EditDynamicObject(playerid, objectid);
1959 }
1960
1961 case SELECT_MODE_SELL:
1962 {
1963 CancelEdit(playerid);
1964
1965 new data[e_furniture], string[128];
1966 SetPVarInt(playerid, "SelectedFurniture", objectid);
1967 Streamer_GetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
1968 format(string, sizeof(string), "Do you want to sell your %s?\nYou'll get {2ECC71}$%s.", HouseFurnitures[ data[ArrayID] ][Name], convertNumber(HouseFurnitures[ data[ArrayID] ][Price]));
1969 ShowPlayerDialog(playerid, DIALOG_FURNITURE_SELL, DIALOG_STYLE_MSGBOX, "Confirm Sale", string, "Sell", "Close");
1970 }
1971 }
1972
1973 SelectMode[playerid] = SELECT_MODE_NONE;
1974 return 1;
1975}
1976
1977public OnPlayerEditDynamicObject(playerid, objectid, response, Float: x, Float: y, Float: z, Float: rx, Float: ry, Float: rz)
1978{
1979 if(EditingFurniture[playerid])
1980 {
1981 switch(response)
1982 {
1983 case EDIT_RESPONSE_CANCEL:
1984 {
1985 new data[e_furniture];
1986 Streamer_GetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
1987 SetDynamicObjectPos(objectid, data[furnitureX], data[furnitureY], data[furnitureZ]);
1988 SetDynamicObjectRot(objectid, data[furnitureRX], data[furnitureRY], data[furnitureRZ]);
1989
1990 EditingFurniture[playerid] = false;
1991 }
1992
1993 case EDIT_RESPONSE_FINAL:
1994 {
1995 new data[e_furniture], query[256];
1996 Streamer_GetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
1997 data[furnitureX] = x;
1998 data[furnitureY] = y;
1999 data[furnitureZ] = z;
2000 data[furnitureRX] = rx;
2001 data[furnitureRY] = ry;
2002 data[furnitureRZ] = rz;
2003 SetDynamicObjectPos(objectid, data[furnitureX], data[furnitureY], data[furnitureZ]);
2004 SetDynamicObjectRot(objectid, data[furnitureRX], data[furnitureRY], data[furnitureRZ]);
2005 Streamer_SetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
2006
2007 mysql_format(SQLHandle, query, sizeof(query), "UPDATE housefurnitures SET FurnitureX=%f, FurnitureY=%f, FurnitureZ=%f, FurnitureRX=%f, FurnitureRY=%f, FurnitureRZ=%f WHERE ID=%d", data[furnitureX], data[furnitureY], data[furnitureZ], data[furnitureRX], data[furnitureRY], data[furnitureRZ], data[SQLID]);
2008 mysql_tquery(SQLHandle, query, "", "");
2009
2010 EditingFurniture[playerid] = false;
2011 }
2012 }
2013 }
2014
2015 return 1;
2016}
2017
2018/* ============ Player Commands ============ */
2019CMD:house(playerid, params[])
2020{
2021 if(InHouse[playerid] == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
2022 ShowHouseMenu(playerid);
2023 return 1;
2024}
2025
2026CMD:myhousekeys(playerid, params[])
2027{
2028 new query[200], Cache: mykeys;
2029 mysql_format(SQLHandle, query, sizeof(query), "SELECT HouseID, FROM_UNIXTIME(Date, '%%d/%%m/%%Y %%H:%%i') as KeyDate FROM housekeys WHERE Player='%e' ORDER BY Date DESC LIMIT 0, 15", Player_GetName(playerid));
2030 mykeys = mysql_query(SQLHandle, query);
2031 ListPage[playerid] = 0;
2032
2033 new rows = cache_num_rows();
2034 if(rows) {
2035 new list[1024], id, key_date[20];
2036 format(list, sizeof(list), "House Info\tKey Given On\n");
2037 for(new i; i < rows; ++i)
2038 {
2039 id = cache_get_field_content_int(i, "HouseID");
2040 cache_get_field_content(i, "KeyDate", key_date);
2041 format(list, sizeof(list), "%s%s's %s\t%s\n", list, HouseData[id][Owner], HouseData[id][Name], key_date);
2042 }
2043
2044 ShowPlayerDialog(playerid, DIALOG_MY_KEYS, DIALOG_STYLE_TABLIST_HEADERS, "My Keys (Page 1)", list, "Next", "Close");
2045 }else{
2046 SendClientMessage(playerid, 0xE74C3CFF, "You don't have any keys for any houses.");
2047 }
2048
2049 cache_delete(mykeys);
2050 return 1;
2051}
2052
2053CMD:givehousekeys(playerid, params[])
2054{
2055 if(InHouse[playerid] == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
2056 new id, houseid = InHouse[playerid];
2057 if(strcmp(HouseData[houseid][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
2058 if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /givehousekeys [player id]");
2059 if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xE74C3CFF, "Invalid player ID.");
2060 if(id == playerid) return SendClientMessage(playerid, 0xE74C3CFF, "You're the owner, you don't need keys.");
2061 if(Iter_Contains(HouseKeys[id], houseid)) return SendClientMessage(playerid, 0xE74C3CFF, "That player has keys for this house.");
2062 Iter_Add(HouseKeys[id], houseid);
2063
2064 new query[128];
2065 mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO housekeys SET HouseID=%d, Player='%e', Date=UNIX_TIMESTAMP()", houseid, Player_GetName(id));
2066 mysql_tquery(SQLHandle, query, "", "");
2067
2068 format(query, sizeof(query), "You've given keys to %s for this house.", Player_GetName(id));
2069 SendClientMessage(playerid, -1, query);
2070 format(query, sizeof(query), "Now you have keys for %s's house, %s.", HouseData[houseid][Owner], HouseData[houseid][Name]);
2071 SendClientMessage(id, -1, query);
2072 return 1;
2073}
2074
2075CMD:takehousekeys(playerid, params[])
2076{
2077 if(InHouse[playerid] == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
2078 new id, houseid = InHouse[playerid];
2079 if(strcmp(HouseData[houseid][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
2080 if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /takehousekeys [player id]");
2081 if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xE74C3CFF, "Invalid player ID.");
2082 if(id == playerid) return SendClientMessage(playerid, 0xE74C3CFF, "You're the owner, you can't take your keys.");
2083 if(!Iter_Contains(HouseKeys[id], houseid)) return SendClientMessage(playerid, 0xE74C3CFF, "That player doesn't have keys for this house.");
2084 Iter_Remove(HouseKeys[id], houseid);
2085
2086 new query[128];
2087 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housekeys WHERE HouseID=%d AND Player='%e'", houseid, Player_GetName(id));
2088 mysql_tquery(SQLHandle, query, "", "");
2089
2090 format(query, sizeof(query), "You've taken keys from %s for this house.", Player_GetName(id));
2091 SendClientMessage(playerid, -1, query);
2092 format(query, sizeof(query), "House owner %s has taken your keys for their house %s.", HouseData[houseid][Owner], HouseData[houseid][Name]);
2093 SendClientMessage(id, -1, query);
2094 return 1;
2095}
2096
2097CMD:kickfromhouse(playerid, params[])
2098{
2099 if(InHouse[playerid] == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
2100 new id, houseid = InHouse[playerid];
2101 if(strcmp(HouseData[houseid][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
2102 if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /kickfromhouse [player id]");
2103 if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xE74C3CFF, "Invalid player ID.");
2104 if(id == playerid) return SendClientMessage(playerid, 0xE74C3CFF, "You can't kick yourself from your house.");
2105 if(InHouse[id] != houseid) return SendClientMessage(playerid, 0xE74C3CFF, "That player isn't in your house.");
2106 SendClientMessage(playerid, -1, "Player kicked.");
2107 SendClientMessage(id, -1, "You got kicked by the house owner.");
2108 SetPVarInt(id, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
2109 SetPlayerVirtualWorld(id, 0);
2110 SetPlayerInterior(id, 0);
2111 SetPlayerPos(id, HouseData[houseid][houseX], HouseData[houseid][houseY], HouseData[houseid][houseZ]);
2112 InHouse[id] = INVALID_HOUSE_ID;
2113 return 1;
2114}
2115
2116/* ============ Admin Commands ============ */
2117CMD:createhouse(playerid, params[])
2118{
2119 if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this command.");
2120 new interior, price;
2121 if(sscanf(params, "ii", price, interior)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /createhouse [price] [interior id]");
2122 if(!(0 <= interior <= sizeof(HouseInteriors)-1)) return SendClientMessage(playerid, 0xE74C3CFF, "Interior ID you entered does not exist.");
2123 new id = Iter_Free(Houses);
2124 if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "You can't create more houses.");
2125 SetPVarInt(playerid, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
2126 format(HouseData[id][Name], MAX_HOUSE_NAME, "House For Sale");
2127 format(HouseData[id][Owner], MAX_PLAYER_NAME, "-");
2128 format(HouseData[id][Password], MAX_HOUSE_PASSWORD, "-");
2129 GetPlayerPos(playerid, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]);
2130 HouseData[id][Price] = price;
2131 HouseData[id][Interior] = interior;
2132 HouseData[id][LockMode] = LOCK_MODE_NOLOCK;
2133 HouseData[id][SalePrice] = HouseData[id][SafeMoney] = HouseData[id][LastEntered] = 0;
2134 format(HouseData[id][Address], MAX_HOUSE_ADDRESS, "%d, %s, %s", id, GetZoneName(HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]), GetCityName(HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]));
2135 HouseData[id][Save] = true;
2136
2137 new label[200];
2138 format(label, sizeof(label), "{2ECC71}House For Sale (ID: %d)\n{FFFFFF}%s\n{F1C40F}Price: {2ECC71}$%s", id, HouseInteriors[interior][IntName], convertNumber(price));
2139 HouseData[id][HouseLabel] = CreateDynamic3DTextLabel(label, 0xFFFFFFFF, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]+0.35, 15.0, .testlos = 1);
2140 HouseData[id][HousePickup] = CreateDynamicPickup(1273, 1, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]);
2141 HouseData[id][HouseIcon] = CreateDynamicMapIcon(HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ], 31, 0);
2142
2143 new query[256];
2144 mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO houses SET ID=%d, HouseX=%f, HouseY=%f, HouseZ=%f, HousePrice=%d, HouseInterior=%d", id, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ], price, interior);
2145 mysql_tquery(SQLHandle, query, "", "");
2146 Iter_Add(Houses, id);
2147 return 1;
2148}
2149
2150CMD:gotohouse(playerid, params[])
2151{
2152 if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this command.");
2153 new id;
2154 if(sscanf(params, "i", id)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /gotohouse [house id]");
2155 if(!Iter_Contains(Houses, id)) return SendClientMessage(playerid, 0xE74C3CFF, "House ID you entered does not exist.");
2156 SetPVarInt(playerid, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
2157 SetPlayerPos(playerid, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]);
2158 SetPlayerInterior(playerid, 0);
2159 SetPlayerVirtualWorld(playerid, 0);
2160 return 1;
2161}
2162
2163CMD:hsetinterior(playerid, params[])
2164{
2165 if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this command.");
2166 new id, interior;
2167 if(sscanf(params, "ii", id, interior)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /hsetinterior [house id] [interior id]");
2168 if(!Iter_Contains(Houses, id)) return SendClientMessage(playerid, 0xE74C3CFF, "House ID you entered does not exist.");
2169 if(!(0 <= interior <= sizeof(HouseInteriors)-1)) return SendClientMessage(playerid, 0xE74C3CFF, "Interior ID you entered does not exist.");
2170 HouseData[id][Interior] = interior;
2171
2172 new query[64];
2173 mysql_format(SQLHandle, query, sizeof(query), "UPDATE houses SET HouseInterior=%d WHERE ID=%d", interior, id);
2174 mysql_tquery(SQLHandle, query, "", "");
2175
2176 UpdateHouseLabel(id);
2177 SendClientMessage(playerid, -1, "Interior updated.");
2178 return 1;
2179}
2180
2181CMD:hsetprice(playerid, params[])
2182{
2183 if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this command.");
2184 new id, price;
2185 if(sscanf(params, "ii", id, price)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /hsetprice [house id] [price]");
2186 if(!Iter_Contains(Houses, id)) return SendClientMessage(playerid, 0xE74C3CFF, "House ID you entered does not exist.");
2187 HouseData[id][Price] = price;
2188
2189 new query[64];
2190 mysql_format(SQLHandle, query, sizeof(query), "UPDATE houses SET HousePrice=%d WHERE ID=%d", price, id);
2191 mysql_tquery(SQLHandle, query, "", "");
2192
2193 UpdateHouseLabel(id);
2194 SendClientMessage(playerid, -1, "Price updated.");
2195 return 1;
2196}
2197
2198CMD:resethouse(playerid, params[])
2199{
2200 if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this command.");
2201 new id;
2202 if(sscanf(params, "i", id)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /resethouse [house id]");
2203 if(!Iter_Contains(Houses, id)) return SendClientMessage(playerid, 0xE74C3CFF, "House ID you entered does not exist.");
2204 ResetHouse(id);
2205 SendClientMessage(playerid, -1, "House reset.");
2206 return 1;
2207}
2208
2209CMD:deletehouse(playerid, params[])
2210{
2211 if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this command.");
2212 new id;
2213 if(sscanf(params, "i", id)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /deletehouse [house id]");
2214 if(!Iter_Contains(Houses, id)) return SendClientMessage(playerid, 0xE74C3CFF, "House ID you entered does not exist.");
2215 ResetHouse(id);
2216 DestroyDynamic3DTextLabel(HouseData[id][HouseLabel]);
2217 DestroyDynamicPickup(HouseData[id][HousePickup]);
2218 DestroyDynamicMapIcon(HouseData[id][HouseIcon]);
2219 Iter_Remove(Houses, id);
2220 HouseData[id][HouseLabel] = Text3D: INVALID_3DTEXT_ID;
2221 HouseData[id][HousePickup] = HouseData[id][HouseIcon] = -1;
2222 HouseData[id][Save] = false;
2223
2224 new query[64];
2225 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM houses WHERE ID=%d", id);
2226 mysql_tquery(SQLHandle, query, "", "");
2227 SendClientMessage(playerid, -1, "House deleted.");
2228 return 1;
2229}