· 8 years ago · Apr 05, 2018, 06:42 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 return 1;
1169 }
1170
1171 if(dialogid == DIALOG_HOUSE_PASSWORD)
1172 {
1173 if(!response) return 1;
1174 new id = GetPVarInt(playerid, "PickupHouseID");
1175 if(!IsPlayerInRangeOfPoint(playerid, 2.0, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ])) return SendClientMessage(playerid, 0xE74C3CFF, "You're not near any house.");
1176 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");
1177 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");
1178 SendToHouse(playerid, id);
1179 return 1;
1180 }
1181
1182 if(dialogid == DIALOG_HOUSE_MENU)
1183 {
1184 if(!response) return 1;
1185 new id = InHouse[playerid];
1186 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1187 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1188
1189 if(listitem == 0) ShowPlayerDialog(playerid, DIALOG_HOUSE_NAME, DIALOG_STYLE_INPUT, "House Name", "Write a new name for this house:", "Change", "Back");
1190 if(listitem == 1) ShowPlayerDialog(playerid, DIALOG_HOUSE_NEW_PASSWORD, DIALOG_STYLE_INPUT, "House Password", "Write a new password for this house:", "Change", "Back");
1191 if(listitem == 2) ShowPlayerDialog(playerid, DIALOG_HOUSE_LOCK, DIALOG_STYLE_LIST, "House Lock", "Not Locked\nPassword Lock\nKeys\nOwner Only", "Change", "Back");
1192 if(listitem == 3)
1193 {
1194 if(HouseData[id][SalePrice] > 0)
1195 {
1196 SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1197 return ShowHouseMenu(playerid);
1198 }
1199
1200 new string[144];
1201 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)));
1202 ShowPlayerDialog(playerid, DIALOG_SAFE_MENU, DIALOG_STYLE_LIST, "House Safe", string, "Choose", "Back");
1203 }
1204
1205 if(listitem == 4)
1206 {
1207 if(HouseData[id][SalePrice] > 0)
1208 {
1209 SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1210 return ShowHouseMenu(playerid);
1211 }
1212
1213 ShowPlayerDialog(playerid, DIALOG_FURNITURE_MENU, DIALOG_STYLE_LIST, "Furnitures", "Buy Furniture\nEdit Furniture\nSell Furniture\nSell All Furnitures", "Choose", "Back");
1214 }
1215
1216 if(listitem == 5) ShowPlayerDialog(playerid, DIALOG_GUNS_MENU, DIALOG_STYLE_LIST, "Guns", "Put Gun\nTake Gun", "Choose", "Back");
1217 if(listitem == 6)
1218 {
1219 ListPage[playerid] = 0;
1220 ShowPlayerDialog(playerid, DIALOG_VISITORS_MENU, DIALOG_STYLE_LIST, "Visitors", "Look Visitor History\nClear Visitor History", "Choose", "Back");
1221 }
1222
1223 if(listitem == 7)
1224 {
1225 ListPage[playerid] = 0;
1226 ShowPlayerDialog(playerid, DIALOG_KEYS_MENU, DIALOG_STYLE_LIST, "Keys", "View Key Owners\nChange Locks", "Choose", "Back");
1227 }
1228
1229 if(listitem == 8)
1230 {
1231 new string[128];
1232 format(string, sizeof(string), "House owner %s kicked everybody from the house.", HouseData[id][Owner]);
1233
1234 foreach(new i : Player)
1235 {
1236 if(i == playerid) continue;
1237 if(InHouse[i] == id)
1238 {
1239 SetPVarInt(i, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
1240 SetPlayerVirtualWorld(i, 0);
1241 SetPlayerInterior(i, 0);
1242 SetPlayerPos(i, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]);
1243 InHouse[i] = INVALID_HOUSE_ID;
1244 SendClientMessage(i, -1, string);
1245 }
1246 }
1247
1248 SendClientMessage(playerid, -1, "You kicked everybody from your house.");
1249 }
1250
1251 if(listitem == 9)
1252 {
1253 new string[128];
1254 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"));
1255 ShowPlayerDialog(playerid, DIALOG_SELL_HOUSE, DIALOG_STYLE_TABLIST, "Sell House", string, "Choose", "Back");
1256 }
1257
1258 return 1;
1259 }
1260
1261 if(dialogid == DIALOG_HOUSE_NAME)
1262 {
1263 if(!response) return ShowHouseMenu(playerid);
1264 new id = InHouse[playerid];
1265 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1266 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1267 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");
1268 format(HouseData[id][Name], MAX_HOUSE_NAME, "%s", inputtext);
1269 HouseData[id][Save] = true;
1270
1271 UpdateHouseLabel(id);
1272 ShowHouseMenu(playerid);
1273 return 1;
1274 }
1275
1276 if(dialogid == DIALOG_HOUSE_NEW_PASSWORD)
1277 {
1278 if(!response) return ShowHouseMenu(playerid);
1279 new id = InHouse[playerid];
1280 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1281 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1282 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");
1283 format(HouseData[id][Password], MAX_HOUSE_PASSWORD, "%s", inputtext);
1284 HouseData[id][Save] = true;
1285 ShowHouseMenu(playerid);
1286 return 1;
1287 }
1288
1289 if(dialogid == DIALOG_HOUSE_LOCK)
1290 {
1291 if(!response) return ShowHouseMenu(playerid);
1292 new id = InHouse[playerid];
1293 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1294 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1295 HouseData[id][LockMode] = listitem;
1296 HouseData[id][Save] = true;
1297
1298 UpdateHouseLabel(id);
1299 ShowHouseMenu(playerid);
1300 return 1;
1301 }
1302
1303 if(dialogid == DIALOG_SAFE_MENU)
1304 {
1305 if(!response) return ShowHouseMenu(playerid);
1306 new id = InHouse[playerid];
1307 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1308 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1309 if(HouseData[id][SalePrice] > 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1310 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");
1311 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");
1312 if(listitem == 2)
1313 {
1314 ListPage[playerid] = 0;
1315
1316 new query[200], Cache: safelog;
1317 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);
1318 safelog = mysql_query(SQLHandle, query);
1319 new rows = cache_num_rows();
1320 if(rows) {
1321 new list[1024], date[20];
1322 format(list, sizeof(list), "Action\tDate\n");
1323 for(new i; i < rows; ++i)
1324 {
1325 cache_get_field_content(i, "TransactionDate", date);
1326 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);
1327 }
1328
1329 ShowPlayerDialog(playerid, DIALOG_SAFE_HISTORY, DIALOG_STYLE_TABLIST_HEADERS, "Safe History (Page 1)", list, "Next", "Previous");
1330 }else{
1331 SendClientMessage(playerid, 0xE74C3CFF, "Can't find any safe history.");
1332 }
1333
1334 cache_delete(safelog);
1335 }
1336
1337 if(listitem == 3)
1338 {
1339 new query[64];
1340 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housesafelogs WHERE HouseID=%d", id);
1341 mysql_tquery(SQLHandle, query, "", "");
1342 ShowHouseMenu(playerid);
1343 }
1344
1345 return 1;
1346 }
1347
1348 if(dialogid == DIALOG_SAFE_TAKE)
1349 {
1350 if(!response) return ShowHouseMenu(playerid);
1351 new id = InHouse[playerid];
1352 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1353 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1354 if(HouseData[id][SalePrice] > 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1355 new amount = strval(inputtext);
1356 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");
1357 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");
1358 new query[128];
1359 mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO housesafelogs SET HouseID=%d, Type=0, Amount=%d, Date=UNIX_TIMESTAMP()", id, amount);
1360 mysql_tquery(SQLHandle, query, "", "");
1361
1362 GivePlayerMoney(playerid, amount);
1363 HouseData[id][SafeMoney] -= amount;
1364 HouseData[id][Save] = true;
1365 ShowHouseMenu(playerid);
1366 return 1;
1367 }
1368
1369 if(dialogid == DIALOG_SAFE_PUT)
1370 {
1371 if(!response) return ShowHouseMenu(playerid);
1372 new id = InHouse[playerid];
1373 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1374 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1375 new amount = strval(inputtext);
1376 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");
1377 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");
1378 new query[128];
1379 mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO housesafelogs SET HouseID=%d, Type=1, Amount=%d, Date=UNIX_TIMESTAMP()", id, amount);
1380 mysql_tquery(SQLHandle, query, "", "");
1381
1382 GivePlayerMoney(playerid, -amount);
1383 HouseData[id][SafeMoney] += amount;
1384 HouseData[id][Save] = true;
1385 ShowHouseMenu(playerid);
1386 return 1;
1387 }
1388
1389 if(dialogid == DIALOG_GUNS_MENU)
1390 {
1391 if(!response) return ShowHouseMenu(playerid);
1392 new id = InHouse[playerid];
1393 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1394 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1395 if(listitem == 0)
1396 {
1397 if(GetPlayerWeapon(playerid) == 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't put your fists in your house.");
1398 new query[128], weapon = GetPlayerWeapon(playerid), ammo = GetPlayerAmmo(playerid);
1399 RemovePlayerWeapon(playerid, weapon);
1400 mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO houseguns VALUES (%d, %d, %d) ON DUPLICATE KEY UPDATE Ammo=Ammo+%d", id, weapon, ammo, ammo);
1401 mysql_tquery(SQLHandle, query, "", "");
1402 ShowHouseMenu(playerid);
1403 }
1404
1405 if(listitem == 1)
1406 {
1407 new query[80], Cache: weapons;
1408 mysql_format(SQLHandle, query, sizeof(query), "SELECT WeaponID, Ammo FROM houseguns WHERE HouseID=%d ORDER BY WeaponID ASC", id);
1409 weapons = mysql_query(SQLHandle, query);
1410 new rows = cache_num_rows();
1411 if(rows) {
1412 new list[512], weapname[32];
1413 format(list, sizeof(list), "#\tWeapon Name\tAmmo\n");
1414 for(new i; i < rows; ++i)
1415 {
1416 GetWeaponName(cache_get_field_content_int(i, "WeaponID"), weapname, sizeof(weapname));
1417 format(list, sizeof(list), "%s%d\t%s\t%s\n", list, i+1, weapname, convertNumber(cache_get_field_content_int(i, "Ammo")));
1418 }
1419
1420 ShowPlayerDialog(playerid, DIALOG_GUNS_TAKE, DIALOG_STYLE_TABLIST_HEADERS, "House Guns", list, "Take", "Back");
1421 }else{
1422 SendClientMessage(playerid, 0xE74C3CFF, "You don't have any guns in your house.");
1423 }
1424
1425 cache_delete(weapons);
1426 }
1427
1428 return 1;
1429 }
1430
1431 if(dialogid == DIALOG_GUNS_TAKE)
1432 {
1433 if(!response) return ShowHouseMenu(playerid);
1434 new id = InHouse[playerid];
1435 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1436 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1437 new query[96], Cache: weapon;
1438 mysql_format(SQLHandle, query, sizeof(query), "SELECT WeaponID, Ammo FROM houseguns WHERE HouseID=%d ORDER BY WeaponID ASC LIMIT %d, 1", id, listitem);
1439 weapon = mysql_query(SQLHandle, query);
1440 new rows = cache_num_rows();
1441 if(rows) {
1442 new string[64], weapname[32], weaponid = cache_get_field_content_int(0, "WeaponID");
1443 GetWeaponName(weaponid, weapname, sizeof(weapname));
1444 GivePlayerWeapon(playerid, weaponid, cache_get_field_content_int(0, "Ammo"));
1445 format(string, sizeof(string), "You've taken a %s from your house.", weapname);
1446 SendClientMessage(playerid, 0xFFFFFFFF, string);
1447 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM houseguns WHERE HouseID=%d AND WeaponID=%d", id, weaponid);
1448 mysql_tquery(SQLHandle, query, "", "");
1449 }else{
1450 SendClientMessage(playerid, 0xE74C3CFF, "Can't find that weapon.");
1451 }
1452
1453 cache_delete(weapon);
1454 return 1;
1455 }
1456
1457 if(dialogid == DIALOG_FURNITURE_MENU)
1458 {
1459 if(!response) return ShowHouseMenu(playerid);
1460 new id = InHouse[playerid];
1461 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1462 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1463 if(HouseData[id][SalePrice] > 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1464
1465 if(listitem == 0)
1466 {
1467 new list[512];
1468 format(list, sizeof(list), "#\tFurniture Name\tPrice\n");
1469 for(new i; i < sizeof(HouseFurnitures); ++i)
1470 {
1471 format(list, sizeof(list), "%s%d\t%s\t$%s\n", list, i+1, HouseFurnitures[i][Name], convertNumber(HouseFurnitures[i][Price]));
1472 }
1473
1474 ShowPlayerDialog(playerid, DIALOG_FURNITURE_BUY, DIALOG_STYLE_TABLIST_HEADERS, "Buy Furniture", list, "Buy", "Back");
1475 }
1476
1477 if(listitem == 1)
1478 {
1479 SelectMode[playerid] = SELECT_MODE_EDIT;
1480 SelectObject(playerid);
1481 SendClientMessage(playerid, 0xFFFFFFFF, "Click on the furniture you want to edit.");
1482 }
1483
1484 if(listitem == 2)
1485 {
1486 SelectMode[playerid] = SELECT_MODE_SELL;
1487 SelectObject(playerid);
1488 SendClientMessage(playerid, 0xFFFFFFFF, "Click on the furniture you want to sell.");
1489 }
1490
1491 if(listitem == 3)
1492 {
1493 new money, sold, data[e_furniture], query[64];
1494 for(new i; i < Streamer_GetUpperBound(STREAMER_TYPE_OBJECT); ++i)
1495 {
1496 if(!IsValidDynamicObject(i)) continue;
1497 Streamer_GetArrayData(STREAMER_TYPE_OBJECT, i, E_STREAMER_EXTRA_ID, data);
1498 if(data[SQLID] > 0 && data[HouseID] == id)
1499 {
1500 sold++;
1501 money += HouseFurnitures[ data[ArrayID] ][Price];
1502 DestroyDynamicObject(i);
1503 }
1504 }
1505
1506 new string[64];
1507 format(string, sizeof(string), "Sold %d furnitures for $%s.", sold, convertNumber(money));
1508 SendClientMessage(playerid, -1, string);
1509 GivePlayerMoney(playerid, money);
1510
1511 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housefurnitures WHERE HouseID=%d", id);
1512 mysql_tquery(SQLHandle, query, "", "");
1513 }
1514
1515 return 1;
1516 }
1517
1518 if(dialogid == DIALOG_FURNITURE_BUY)
1519 {
1520 if(!response) return ShowHouseMenu(playerid);
1521 new id = InHouse[playerid];
1522 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1523 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1524 if(HouseData[id][SalePrice] > 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1525 if(HouseFurnitures[listitem][Price] > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't afford this furniture.");
1526 GivePlayerMoney(playerid, -HouseFurnitures[listitem][Price]);
1527 new Float: x, Float: y, Float: z;
1528 GetPlayerPos(playerid, x, y, z);
1529 GetXYInFrontOfPlayer(playerid, x, y, 3.0);
1530 new objectid = CreateDynamicObject(HouseFurnitures[listitem][ModelID], x, y, z, 0.0, 0.0, 0.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)), query[256];
1531 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));
1532 new Cache: add = mysql_query(SQLHandle, query), data[e_furniture];
1533 data[SQLID] = cache_insert_id();
1534 data[HouseID] = id;
1535 data[ArrayID] = listitem;
1536 data[furnitureX] = x;
1537 data[furnitureY] = y;
1538 data[furnitureZ] = z;
1539 data[furnitureRX] = 0.0;
1540 data[furnitureRY] = 0.0;
1541 data[furnitureRZ] = 0.0;
1542 cache_delete(add);
1543 Streamer_SetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
1544
1545 EditingFurniture[playerid] = true;
1546 EditDynamicObject(playerid, objectid);
1547 return 1;
1548 }
1549
1550 if(dialogid == DIALOG_FURNITURE_SELL)
1551 {
1552 if(!response) return 1;
1553 new id = InHouse[playerid];
1554 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1555 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1556 if(HouseData[id][SalePrice] > 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this feature while the house is for sale.");
1557 new objectid = GetPVarInt(playerid, "SelectedFurniture"), query[64], data[e_furniture];
1558 Streamer_GetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
1559 GivePlayerMoney(playerid, HouseFurnitures[ data[ArrayID] ][Price]);
1560 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housefurnitures WHERE ID=%d", data[SQLID]);
1561 mysql_tquery(SQLHandle, query, "", "");
1562 DestroyDynamicObject(objectid);
1563 DeletePVar(playerid, "SelectedFurniture");
1564 return 1;
1565 }
1566
1567 if(dialogid == DIALOG_VISITORS_MENU)
1568 {
1569 if(!response) return ShowHouseMenu(playerid);
1570 new id = InHouse[playerid];
1571 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1572 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1573 if(listitem == 0)
1574 {
1575 new query[200], Cache: visitors;
1576 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);
1577 visitors = mysql_query(SQLHandle, query);
1578 new rows = cache_num_rows();
1579 if(rows) {
1580 new list[1024], visitor_name[MAX_PLAYER_NAME], visit_date[20];
1581 format(list, sizeof(list), "Visitor Name\tDate\n");
1582 for(new i; i < rows; ++i)
1583 {
1584 cache_get_field_content(i, "Visitor", visitor_name);
1585 cache_get_field_content(i, "VisitDate", visit_date);
1586 format(list, sizeof(list), "%s%s\t%s\n", list, visitor_name, visit_date);
1587 }
1588
1589 ShowPlayerDialog(playerid, DIALOG_VISITORS, DIALOG_STYLE_TABLIST_HEADERS, "House Visitors (Page 1)", list, "Next", "Previous");
1590 }else{
1591 SendClientMessage(playerid, 0xE74C3CFF, "You didn't had any visitors.");
1592 }
1593
1594 cache_delete(visitors);
1595 }
1596
1597 if(listitem == 1)
1598 {
1599 new query[64];
1600 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housevisitors WHERE HouseID=%d", id);
1601 mysql_tquery(SQLHandle, query, "", "");
1602 ShowHouseMenu(playerid);
1603 }
1604
1605 return 1;
1606 }
1607
1608 if(dialogid == DIALOG_VISITORS)
1609 {
1610 if(!response) {
1611 ListPage[playerid]--;
1612 if(ListPage[playerid] < 0)
1613 {
1614 ListPage[playerid] = 0;
1615 ShowHouseMenu(playerid);
1616 return 1;
1617 }
1618 }else{
1619 ListPage[playerid]++;
1620 }
1621
1622 new id = InHouse[playerid];
1623 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1624 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1625 new query[200], Cache: visitors;
1626 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);
1627 visitors = mysql_query(SQLHandle, query);
1628 new rows = cache_num_rows();
1629 if(rows) {
1630 new list[1024], visitor_name[MAX_PLAYER_NAME], visit_date[20];
1631 format(list, sizeof(list), "Visitor Name\tDate\n");
1632 for(new i; i < rows; ++i)
1633 {
1634 cache_get_field_content(i, "Visitor", visitor_name);
1635 cache_get_field_content(i, "VisitDate", visit_date);
1636 format(list, sizeof(list), "%s%s\t%s\n", list, visitor_name, visit_date);
1637 }
1638
1639 new title[32];
1640 format(title, sizeof(title), "House Visitors (Page %d)", ListPage[playerid]+1);
1641 ShowPlayerDialog(playerid, DIALOG_VISITORS, DIALOG_STYLE_TABLIST_HEADERS, title, list, "Next", "Previous");
1642 }else{
1643 SendClientMessage(playerid, 0xE74C3CFF, "Can't find any more visitors.");
1644 ListPage[playerid] = 0;
1645 ShowHouseMenu(playerid);
1646 }
1647
1648 cache_delete(visitors);
1649 return 1;
1650 }
1651
1652 if(dialogid == DIALOG_KEYS_MENU)
1653 {
1654 if(!response) return ShowHouseMenu(playerid);
1655 new id = InHouse[playerid];
1656 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1657 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1658 if(listitem == 0)
1659 {
1660 new query[200], Cache: keyowners;
1661 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);
1662 keyowners = mysql_query(SQLHandle, query);
1663 new rows = cache_num_rows();
1664 if(rows) {
1665 new list[1024], key_name[MAX_PLAYER_NAME], key_date[20];
1666 format(list, sizeof(list), "Key Owner\tKey Given On\n");
1667 for(new i; i < rows; ++i)
1668 {
1669 cache_get_field_content(i, "Player", key_name);
1670 cache_get_field_content(i, "KeyDate", key_date);
1671 format(list, sizeof(list), "%s%s\t%s\n", list, key_name, key_date);
1672 }
1673
1674 ShowPlayerDialog(playerid, DIALOG_KEYS, DIALOG_STYLE_TABLIST_HEADERS, "Key Owners (Page 1)", list, "Next", "Previous");
1675 }else{
1676 SendClientMessage(playerid, 0xE74C3CFF, "Can't find any key owners.");
1677 }
1678
1679 cache_delete(keyowners);
1680 }
1681
1682 if(listitem == 1)
1683 {
1684 foreach(new i : Player)
1685 {
1686 if(Iter_Contains(HouseKeys[i], id)) Iter_Remove(HouseKeys[i], id);
1687 }
1688
1689 new query[64];
1690 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housekeys WHERE HouseID=%d", id);
1691 mysql_tquery(SQLHandle, query, "", "");
1692 ShowHouseMenu(playerid);
1693 }
1694
1695 return 1;
1696 }
1697
1698 if(dialogid == DIALOG_KEYS)
1699 {
1700 if(!response) {
1701 ListPage[playerid]--;
1702 if(ListPage[playerid] < 0)
1703 {
1704 ListPage[playerid] = 0;
1705 ShowHouseMenu(playerid);
1706 return 1;
1707 }
1708 }else{
1709 ListPage[playerid]++;
1710 }
1711
1712 new id = InHouse[playerid];
1713 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1714 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1715 new query[200], Cache: keyowners;
1716 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);
1717 keyowners = mysql_query(SQLHandle, query);
1718 new rows = cache_num_rows();
1719 if(rows) {
1720 new list[1024], key_name[MAX_PLAYER_NAME], key_date[20];
1721 format(list, sizeof(list), "Key Owner\tKey Given On\n");
1722 for(new i; i < rows; ++i)
1723 {
1724 cache_get_field_content(i, "Player", key_name);
1725 cache_get_field_content(i, "KeyDate", key_date);
1726 format(list, sizeof(list), "%s%s\t%s\n", list, key_name, key_date);
1727 }
1728
1729 new title[32];
1730 format(title, sizeof(title), "Key Owners (Page %d)", ListPage[playerid]+1);
1731 ShowPlayerDialog(playerid, DIALOG_KEYS, DIALOG_STYLE_TABLIST_HEADERS, title, list, "Next", "Previous");
1732 }else{
1733 ListPage[playerid] = 0;
1734 ShowHouseMenu(playerid);
1735 SendClientMessage(playerid, 0xE74C3CFF, "Can't find any more key owners.");
1736 }
1737
1738 cache_delete(keyowners);
1739 return 1;
1740 }
1741
1742 if(dialogid == DIALOG_SAFE_HISTORY)
1743 {
1744 if(!response) {
1745 ListPage[playerid]--;
1746 if(ListPage[playerid] < 0)
1747 {
1748 ListPage[playerid] = 0;
1749 ShowHouseMenu(playerid);
1750 return 1;
1751 }
1752 }else{
1753 ListPage[playerid]++;
1754 }
1755
1756 new id = InHouse[playerid];
1757 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1758 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1759 new query[200], Cache: safelog;
1760 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);
1761 safelog = mysql_query(SQLHandle, query);
1762 new rows = cache_num_rows();
1763 if(rows) {
1764 new list[1024], date[20];
1765 format(list, sizeof(list), "Action\tDate\n");
1766 for(new i; i < rows; ++i)
1767 {
1768 cache_get_field_content(i, "TransactionDate", date);
1769 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);
1770 }
1771
1772 new title[32];
1773 format(title, sizeof(title), "Safe History (Page %d)", ListPage[playerid]+1);
1774 ShowPlayerDialog(playerid, DIALOG_SAFE_HISTORY, DIALOG_STYLE_TABLIST_HEADERS, title, list, "Next", "Previous");
1775 }else{
1776 SendClientMessage(playerid, 0xE74C3CFF, "Can't find any more safe history.");
1777 }
1778
1779 cache_delete(safelog);
1780 return 1;
1781 }
1782
1783 if(dialogid == DIALOG_MY_KEYS)
1784 {
1785 if(!response) {
1786 ListPage[playerid]--;
1787 if(ListPage[playerid] < 0)
1788 {
1789 ListPage[playerid] = 0;
1790 return 1;
1791 }
1792 }else{
1793 ListPage[playerid]++;
1794 }
1795
1796 new query[200], Cache: mykeys;
1797 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);
1798 mykeys = mysql_query(SQLHandle, query);
1799
1800 new rows = cache_num_rows();
1801 if(rows) {
1802 new list[1024], id, key_date[20];
1803 format(list, sizeof(list), "House Info\tKey Given On\n");
1804 for(new i; i < rows; ++i)
1805 {
1806 id = cache_get_field_content_int(i, "HouseID");
1807 cache_get_field_content(i, "KeyDate", key_date);
1808 format(list, sizeof(list), "%s%s's %s\t%s\n", list, HouseData[id][Owner], HouseData[id][Name], key_date);
1809 }
1810
1811 new title[32];
1812 format(title, sizeof(title), "My Keys (Page %d)", ListPage[playerid]+1);
1813 ShowPlayerDialog(playerid, DIALOG_MY_KEYS, DIALOG_STYLE_TABLIST_HEADERS, title, list, "Next", "Previous");
1814 }else{
1815 ListPage[playerid] = 0;
1816 SendClientMessage(playerid, 0xE74C3CFF, "Can't find any more keys.");
1817 }
1818
1819 cache_delete(mykeys);
1820 return 1;
1821 }
1822
1823 if(dialogid == DIALOG_BUY_HOUSE_FROM_OWNER)
1824 {
1825 if(!response) return 1;
1826 new id = GetPVarInt(playerid, "PickupHouseID");
1827 if(!IsPlayerInRangeOfPoint(playerid, 2.0, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ])) return SendClientMessage(playerid, 0xE74C3CFF, "You're not near any house.");
1828 #if LIMIT_PER_PLAYER > 0
1829 if(OwnedHouses(playerid) + 1 > LIMIT_PER_PLAYER) return SendClientMessage(playerid, 0xE74C3CFF, "You can't buy any more houses.");
1830 #endif
1831 if(HouseData[id][SalePrice] > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't afford this house.");
1832 if(HouseData[id][SalePrice] < 1) return SendClientMessage(playerid, 0xE74C3CFF, "Someone already owns this house.");
1833 new old_owner[MAX_PLAYER_NAME], price = HouseData[id][SalePrice], owner_id = INVALID_PLAYER_ID;
1834 format(old_owner, MAX_PLAYER_NAME, "%s", HouseData[id][Owner]);
1835
1836 foreach(new i : Player)
1837 {
1838 if(!strcmp(HouseData[id][Owner], Player_GetName(i)))
1839 {
1840 owner_id = i;
1841 break;
1842 }
1843 }
1844
1845 GivePlayerMoney(playerid, -HouseData[id][SalePrice]);
1846 GetPlayerName(playerid, HouseData[id][Owner], MAX_PLAYER_NAME);
1847 HouseData[id][LastEntered] = gettime();
1848 HouseData[id][SalePrice] = 0;
1849 HouseData[id][Save] = true;
1850
1851 UpdateHouseLabel(id);
1852 Streamer_SetIntData(STREAMER_TYPE_PICKUP, HouseData[id][HousePickup], E_STREAMER_MODEL_ID, 19522);
1853 Streamer_SetIntData(STREAMER_TYPE_MAP_ICON, HouseData[id][HouseIcon], E_STREAMER_TYPE, 32);
1854 SendToHouse(playerid, id);
1855
1856 foreach(new i : Player)
1857 {
1858 if(i == playerid) continue;
1859 if(InHouse[i] == id)
1860 {
1861 SetPVarInt(i, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
1862 SetPlayerVirtualWorld(i, 0);
1863 SetPlayerInterior(i, 0);
1864 SetPlayerPos(i, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]);
1865 InHouse[i] = INVALID_HOUSE_ID;
1866 }
1867
1868 if(Iter_Contains(HouseKeys[i], id)) Iter_Remove(HouseKeys[i], id);
1869 }
1870
1871 new query[128];
1872 if(IsPlayerConnected(owner_id)) {
1873 GivePlayerMoney(owner_id, price);
1874
1875 new string[128];
1876 format(string, sizeof(string), "%s(%d) has bought your house for $%s.", HouseData[id][Owner], playerid, convertNumber(price));
1877 SendClientMessage(owner_id, -1, string);
1878 }else{
1879 mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO housesales SET OldOwner='%e', NewOwner='%e', Price=%d", old_owner, HouseData[id][Owner], price);
1880 mysql_tquery(SQLHandle, query, "", "");
1881 }
1882
1883 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housevisitors WHERE HouseID=%d", id);
1884 mysql_tquery(SQLHandle, query, "", "");
1885
1886 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housekeys WHERE HouseID=%d", id);
1887 mysql_tquery(SQLHandle, query, "", "");
1888
1889 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housesafelogs WHERE HouseID=%d", id);
1890 mysql_tquery(SQLHandle, query, "", "");
1891 return 1;
1892 }
1893
1894 if(dialogid == DIALOG_SELL_HOUSE)
1895 {
1896 if(!response) return ShowHouseMenu(playerid);
1897 new id = InHouse[playerid];
1898 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1899 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1900 if(listitem == 0)
1901 {
1902 new money = floatround(HouseData[id][Price] * 0.85) + HouseData[id][SafeMoney];
1903 GivePlayerMoney(playerid, money);
1904 ResetHouse(id);
1905 }
1906
1907 if(listitem == 1)
1908 {
1909 if(HouseData[id][SalePrice] > 0) {
1910 HouseData[id][SalePrice] = 0;
1911 HouseData[id][Save] = true;
1912
1913 UpdateHouseLabel(id);
1914 Streamer_SetIntData(STREAMER_TYPE_PICKUP, HouseData[id][HousePickup], E_STREAMER_MODEL_ID, 19522);
1915 Streamer_SetIntData(STREAMER_TYPE_MAP_ICON, HouseData[id][HouseIcon], E_STREAMER_TYPE, 32);
1916 SendClientMessage(playerid, -1, "Your house is no longer for sale.");
1917 }else{
1918 if(HouseData[id][SafeMoney] > 0) return SendClientMessage(playerid, 0xE74C3CFF, "You can't put your house for sale if there's money in the safe.");
1919 ShowPlayerDialog(playerid, DIALOG_SELLING_PRICE, DIALOG_STYLE_INPUT, "Sell House", "How much do you want for your house?", "Put For Sale", "Cancel");
1920 }
1921 }
1922
1923 return 1;
1924 }
1925
1926 if(dialogid == DIALOG_SELLING_PRICE)
1927 {
1928 if(!response) return ShowHouseMenu(playerid);
1929 new id = InHouse[playerid];
1930 if(id == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
1931 if(strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
1932 new amount = strval(inputtext);
1933 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");
1934 HouseData[id][SalePrice] = amount;
1935 HouseData[id][Save] = true;
1936
1937 UpdateHouseLabel(id);
1938 Streamer_SetIntData(STREAMER_TYPE_PICKUP, HouseData[id][HousePickup], E_STREAMER_MODEL_ID, 1273);
1939 Streamer_SetIntData(STREAMER_TYPE_MAP_ICON, HouseData[id][HouseIcon], E_STREAMER_TYPE, 31);
1940
1941 new string[128];
1942 format(string, sizeof(string), "You put your house for sale for $%s.", convertNumber(amount));
1943 SendClientMessage(playerid, -1, string);
1944 return 1;
1945 }
1946
1947 return 0;
1948}
1949
1950public OnPlayerSelectDynamicObject(playerid, objectid, modelid, Float: x, Float: y, Float: z)
1951{
1952 switch(SelectMode[playerid])
1953 {
1954 case SELECT_MODE_EDIT:
1955 {
1956 EditingFurniture[playerid] = true;
1957 EditDynamicObject(playerid, objectid);
1958 }
1959
1960 case SELECT_MODE_SELL:
1961 {
1962 CancelEdit(playerid);
1963
1964 new data[e_furniture], string[128];
1965 SetPVarInt(playerid, "SelectedFurniture", objectid);
1966 Streamer_GetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
1967 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]));
1968 ShowPlayerDialog(playerid, DIALOG_FURNITURE_SELL, DIALOG_STYLE_MSGBOX, "Confirm Sale", string, "Sell", "Close");
1969 }
1970 }
1971
1972 SelectMode[playerid] = SELECT_MODE_NONE;
1973 return 1;
1974}
1975
1976public OnPlayerEditDynamicObject(playerid, objectid, response, Float: x, Float: y, Float: z, Float: rx, Float: ry, Float: rz)
1977{
1978 if(EditingFurniture[playerid])
1979 {
1980 switch(response)
1981 {
1982 case EDIT_RESPONSE_CANCEL:
1983 {
1984 new data[e_furniture];
1985 Streamer_GetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
1986 SetDynamicObjectPos(objectid, data[furnitureX], data[furnitureY], data[furnitureZ]);
1987 SetDynamicObjectRot(objectid, data[furnitureRX], data[furnitureRY], data[furnitureRZ]);
1988
1989 EditingFurniture[playerid] = false;
1990 }
1991
1992 case EDIT_RESPONSE_FINAL:
1993 {
1994 new data[e_furniture], query[256];
1995 Streamer_GetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
1996 data[furnitureX] = x;
1997 data[furnitureY] = y;
1998 data[furnitureZ] = z;
1999 data[furnitureRX] = rx;
2000 data[furnitureRY] = ry;
2001 data[furnitureRZ] = rz;
2002 SetDynamicObjectPos(objectid, data[furnitureX], data[furnitureY], data[furnitureZ]);
2003 SetDynamicObjectRot(objectid, data[furnitureRX], data[furnitureRY], data[furnitureRZ]);
2004 Streamer_SetArrayData(STREAMER_TYPE_OBJECT, objectid, E_STREAMER_EXTRA_ID, data);
2005
2006 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]);
2007 mysql_tquery(SQLHandle, query, "", "");
2008
2009 EditingFurniture[playerid] = false;
2010 }
2011 }
2012 }
2013
2014 return 1;
2015}
2016
2017/* ============ Player Commands ============ */
2018CMD:house(playerid, params[])
2019{
2020 if(InHouse[playerid] == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
2021 ShowHouseMenu(playerid);
2022 return 1;
2023}
2024
2025CMD:myhousekeys(playerid, params[])
2026{
2027 new query[200], Cache: mykeys;
2028 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));
2029 mykeys = mysql_query(SQLHandle, query);
2030 ListPage[playerid] = 0;
2031
2032 new rows = cache_num_rows();
2033 if(rows) {
2034 new list[1024], id, key_date[20];
2035 format(list, sizeof(list), "House Info\tKey Given On\n");
2036 for(new i; i < rows; ++i)
2037 {
2038 id = cache_get_field_content_int(i, "HouseID");
2039 cache_get_field_content(i, "KeyDate", key_date);
2040 format(list, sizeof(list), "%s%s's %s\t%s\n", list, HouseData[id][Owner], HouseData[id][Name], key_date);
2041 }
2042
2043 ShowPlayerDialog(playerid, DIALOG_MY_KEYS, DIALOG_STYLE_TABLIST_HEADERS, "My Keys (Page 1)", list, "Next", "Close");
2044 }else{
2045 SendClientMessage(playerid, 0xE74C3CFF, "You don't have any keys for any houses.");
2046 }
2047
2048 cache_delete(mykeys);
2049 return 1;
2050}
2051
2052CMD:givehousekeys(playerid, params[])
2053{
2054 if(InHouse[playerid] == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
2055 new id, houseid = InHouse[playerid];
2056 if(strcmp(HouseData[houseid][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
2057 if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /givehousekeys [player id]");
2058 if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xE74C3CFF, "Invalid player ID.");
2059 if(id == playerid) return SendClientMessage(playerid, 0xE74C3CFF, "You're the owner, you don't need keys.");
2060 if(Iter_Contains(HouseKeys[id], houseid)) return SendClientMessage(playerid, 0xE74C3CFF, "That player has keys for this house.");
2061 Iter_Add(HouseKeys[id], houseid);
2062
2063 new query[128];
2064 mysql_format(SQLHandle, query, sizeof(query), "INSERT INTO housekeys SET HouseID=%d, Player='%e', Date=UNIX_TIMESTAMP()", houseid, Player_GetName(id));
2065 mysql_tquery(SQLHandle, query, "", "");
2066
2067 format(query, sizeof(query), "You've given keys to %s for this house.", Player_GetName(id));
2068 SendClientMessage(playerid, -1, query);
2069 format(query, sizeof(query), "Now you have keys for %s's house, %s.", HouseData[houseid][Owner], HouseData[houseid][Name]);
2070 SendClientMessage(id, -1, query);
2071 return 1;
2072}
2073
2074CMD:takehousekeys(playerid, params[])
2075{
2076 if(InHouse[playerid] == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
2077 new id, houseid = InHouse[playerid];
2078 if(strcmp(HouseData[houseid][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
2079 if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /takehousekeys [player id]");
2080 if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xE74C3CFF, "Invalid player ID.");
2081 if(id == playerid) return SendClientMessage(playerid, 0xE74C3CFF, "You're the owner, you can't take your keys.");
2082 if(!Iter_Contains(HouseKeys[id], houseid)) return SendClientMessage(playerid, 0xE74C3CFF, "That player doesn't have keys for this house.");
2083 Iter_Remove(HouseKeys[id], houseid);
2084
2085 new query[128];
2086 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM housekeys WHERE HouseID=%d AND Player='%e'", houseid, Player_GetName(id));
2087 mysql_tquery(SQLHandle, query, "", "");
2088
2089 format(query, sizeof(query), "You've taken keys from %s for this house.", Player_GetName(id));
2090 SendClientMessage(playerid, -1, query);
2091 format(query, sizeof(query), "House owner %s has taken your keys for their house %s.", HouseData[houseid][Owner], HouseData[houseid][Name]);
2092 SendClientMessage(id, -1, query);
2093 return 1;
2094}
2095
2096CMD:kickfromhouse(playerid, params[])
2097{
2098 if(InHouse[playerid] == INVALID_HOUSE_ID) return SendClientMessage(playerid, 0xE74C3CFF, "You're not in a house.");
2099 new id, houseid = InHouse[playerid];
2100 if(strcmp(HouseData[houseid][Owner], Player_GetName(playerid))) return SendClientMessage(playerid, 0xE74C3CFF, "You're not the owner of this house.");
2101 if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /kickfromhouse [player id]");
2102 if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xE74C3CFF, "Invalid player ID.");
2103 if(id == playerid) return SendClientMessage(playerid, 0xE74C3CFF, "You can't kick yourself from your house.");
2104 if(InHouse[id] != houseid) return SendClientMessage(playerid, 0xE74C3CFF, "That player isn't in your house.");
2105 SendClientMessage(playerid, -1, "Player kicked.");
2106 SendClientMessage(id, -1, "You got kicked by the house owner.");
2107 SetPVarInt(id, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
2108 SetPlayerVirtualWorld(id, 0);
2109 SetPlayerInterior(id, 0);
2110 SetPlayerPos(id, HouseData[houseid][houseX], HouseData[houseid][houseY], HouseData[houseid][houseZ]);
2111 InHouse[id] = INVALID_HOUSE_ID;
2112 return 1;
2113}
2114
2115/* ============ Admin Commands ============ */
2116CMD:createhouse(playerid, params[])
2117{
2118 if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this command.");
2119 new interior, price;
2120 if(sscanf(params, "ii", price, interior)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /createhouse [price] [interior id]");
2121 if(!(0 <= interior <= sizeof(HouseInteriors)-1)) return SendClientMessage(playerid, 0xE74C3CFF, "Interior ID you entered does not exist.");
2122 new id = Iter_Free(Houses);
2123 if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "You can't create more houses.");
2124 SetPVarInt(playerid, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
2125 format(HouseData[id][Name], MAX_HOUSE_NAME, "House For Sale");
2126 format(HouseData[id][Owner], MAX_PLAYER_NAME, "-");
2127 format(HouseData[id][Password], MAX_HOUSE_PASSWORD, "-");
2128 GetPlayerPos(playerid, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]);
2129 HouseData[id][Price] = price;
2130 HouseData[id][Interior] = interior;
2131 HouseData[id][LockMode] = LOCK_MODE_NOLOCK;
2132 HouseData[id][SalePrice] = HouseData[id][SafeMoney] = HouseData[id][LastEntered] = 0;
2133 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]));
2134 HouseData[id][Save] = true;
2135
2136 new label[200];
2137 format(label, sizeof(label), "{2ECC71}House For Sale (ID: %d)\n{FFFFFF}%s\n{F1C40F}Price: {2ECC71}$%s", id, HouseInteriors[interior][IntName], convertNumber(price));
2138 HouseData[id][HouseLabel] = CreateDynamic3DTextLabel(label, 0xFFFFFFFF, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]+0.35, 15.0, .testlos = 1);
2139 HouseData[id][HousePickup] = CreateDynamicPickup(1273, 1, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]);
2140 HouseData[id][HouseIcon] = CreateDynamicMapIcon(HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ], 31, 0);
2141
2142 new query[256];
2143 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);
2144 mysql_tquery(SQLHandle, query, "", "");
2145 Iter_Add(Houses, id);
2146 return 1;
2147}
2148
2149CMD:gotohouse(playerid, params[])
2150{
2151 if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this command.");
2152 new id;
2153 if(sscanf(params, "i", id)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /gotohouse [house id]");
2154 if(!Iter_Contains(Houses, id)) return SendClientMessage(playerid, 0xE74C3CFF, "House ID you entered does not exist.");
2155 SetPVarInt(playerid, "HousePickupCooldown", gettime() + HOUSE_COOLDOWN);
2156 SetPlayerPos(playerid, HouseData[id][houseX], HouseData[id][houseY], HouseData[id][houseZ]);
2157 SetPlayerInterior(playerid, 0);
2158 SetPlayerVirtualWorld(playerid, 0);
2159 return 1;
2160}
2161
2162CMD:hsetinterior(playerid, params[])
2163{
2164 if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this command.");
2165 new id, interior;
2166 if(sscanf(params, "ii", id, interior)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /hsetinterior [house id] [interior id]");
2167 if(!Iter_Contains(Houses, id)) return SendClientMessage(playerid, 0xE74C3CFF, "House ID you entered does not exist.");
2168 if(!(0 <= interior <= sizeof(HouseInteriors)-1)) return SendClientMessage(playerid, 0xE74C3CFF, "Interior ID you entered does not exist.");
2169 HouseData[id][Interior] = interior;
2170
2171 new query[64];
2172 mysql_format(SQLHandle, query, sizeof(query), "UPDATE houses SET HouseInterior=%d WHERE ID=%d", interior, id);
2173 mysql_tquery(SQLHandle, query, "", "");
2174
2175 UpdateHouseLabel(id);
2176 SendClientMessage(playerid, -1, "Interior updated.");
2177 return 1;
2178}
2179
2180CMD:hsetprice(playerid, params[])
2181{
2182 if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this command.");
2183 new id, price;
2184 if(sscanf(params, "ii", id, price)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /hsetprice [house id] [price]");
2185 if(!Iter_Contains(Houses, id)) return SendClientMessage(playerid, 0xE74C3CFF, "House ID you entered does not exist.");
2186 HouseData[id][Price] = price;
2187
2188 new query[64];
2189 mysql_format(SQLHandle, query, sizeof(query), "UPDATE houses SET HousePrice=%d WHERE ID=%d", price, id);
2190 mysql_tquery(SQLHandle, query, "", "");
2191
2192 UpdateHouseLabel(id);
2193 SendClientMessage(playerid, -1, "Price updated.");
2194 return 1;
2195}
2196
2197CMD:resethouse(playerid, params[])
2198{
2199 if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this command.");
2200 new id;
2201 if(sscanf(params, "i", id)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /resethouse [house id]");
2202 if(!Iter_Contains(Houses, id)) return SendClientMessage(playerid, 0xE74C3CFF, "House ID you entered does not exist.");
2203 ResetHouse(id);
2204 SendClientMessage(playerid, -1, "House reset.");
2205 return 1;
2206}
2207
2208CMD:deletehouse(playerid, params[])
2209{
2210 if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "You can't use this command.");
2211 new id;
2212 if(sscanf(params, "i", id)) return SendClientMessage(playerid, 0xE74C3CFF, "USAGE: /deletehouse [house id]");
2213 if(!Iter_Contains(Houses, id)) return SendClientMessage(playerid, 0xE74C3CFF, "House ID you entered does not exist.");
2214 ResetHouse(id);
2215 DestroyDynamic3DTextLabel(HouseData[id][HouseLabel]);
2216 DestroyDynamicPickup(HouseData[id][HousePickup]);
2217 DestroyDynamicMapIcon(HouseData[id][HouseIcon]);
2218 Iter_Remove(Houses, id);
2219 HouseData[id][HouseLabel] = Text3D: INVALID_3DTEXT_ID;
2220 HouseData[id][HousePickup] = HouseData[id][HouseIcon] = -1;
2221 HouseData[id][Save] = false;
2222
2223 new query[64];
2224 mysql_format(SQLHandle, query, sizeof(query), "DELETE FROM houses WHERE ID=%d", id);
2225 mysql_tquery(SQLHandle, query, "", "");
2226 SendClientMessage(playerid, -1, "House deleted.");
2227 return 1;
2228}