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