Advertisement
Guest User

Untitled

a guest
May 1st, 2016
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 57.86 KB | None | 0 0
  1. // IMPORTANT NOTICE; HouseInfo[houseid][hModified] = 1; enables saving to that house
  2. // set hModified to 1, only when the house is modified and requires saving.
  3. // this is for improved performance.
  4. //============================[ Loading/Saving ]================================
  5. stock GetHousePool()
  6. {
  7. new pool, Cache:housesPool;
  8. housesPool = mysql_query(sqlGameConnection, "SELECT HouseID FROM houses ORDER BY HouseID DESC LIMIT 1;");
  9. pool = cache_get_field_content_int(0, "HouseID");
  10. cache_delete(housesPool);
  11. return pool;
  12. }
  13. stock LoadOwnedHouses()
  14. {
  15. mysql_tquery(sqlGameConnection, "SELECT houses.*, players.Name FROM houses INNER JOIN players ON houses.OwnerID = players.ID", "OnLoadOwnedHouses", "");
  16. printf("mysql_tquery OnLoadOwnedHouses");
  17. return 1;
  18. }
  19.  
  20. new
  21. ownedHousesPool = 0;
  22. forward OnLoadOwnedHouses();
  23. public OnLoadOwnedHouses()
  24. {
  25. new
  26. value[100], houseCount = 0;
  27.  
  28. for(new id = 1; id < cache_num_rows(); id++)
  29. {
  30. if(id == MAX_HOUSES)
  31. return print("[HouseInfo] WARNING: maximum houses reached.");
  32. //important variables/general variables
  33. if(!(cache_get_field_content_int(id, "Created"))) continue;
  34. HouseInfo[id][hSQLID] = cache_get_field_content_int(id, "HouseID");
  35. HouseInfo[id][hOwnerID] = cache_get_field_content_int(id, "OwnerID");
  36. cache_get_field_content(id, "Name", value);
  37. format(HouseInfo[id][hOwner], MAX_PLAYER_NAME + 1, "%s", value);
  38.  
  39. HouseInfo[id][hOwned] = cache_get_field_content_int(id, "Owned");
  40. HouseInfo[id][hValue] = cache_get_field_content_int(id, "Value");
  41.  
  42. cache_get_field_content(id, "Tag", value);
  43. strmid(HouseInfo[id][hTag], value, 0, strlen(value), 255);
  44. HouseInfo[id][hLevel] = cache_get_field_content_int(id, "Level");
  45.  
  46. //icon location variables
  47. cache_get_field_content(id, "OutsideX", value);
  48. HouseInfo[id][hOutsideX] = floatstr(value);
  49. cache_get_field_content(id, "OutsideY", value);
  50. HouseInfo[id][hOutsideY] = floatstr(value);
  51. cache_get_field_content(id, "OutsideZ", value);
  52. HouseInfo[id][hOutsideZ] = floatstr(value);
  53. cache_get_field_content(id, "OutsideA", value);
  54. HouseInfo[id][hOutsideA] = floatstr(value);
  55. cache_get_field_content(id, "InsideX", value);
  56. HouseInfo[id][hInsideX] = floatstr(value);
  57. cache_get_field_content(id, "InsideY", value);
  58. HouseInfo[id][hInsideY] = floatstr(value);
  59. cache_get_field_content(id, "InsideZ", value);
  60. HouseInfo[id][hInsideZ] = floatstr(value);
  61. cache_get_field_content(id, "InsideA", value);
  62. HouseInfo[id][hInsideA] = floatstr(value);
  63. HouseInfo[id][hInterior] = cache_get_field_content_int(id, "Interior");
  64.  
  65. //upgrades/storage
  66. HouseInfo[id][hLocked] = cache_get_field_content_int(id, "Locked");
  67. HouseInfo[id][hAlarm] = cache_get_field_content_int(id, "Alarm");
  68. HouseInfo[id][hAlarmStatus] = cache_get_field_content_int(id, "AlarmStatus");
  69. HouseInfo[id][hCash] = cache_get_field_content_int(id, "Cash");
  70. HouseInfo[id][hMaterials] = cache_get_field_content_int(id, "Materials");
  71. HouseInfo[id][hPot] = cache_get_field_content_int(id, "Pot");
  72. HouseInfo[id][hCrack] = cache_get_field_content_int(id, "Crack");
  73. HouseInfo[id][hGun1] = cache_get_field_content_int(id, "Gun1");
  74. HouseInfo[id][hGun2] = cache_get_field_content_int(id, "Gun2");
  75. HouseInfo[id][hGun3] = cache_get_field_content_int(id, "Gun3");
  76. HouseInfo[id][hGun4] = cache_get_field_content_int(id, "Gun4");
  77. HouseInfo[id][hModified] = 0;
  78.  
  79. HouseInfo[id][hOutsidePickup] = CreateDynamicPickup(1273, 1, HouseInfo[id][hOutsideX], HouseInfo[id][hOutsideY], HouseInfo[id][hOutsideZ]);
  80.  
  81. HouseInfoText3D[id] = CreateDynamic3DTextLabel("", COLOR_HOUSETEXT, HouseInfo[id][hOutsideX], HouseInfo[id][hOutsideY], HouseInfo[id][hOutsideZ] +0.88, 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 100);
  82. SetHouseTag(id);
  83. HouseInfo[id][hCreated] = 1;
  84. houseCount++;
  85. }
  86. ownedHousesPool = houseCount;
  87. lastSQLhouseID = GetHousePool();
  88. printf("[HouseInfo] %d owned houses were loaded.", ownedHousesPool);
  89. mysql_tquery(sqlGameConnection, "SELECT * FROM houses WHERE OwnerID = 0", "OnLoadUnownedHouses", "");
  90. printf("mysql_tquery OnLoadUnownedHouses");
  91. return 1;
  92. }
  93.  
  94. forward OnLoadUnownedHouses();
  95. public OnLoadUnownedHouses()
  96. {
  97. new
  98. value[100], houseCount = 0;
  99.  
  100. for(new id = ownedHousesPool + 1; id < cache_num_rows() + ownedHousesPool; id++) //starts at 1
  101. {
  102. if(id == MAX_HOUSES)
  103. return print("[HouseInfo] WARNING: maximum houses reached.");
  104. //important variables/general variables
  105. if(!(cache_get_field_content_int(id, "Created"))) continue;
  106. HouseInfo[id][hSQLID] = cache_get_field_content_int(id, "HouseID");
  107. HouseInfo[id][hOwnerID] = 0;
  108.  
  109. HouseInfo[id][hOwned] = 0;
  110. HouseInfo[id][hValue] = cache_get_field_content_int(id, "Value");
  111.  
  112. cache_get_field_content(id, "Tag", value);
  113. strmid(HouseInfo[id][hTag], value, 0, strlen(value), 255);
  114. HouseInfo[id][hLevel] = cache_get_field_content_int(id, "Level");
  115.  
  116. //icon location variables
  117. cache_get_field_content(id, "OutsideX", value);
  118. HouseInfo[id][hOutsideX] = floatstr(value);
  119. cache_get_field_content(id, "OutsideY", value);
  120. HouseInfo[id][hOutsideY] = floatstr(value);
  121. cache_get_field_content(id, "OutsideZ", value);
  122. HouseInfo[id][hOutsideZ] = floatstr(value);
  123. cache_get_field_content(id, "OutsideA", value);
  124. HouseInfo[id][hOutsideA] = floatstr(value);
  125. cache_get_field_content(id, "InsideX", value);
  126. HouseInfo[id][hInsideX] = floatstr(value);
  127. cache_get_field_content(id, "InsideY", value);
  128. HouseInfo[id][hInsideY] = floatstr(value);
  129. cache_get_field_content(id, "InsideZ", value);
  130. HouseInfo[id][hInsideZ] = floatstr(value);
  131. cache_get_field_content(id, "InsideA", value);
  132. HouseInfo[id][hInsideA] = floatstr(value);
  133. HouseInfo[id][hInterior] = cache_get_field_content_int(id, "Interior");
  134. HouseInfo[id][hModified] = 0;
  135.  
  136. HouseInfo[id][hOutsidePickup] = CreateDynamicPickup(1273, 1, HouseInfo[id][hOutsideX], HouseInfo[id][hOutsideY], HouseInfo[id][hOutsideZ]);
  137.  
  138. HouseInfoText3D[id] = CreateDynamic3DTextLabel("", COLOR_HOUSETEXT, HouseInfo[id][hOutsideX], HouseInfo[id][hOutsideY], HouseInfo[id][hOutsideZ] +0.88, 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 100);
  139. SetHouseTag(id);
  140. HouseInfo[id][hCreated] = 1;
  141. houseCount++;
  142. }
  143. printf("[HouseInfo] %d unowned houses were loaded. The last SQL ID in the table is; %d.", houseCount, lastSQLhouseID);
  144. return 1;
  145. }
  146. public SaveHouses()
  147. {
  148. new
  149. houseCount = 0;
  150. for(new id = 1; id < sizeof(HouseInfo); id++)
  151. {
  152. if(!HouseInfo[id][hCreated]) continue;
  153. if(!HouseInfo[id][hModified]) continue;
  154. new query[2000];
  155. mysql_format(sqlGameConnection, query, sizeof(query), "UPDATE `houses` SET `OwnerID` = %d, `Created` = %d, `Owned` = %d,",
  156. HouseInfo[id][hOwnerID], HouseInfo[id][hCreated], HouseInfo[id][hOwned]);
  157.  
  158. mysql_format(sqlGameConnection, query, sizeof(query), "%s `Value` = %d, `OutsideX` = %f, `OutsideY` = %f, `OutsideZ` = %f,",
  159. query, HouseInfo[id][hValue], HouseInfo[id][hOutsideX], HouseInfo[id][hOutsideY], HouseInfo[id][hOutsideZ]);
  160.  
  161. mysql_format(sqlGameConnection, query, sizeof(query), "%s `OutsideA` = %f, `InsideX` = %f, `InsideY` = %f, `InsideZ` = %f,",
  162. query, HouseInfo[id][hOutsideA], HouseInfo[id][hInsideX], HouseInfo[id][hInsideY], HouseInfo[id][hInsideZ]);
  163.  
  164. mysql_format(sqlGameConnection, query, sizeof(query), "%s `InsideA` = %f, `Interior` = %d, `Locked` = %d, `Alarm` = %d,",
  165. query, HouseInfo[id][hInsideA], HouseInfo[id][hInterior], HouseInfo[id][hLocked], HouseInfo[id][hAlarm]);
  166.  
  167. mysql_format(sqlGameConnection, query, sizeof(query), "%s `AlarmStatus` = %d, `Cash` = %d, `Materials` = %d, `Pot` = %d,",
  168. query, HouseInfo[id][hAlarmStatus], HouseInfo[id][hCash], HouseInfo[id][hMaterials], HouseInfo[id][hPot]);
  169.  
  170. mysql_format(sqlGameConnection, query, sizeof(query), "%s `Crack` = %d, `Gun1` = %d, `Gun2` = %d, `Gun3` = %d,",
  171. query, HouseInfo[id][hCrack], HouseInfo[id][hGun1], HouseInfo[id][hGun2], HouseInfo[id][hGun3]);
  172.  
  173. mysql_format(sqlGameConnection, query, sizeof(query), "%s `Gun4` = '%d', `Tag` = '%e', `Level` = %d WHERE `HouseID` = %d",
  174. query, HouseInfo[id][hGun4], HouseInfo[id][hTag], HouseInfo[id][hLevel], HouseInfo[id][hSQLID]);
  175. mysql_tquery(sqlGameConnection, query);
  176. HouseInfo[id][hModified] = 0;
  177. houseCount++;
  178. }
  179. printf("[HouseInfo] %d houses were saved.", houseCount);
  180. return 1;
  181. }
  182. //===========================[ Useful functions ]===============================
  183. stock SetHouseTag(hid)
  184. {
  185. new
  186. newhousetag[180], location[60];
  187. Get2DZone(location, MAX_ZONE_NAME, HouseInfo[hid][hOutsideX], HouseInfo[hid][hOutsideY], HouseInfo[hid][hOutsideZ]);
  188. if(HouseInfo[hid][hOwned] == 1)
  189. {
  190. format(newhousetag, sizeof(newhousetag), "{5BC435}%s{FFFFFF}\nOwner: %s\nAddress: %d %s\nPost code: %d\nType /enter to go inside.", HouseInfo[hid][hTag], HouseInfo[hid][hOwner], hid, location, HouseInfo[hid][hSQLID]);
  191. }
  192. else
  193. {
  194. format(newhousetag, sizeof(newhousetag), "{5BC435}This property is for sale!{FFFFFF}\nAddress: %d %s\nPost code: %d\nType /buyhouse to buy it for $%d", hid, location, HouseInfo[hid][hSQLID], HouseInfo[hid][hValue]);
  195. }
  196. UpdateDynamic3DTextLabelText(HouseInfoText3D[hid], COLOR_HOUSETEXT, newhousetag);
  197. return 1;
  198. }
  199. stock GetHouseOwnerIDFromSQLID(sqlid)
  200. {
  201. for(new id = 1; id < MAX_HOUSES; id++)
  202. {
  203. if(HouseInfo[id][hOwnerID] == sqlid)
  204. {
  205. print("house ID obtained.");
  206. return id;
  207. }
  208. }
  209. return 0;
  210. }
  211. stock GetHouseIDFromSQLID(sqlid)
  212. {
  213. for(new id = 0; id < MAX_HOUSES; id++)
  214. {
  215. if(HouseInfo[id][hSQLID] == sqlid)
  216. {
  217. return id;
  218. }
  219. }
  220. return 0;
  221. }
  222. stock GetHouseOwner(sqlid, playerid){
  223. new query[128];
  224. mysql_format(sqlGameConnection, query, sizeof(query), "SELECT `HouseID` FROM `houses` WHERE `OwnerID`=%d", sqlid);
  225. mysql_tquery(sqlGameConnection, query, "OnGetHouseOwner", "i", playerid);
  226. return 1;
  227. }
  228. forward OnGetHouseOwner(playerid);
  229. public OnGetHouseOwner(playerid)
  230. {
  231. new ID;
  232. if(cache_num_rows() != 0)
  233. {
  234. ID = cache_get_field_content_int(0, "HouseID");
  235. }
  236. else
  237. ID = 0;
  238.  
  239. PlayerInfo[playerid][pHouseID] = ID;
  240. }
  241. stock GetPlayerNearHouseID(playerid)
  242. {
  243. for(new id = 1; id < sizeof(HouseInfo); id++)
  244. {
  245. if(IsPlayerInRangeOfPoint(playerid, 1.0, HouseInfo[id][hOutsideX], HouseInfo[id][hOutsideY], HouseInfo[id][hOutsideZ]))
  246. {
  247. return id;
  248. }
  249. }
  250. return 0;
  251. }
  252. stock GetHouseLocation(houseid)
  253. {
  254. new location[MAX_ZONE_NAME];
  255. Get2DZone(location, MAX_ZONE_NAME, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]);
  256. return location;
  257. }
  258. stock DeleteHouse(houseid)
  259. {
  260. DestroyDynamic3DTextLabel(HouseInfoText3D[houseid]);
  261. HouseInfoText3D[houseid] = Text3D:INVALID_3DTEXT_ID;
  262. HouseInfo[houseid][hCreated] = 0;
  263. HouseInfo[houseid][hOwned] = 0;
  264. HouseInfo[houseid][hValue] = 0;
  265. HouseInfo[houseid][hOutsideX] = 0;
  266. HouseInfo[houseid][hOutsideY] = 0;
  267. HouseInfo[houseid][hOutsideZ] = 0;
  268. HouseInfo[houseid][hOutsideA] = 0;
  269. HouseInfo[houseid][hInsideX] = 0;
  270. HouseInfo[houseid][hInsideY] = 0;
  271. HouseInfo[houseid][hInsideZ] = 0;
  272. HouseInfo[houseid][hInsideA] = 0;
  273. HouseInfo[houseid][hInterior] = 0;
  274. HouseInfo[houseid][hLocked] = 0;
  275. HouseInfo[houseid][hAlarm] = 0;
  276. HouseInfo[houseid][hAlarmStatus] = 0;
  277. HouseInfo[houseid][hCash] = 0;
  278. HouseInfo[houseid][hMaterials] = 0;
  279. HouseInfo[houseid][hPot] = 0;
  280. HouseInfo[houseid][hCrack] = 0;
  281. HouseInfo[houseid][hGun1] = 0;
  282. HouseInfo[houseid][hGun2] = 0;
  283. HouseInfo[houseid][hGun3] = 0;
  284. HouseInfo[houseid][hGun4] = 0;
  285. HouseInfo[houseid][hOwnerID] = -1;
  286. strdel(HouseInfo[houseid][hTag], 0, strlen(HouseInfo[houseid][hTag]));
  287. strins(HouseInfo[houseid][hTag], "House", 0);
  288. HouseInfo[houseid][hLevel] = 0;
  289. if(HouseInfo[houseid][hOutsidePickup])
  290. {
  291. DestroyDynamicPickup(HouseInfo[houseid][hOutsidePickup]);
  292. }
  293. HouseInfo[houseid][hSQLID] = 0;
  294. return 1;
  295. }
  296. //==============================[ Admin commands ]==============================
  297.  
  298. CMD:cleanhouses(playerid, params[]) //data cleanups
  299. {
  300. if(PlayerInfo[playerid][pAdmin] < 99999)
  301. return AdmErrorMsg;
  302.  
  303. new confirm[128];
  304. if(sscanf(params, "s[128]", confirm))
  305. {
  306. if(strcmp(confirm, "confirm", true) == 0)
  307. {
  308. SendClientMessage(playerid, COLOR_LIGHTBLUE, "This action will delete all houses at coordinates 0.0, 0.0, 0.0 and houses not created.");
  309. return SendClientMessage(playerid, COLOR_GREY, "Type /cleanhouses confirm to clean up the houses table.");
  310. }
  311. }
  312. for(new id = 1; id < MAX_HOUSES; id++)
  313. {
  314. if(HouseInfo[id][hOutsideX] == 0.0 && HouseInfo[id][hOutsideY] == 0.0)
  315. {
  316. DeleteHouse(id);
  317. }
  318. }
  319. mysql_tquery(sqlGameConnection, "DELETE FROM houses WHERE OutsideX = 0.0 AND OutsideY = 0.0", "", "");
  320. mysql_tquery(sqlGameConnection, "DELETE FROM houses WHERE Created = 0", "", "");
  321. SendClientMessage(playerid, COLOR_GREY, "You have cleaned out the houses table.");
  322. return 1;
  323. }
  324. CMD:createhouse(playerid, params[])
  325. {
  326. if(PlayerInfo[playerid][pAdmin] >= 99999 || PlayerInfo[playerid][pBizMod] == 1)
  327. {
  328. new price, interiorid, houseid, Float:X, Float:Y, Float:Z, Float:A, check = 0;
  329. if(sscanf(params, "dd", price, interiorid))
  330. {
  331. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /createhouse [price] [interior id]");
  332. SendClientMessage(playerid, COLOR_GRAD2, "{00BFFF}Usage:{FFFFFF} /viewhouseint [1-22] or /gotoint");
  333. return 1;
  334. }
  335. GetPlayerPos(playerid, X, Y, Z);
  336. GetPlayerFacingAngle(playerid, A);
  337. for(new i = 1; i < sizeof(HouseInfo); i++)
  338. {
  339. if(HouseInfo[i][hCreated] == 0)
  340. {
  341. check = 1;
  342. houseid = i;
  343. break;
  344. }
  345. }
  346. if(!check) return SendClientMessage(playerid, COLOR_GRAD2, "1000/1000 houses have already been created.");
  347. lastSQLhouseID++;
  348. HouseInfo[houseid][hSQLID] = lastSQLhouseID;
  349. HouseInfo[houseid][hOutsideX] = X;
  350. HouseInfo[houseid][hOutsideY] = Y;
  351. HouseInfo[houseid][hOutsideZ] = Z;
  352. HouseInfo[houseid][hOutsideA] = A;
  353. HouseInfo[houseid][hCreated] = 1;
  354. HouseInfo[houseid][hValue] = price;
  355. strdel(HouseInfo[houseid][hTag], 0, strlen(HouseInfo[houseid][hTag]));
  356. strins(HouseInfo[houseid][hTag], "House", 0);
  357. SetHouseInterior(houseid, interiorid);
  358. if(HouseInfo[houseid][hOutsidePickup])
  359. {
  360. DestroyDynamicPickup(HouseInfo[houseid][hOutsidePickup]);
  361. }
  362. HouseInfo[houseid][hOutsidePickup] = CreateDynamicPickup(1273, 1, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]);
  363.  
  364. if(HouseInfoText3D[houseid])
  365. {
  366. DestroyDynamic3DTextLabel(HouseInfoText3D[houseid]);
  367. }
  368. HouseInfoText3D[houseid] = CreateDynamic3DTextLabel("", COLOR_HOUSETEXT, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ] +0.88, 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 100);
  369. SetHouseTag(houseid);
  370. format(str, sizeof(str), "You have created houseid %d with the price of $%d and interiorid %d", houseid, price, interiorid);
  371. SendClientMessage(playerid, COLOR_GRAD1, str);
  372.  
  373. new query[500];
  374. format(query, sizeof(query), "INSERT INTO `houses` (`OwnerID`, `Created`, `Owned`, `Value`, `OutsideX`, `OutsideY`, `OutsideZ`, `OutsideA`, `InsideX`, `InsideY`, `InsideZ`, `InsideA`, `Interior`, `Locked`, `Alarm`, `AlarmStatus`, `Cash`, `Materials`, `Pot`, `Crack`, `Gun1`, `Gun2`, `Gun3`, `Gun4`, `Tag`, `Level`)");
  375. format(query, sizeof(query), "%s VALUES(-1, 1, 0, %d, %f, %f, %f, %f, %f, %f, %f, %f, %d, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'House', 2)", query, price, X, Y, Z, A, HouseInfo[houseid][hInsideX], HouseInfo[houseid][hInsideY], HouseInfo[houseid][hInsideZ], HouseInfo[houseid][hInsideA], HouseInfo[houseid][hInterior]);
  376. mysql_tquery(sqlGameConnection, query, "sqlAddHouse", "i", houseid);
  377. }
  378. else return AdmErrorMsg;
  379. return 1;
  380. }
  381.  
  382. CMD:deletehouse(playerid, params[])
  383. {
  384. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pBizMod] == 1)
  385. {
  386. new houseid;
  387. if(sscanf(params, "ds[128]", houseid, str))
  388. {
  389. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /deletehouse [houseid] [confirm]");
  390. return 1;
  391. }
  392. if(HouseInfo[houseid][hCreated] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "That house has not even been created yet.");
  393. if(strcmp(str, "confirm", true) == 0)
  394. {
  395. foreach(Player, i)
  396. {
  397. if(IsPlayerConnected(i))
  398. {
  399. if(PlayerInfo[i][pHouseID] == houseid)
  400. {
  401. SendClientMessage(i, COLOR_LIGHTBLUE, "* Your house has been deleted by an admin, you are no longer the owner.");
  402. PlayerInfo[i][pHouseID] = 0;
  403. }
  404. }
  405. }
  406. new query[100];
  407. format(query, sizeof(query), "DELETE FROM `houses` WHERE `HouseID` = %d", HouseInfo[houseid][hSQLID]);
  408. mysql_tquery(sqlGameConnection, query);
  409. format(str, sizeof(str), "You have fully deleted houseid %d.", houseid);
  410. SendClientMessage(playerid, COLOR_GRAD1, str);
  411. DeleteHouse(houseid);
  412. }
  413. else
  414. {
  415. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /deletehouse [houseid] [confirm]");
  416. format(str, sizeof(str), "Are you sure you want to delete house id %d?", houseid);
  417. SendClientMessage(playerid, COLOR_GRAD2, str);
  418. return 1;
  419. }
  420. }
  421. else return AdmErrorMsg;
  422. return 1;
  423. }
  424.  
  425. CMD:resethouse(playerid, params[])
  426. {
  427. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pBizMod] == 1)
  428. {
  429. new houseid;
  430. if(sscanf(params, "ds[128]", houseid, str))return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /resethouse [houseid] [confirm]");
  431. if(HouseInfo[houseid][hCreated] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "That house has not even been created yet! ");
  432. if(strcmp(str, "confirm", true) == 0)
  433. {
  434. foreach(Player, i)
  435. {
  436. if(IsPlayerConnected(i))
  437. {
  438. if(PlayerInfo[i][pHouseID] == houseid)
  439. {
  440. SendClientMessage(i, COLOR_LIGHTBLUE, "* Your house has been reset by an admin, you are no longer the owner.");
  441. PlayerInfo[i][pHouseID] = 0;
  442. }
  443. }
  444. }
  445. HouseInfo[houseid][hOwned] = 0;
  446. HouseInfo[houseid][hLocked] = 0;
  447. HouseInfo[houseid][hCash] = 0;
  448. HouseInfo[houseid][hMaterials] = 0;
  449. HouseInfo[houseid][hPot] = 0;
  450. HouseInfo[houseid][hCrack] = 0;
  451. HouseInfo[houseid][hAlarm] = 0;
  452. HouseInfo[houseid][hAlarmStatus] = 0;
  453. HouseInfo[houseid][hGun1] = 0;
  454. HouseInfo[houseid][hGun2] = 0;
  455. HouseInfo[houseid][hGun3] = 0;
  456. HouseInfo[houseid][hGun4] = 0;
  457. HouseInfo[houseid][hOwnerID] = -1;
  458.  
  459. strdel(HouseInfo[houseid][hTag], 0, strlen(HouseInfo[houseid][hTag]));
  460. strins(HouseInfo[houseid][hTag], "House", 0);
  461. SetHouseTag(houseid);
  462. format(str, sizeof(str), "You have reset houseid %d.", houseid);
  463. SendClientMessage(playerid, COLOR_GRAD1, str);
  464. HouseInfo[houseid][hModified] = 1;
  465. return 1;
  466. }
  467. }
  468. else return AdmErrorMsg;
  469. return 1;
  470. }
  471.  
  472. CMD:gotohouse(playerid, params[])
  473. {
  474. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pBizMod] == 1)
  475. {
  476. new houseid;
  477. if(sscanf(params, "d", houseid)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /gotohouse [id]");
  478. if(HouseInfo[houseid][hCreated] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "That house hasn't been created yet.");
  479. if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
  480. {
  481. SendClientMessage(playerid, COLOR_GREY, "You can not do that while spectating.");
  482. return 1;
  483. }
  484. SetPlayerPos(playerid, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]);
  485. SetPlayerInterior(playerid, 0);
  486. PlayerInfo[playerid][pInt] = 0;
  487. SetPlayerVirtualWorld(playerid, 0);
  488. PlayerInfo[playerid][pVirtualWorld] = 0;
  489. format(str, sizeof(str), "~w~Teleporting to ~b~\"%s\"~w~.", HouseInfo[houseid][hTag]);
  490. displayCenterHUDInfo(playerid, str, 8); //display for 8 seconds
  491. }
  492. else
  493. {
  494. AdmErrorMsg;
  495. }
  496. return 1;
  497. }
  498. CMD:gotohousesqlid(playerid, params[])
  499. {
  500. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pBizMod] == 1)
  501. {
  502. new houseid;
  503. if(sscanf(params, "d", houseid))
  504. return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /gotohousesqlid [post code/SQL ID]");
  505.  
  506. houseid = GetHouseIDFromSQLID(houseid);
  507.  
  508. if(HouseInfo[houseid][hCreated] == 0)
  509. return SendClientMessage(playerid, COLOR_GRAD1, "That house hasn't been created yet.");
  510.  
  511. if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
  512. return SendClientMessage(playerid, COLOR_GREY, "You can not do that while spectating.");
  513.  
  514. SetPlayerPos(playerid, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]);
  515. SetPlayerInterior(playerid, 0);
  516. PlayerInfo[playerid][pInt] = 0;
  517. SetPlayerVirtualWorld(playerid, 0);
  518. PlayerInfo[playerid][pVirtualWorld] = 0;
  519. format(str, sizeof(str), "~w~Teleporting to ~b~\"%s\"~w~.", HouseInfo[houseid][hTag]);
  520. displayCenterHUDInfo(playerid, str, 8); //display for 8 seconds
  521. }
  522. else
  523. {
  524. AdmErrorMsg;
  525. }
  526. return 1;
  527. }
  528. CMD:asethousetag(playerid, params[])
  529. {
  530. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pBizMod] == 1)
  531. {
  532. new houseid;
  533. if(sscanf(params, "ds[128]", houseid, tmp)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /asethousetag [House ID] [New Tag]");
  534. if(HouseInfo[houseid][hCreated] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "That house hasn't been created yet.");
  535. if(HouseInfo[houseid][hOwned] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "That house isn't owned yet.");
  536. if(strlen(tmp) < 4 || strlen(tmp) > 25) return SendClientMessage(playerid, COLOR_GRAD1, "The tag must be greater than 4 and lesser than 26.");
  537.  
  538. strdel(HouseInfo[houseid][hTag], 0, 25);
  539. strmid(HouseInfo[houseid][hTag], tmp, 0, sizeof(tmp), 25);
  540. SetHouseTag(houseid);
  541. format(str, sizeof(str), "That house's tag has been set to \"%s\"", HouseInfo[houseid][hTag]);
  542. SendClientMessage(playerid, COLOR_GRAD1, str);
  543. HouseInfo[houseid][hModified] = 1;
  544. }
  545. else
  546. {
  547. AdmErrorMsg;
  548. }
  549. return 1;
  550. }
  551. CMD:ogethouseowner(playerid, params[])
  552. {
  553. if(PlayerInfo[playerid][pAdmin] < 1 && PlayerInfo[playerid][pBizMod] != 1)
  554. return AdmErrorMsg;
  555.  
  556. new name[MAX_PLAYER_NAME + 1];
  557. if(sscanf(params, "s[25]", name))
  558. return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /ogethouseowner [full name (case matters)]");
  559.  
  560. new query[300];
  561. mysql_format(sqlGameConnection, query, sizeof(query), "SELECT HouseID FROM houses INNER JOIN players ON houses.OwnerID = players.ID WHERE players.Name = '%e' LIMIT 1", name);
  562. mysql_tquery(sqlGameConnection, query, "Onogethouseowner", "is", playerid, name);
  563. return 1;
  564. }
  565. forward Onogethouseowner(playerid, name[]);
  566. public Onogethouseowner(playerid, name[])
  567. {
  568. if(cache_num_rows() != 0)
  569. {
  570. new
  571. ownerstr[128], sqlid = cache_get_field_content_int(0, "HouseID");
  572. format(ownerstr, 128, "Owner: %s, SQL house ID/post code: %d", name, sqlid);
  573. SendClientMessage(playerid, COLOR_GREY, ownerstr);
  574. return 1;
  575. }
  576. SendClientMessage(playerid, COLOR_GREY, "That player doesn't own a house.");
  577. return 1;
  578. }
  579. CMD:houseinfo(playerid, params[])
  580. {
  581. if(PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pBizMod] == 1)
  582. {
  583. for(new i = 0; i < MAX_HOUSES; i++)
  584. {
  585. if(HouseInfo[i][hCreated] == 1)
  586. {
  587. if(IsPlayerInRangeOfPoint(playerid, 1.0, HouseInfo[i][hOutsideX], HouseInfo[i][hOutsideY], HouseInfo[i][hOutsideZ]))
  588. {
  589. format(str, sizeof(str), "Owner: %s, ID: %d, Owner SQL ID: %d", HouseInfo[i][hOwner], i, HouseInfo[i][hOwnerID]);
  590. SendClientMessage(playerid, COLOR_GRAD1, str);
  591. }
  592. }
  593. }
  594. }
  595. return 1;
  596. }
  597.  
  598. CMD:edithouse(playerid, params[])
  599. {
  600. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pBizMod] == 1)
  601. {
  602. new tmp2[128];
  603. new houseid;
  604. if(sscanf(params, "s[128] ", tmp))
  605. {
  606. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /edithouse [action] [houseid]");
  607. SendClientMessage(playerid, COLOR_GRAD2, "ACTIONS: entrance, interior, value");
  608. return 1;
  609. }
  610. if(strcmp(tmp, "entrance", true) == 0)
  611. {
  612. if(sscanf(params, "s[8] d", tmp2, houseid))
  613. {
  614. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /edithouse entrance [houseid]");
  615. return 1;
  616. }
  617. new Float:X, Float:Y, Float:Z, Float:A;
  618. GetPlayerPos(playerid, X, Y, Z);
  619. GetPlayerFacingAngle(playerid, A);
  620. if(HouseInfo[houseid][hCreated] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "That house has not even been created yet.");
  621. HouseInfo[houseid][hOutsideX] = X;
  622. HouseInfo[houseid][hOutsideY] = Y;
  623. HouseInfo[houseid][hOutsideZ] = Z;
  624. HouseInfo[houseid][hOutsideA] = A;
  625. if(HouseInfo[houseid][hOutsidePickup])
  626. {
  627. DestroyDynamicPickup(HouseInfo[houseid][hOutsidePickup]);
  628. }
  629. HouseInfo[houseid][hOutsidePickup] = CreateDynamicPickup(1273, 1, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]);
  630. DestroyDynamic3DTextLabel(HouseInfoText3D[houseid]);
  631. HouseInfoText3D[houseid] = CreateDynamic3DTextLabel("", COLOR_HOUSETEXT, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ] +0.88, 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 100);
  632. SetHouseTag(houseid);
  633. format(str, sizeof(str), "You have moved houseid %d's entrance.", houseid);
  634. SendClientMessage(playerid, COLOR_GRAD1, str);
  635. HouseInfo[houseid][hModified] = 1;
  636. return 1;
  637. }
  638. else if(strcmp(tmp, "interior", true) == 0)
  639. {
  640. new interiorid;
  641. if(sscanf(params, "s[128] dd", tmp2, houseid, interiorid))
  642. {
  643. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /edithouse interior [houseid] [interiorid]");
  644. SendClientMessage(playerid, COLOR_GRAD2, "{00BFFF}Usage:{FFFFFF} /viewhouseint [1-22] or /gotoint");
  645. return 1;
  646. }
  647. if(HouseInfo[houseid][hCreated] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "That house has not even been created yet.");
  648. SetHouseInterior(houseid, interiorid);
  649. format(str, sizeof(str), "You have edited houseid %d's interiorid to %d.", houseid, interiorid);
  650. SendClientMessage(playerid, COLOR_GRAD1, str);
  651. HouseInfo[houseid][hModified] = 1;
  652. return 1;
  653. }
  654. else if(strcmp(tmp, "value", true) == 0)
  655. {
  656. new value;
  657. if(sscanf(params, "s[128] dd", tmp2, houseid, value))
  658. {
  659. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /edithouse value [houseid] [new value]");
  660. return 1;
  661. }
  662. if(HouseInfo[houseid][hCreated] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "That house has not even been created yet.");
  663. HouseInfo[houseid][hValue] = value;
  664. SetHouseTag(houseid);
  665. format(str, sizeof(str), "You have edited houseid %d's value to $%d.", houseid, value);
  666. SendClientMessage(playerid, COLOR_GRAD1, str);
  667. HouseInfo[houseid][hModified] = 1;
  668. return 1;
  669. }
  670. else
  671. {
  672. format(str, sizeof(str), "Invalid action \"%s\".", tmp);
  673. SendClientMessage(playerid, COLOR_GRAD1, str);
  674. return 1;
  675. }
  676. }
  677. else
  678. {
  679. AdmErrorMsg;
  680. }
  681. return 1;
  682. }
  683.  
  684. CMD:viewhouseint(playerid, params[])
  685. {
  686. if(PlayerInfo[playerid][pAdmin] >=4 || PlayerInfo[playerid][pBizMod] == 1)
  687. {
  688. new interiorid;
  689. if(sscanf(params, "i", interiorid)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /viewhouseint [1-22]");
  690. if(interiorid < 1 || interiorid > 22)
  691. {
  692. SendClientMessage(playerid, COLOR_GREY, "Number can't be below 1 or above 22.");
  693. return 1;
  694. }
  695. SetPlayerHouseInterior(playerid, interiorid);
  696. }
  697. return 1;
  698. }
  699. //=============================[ Player Commands ]==============================
  700. CMD:sellhousetomarket(playerid, params[])
  701. {
  702. //Conditions
  703. if(PlayerInfo[playerid][pHouseID] == 0)
  704. return SendClientMessage(playerid, COLOR_GRAD1, "You do not own a house to sell.");
  705.  
  706. new
  707. houseid = PlayerInfo[playerid][pHouseID], location[60],
  708. value = HouseInfo[houseid][hValue] / 4;
  709.  
  710. Get2DZone(location, MAX_ZONE_NAME, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]);
  711.  
  712. if(sscanf(params, "s[128]", str))
  713. {
  714. format(str, sizeof(str), "Your property is currently worth {FFFF00}$%d{FAFAFA}, type {FF0000}/sellhousetomarket confirm{FAFAFA} to sell {FFFF00}%d %s.", value, houseid, location);
  715. return SendClientMessage(playerid, COLOR_WHITE, str);
  716. }
  717.  
  718. //Sell the house
  719. if(strcmp(str, "confirm", true) == 0)
  720. {
  721. GiveMoney(playerid, value);
  722. HouseInfo[houseid][hOwned] = 0;
  723. HouseInfo[houseid][hLocked] = 0;
  724. HouseInfo[houseid][hCash] = 0;
  725. HouseInfo[houseid][hMaterials] = 0;
  726. HouseInfo[houseid][hPot] = 0;
  727. HouseInfo[houseid][hCrack] = 0;
  728. HouseInfo[houseid][hAlarm] = 0;
  729. HouseInfo[houseid][hAlarmStatus] = 0;
  730. HouseInfo[houseid][hGun1] = 0;
  731. HouseInfo[houseid][hGun2] = 0;
  732. HouseInfo[houseid][hGun3] = 0;
  733. HouseInfo[houseid][hGun4] = 0;
  734. HouseInfo[houseid][hOwnerID] = -1;
  735. format(HouseInfo[houseid][hOwner], 24, "Nobody");
  736. PlayerInfo[playerid][pHouseID] = 0;
  737. format(str, sizeof(str), "Congratulations, you have sold {FFFF00}%d %s{FAFAFA} for $%d.", houseid, location, value);
  738. SendClientMessage(playerid, COLOR_WHITE, str);
  739. strdel(HouseInfo[houseid][hTag], 0, strlen(HouseInfo[houseid][hTag]));
  740. strins(HouseInfo[houseid][hTag], "House", 0);
  741. SetHouseTag(houseid);
  742. HouseInfo[houseid][hModified] = 1;
  743. }
  744. else
  745. {
  746. format(str, sizeof(str), "Your property is currently worth {FFFF00}$%d{FAFAFA}, type {FF0000}/sellhousetomarket confirm{FAFAFA} to sell {FFFF00}%d %s.", value, houseid, location);
  747. SendClientMessage(playerid, COLOR_WHITE, str);
  748. }
  749. return 1;
  750. }
  751.  
  752. CMD:sethousetag(playerid, params[])
  753. {
  754. if(PlayerInfo[playerid][pHouseID] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "You do not own a house.");
  755. new houseid = PlayerInfo[playerid][pHouseID];
  756. if(sscanf(params, "s[128]", str)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /sethousetag [Text]");
  757. if(strlen(str) < 4 || strlen(str) > 25) return SendClientMessage(playerid, COLOR_GRAD1, "The tag must be greater than 4 and lesser than 26.");
  758. if(!AlphaNumeric(tmp))
  759. {
  760. SendClientMessage(playerid, COLOR_RED, "** Invalid characters.");
  761. return 1;
  762. }
  763. strdel(HouseInfo[houseid][hTag], 0, 25);
  764. strmid(HouseInfo[houseid][hTag], str, 0, sizeof(str), 25);
  765. SetHouseTag(houseid);
  766. format(str, sizeof(str), "Your house's tag has been set to \"%s\"", HouseInfo[houseid][hTag]);
  767. SendClientMessage(playerid, COLOR_GRAD1, str);
  768. HouseInfo[houseid][hModified] = 1;
  769. return 1;
  770. }
  771.  
  772. CMD:house(playerid, params[])
  773. {
  774. if(PlayerInfo[playerid][pHouseID] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "You do not own a house.");
  775. new houseid = PlayerInfo[playerid][pHouseID];
  776.  
  777. if(HouseInfo[houseid][hOwnerID] != PlayerInfo[playerid][pID])
  778. return SendClientMessage(playerid, COLOR_GREY, "You don't own this house.");
  779.  
  780. if(!IsPlayerInRangeOfPoint(playerid, 100.0, HouseInfo[houseid][hInsideX], HouseInfo[houseid][hInsideY], HouseInfo[houseid][hInsideZ]) || GetPlayerVirtualWorld(playerid) != HouseInfo[houseid][hSQLID])
  781. {
  782. SendClientMessage(playerid, COLOR_GRAD1, "You are not inside your house.");
  783. return 1;
  784. }
  785. new action[2][32];
  786. if(sscanf(params, "s[32] ", action[0]))
  787. {
  788. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house [action]");
  789. SendClientMessage(playerid, COLOR_GRAD2, "ACTIONS: store, get, check.");
  790. return 1;
  791. }
  792. if(strcmp(action[0], "store", true) == 0)
  793. {
  794. if(sscanf(params, "s[32] s[32] ", action[0], action[1]))
  795. {
  796. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house store [item]");
  797. SendClientMessage(playerid, COLOR_GRAD2, "Items: gun, cash, materials, pot, crack");
  798. return 1;
  799. }
  800. if(strcmp(action[1], "gun", true) == 0)
  801. {
  802. new weaponid = GetPlayerWeapon(playerid);
  803. if(HaveWeapon(playerid, weaponid) == weaponid && (weaponid == 22 || weaponid == 24 || weaponid == 25 || weaponid == 27 || weaponid == 29 || weaponid == 31 || weaponid == 30 || weaponid == 33 || weaponid == 34))
  804. {
  805. new weaponname[64];
  806. GetWeaponName(weaponid, weaponname, 64);
  807. if(HouseInfo[houseid][hGun1] == 0)
  808. {
  809. if(PlayerInfo[playerid][pMask] == 0)
  810. {
  811. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  812. format(str, sizeof(str), "* %s stores a %s into their safe.", PlayerICName(playerid), weaponname);
  813. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  814. }
  815. format(str, sizeof(str), "* You have stored a %s.", weaponname);
  816. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  817. HouseInfo[houseid][hGun1] = weaponid;
  818. TakeWeapon(playerid, weaponid);
  819. SetPlayerArmedWeapon(playerid, 0);
  820. HouseInfo[houseid][hModified] = 1;
  821.  
  822. return 1;
  823. }
  824. else if(HouseInfo[houseid][hGun2] == 0)
  825. {
  826. if(PlayerInfo[playerid][pMask] == 0)
  827. {
  828. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  829. format(str, sizeof(str), "* %s stores a %s into their safe.", PlayerICName(playerid), weaponname);
  830. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  831. }
  832. format(str, sizeof(str), "* You have stored a %s.", weaponname);
  833. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  834. HouseInfo[houseid][hGun2] = weaponid;
  835. TakeWeapon(playerid, weaponid);
  836. SetPlayerArmedWeapon(playerid, 0);
  837. HouseInfo[houseid][hModified] = 1;
  838. return 1;
  839. }
  840. else if(HouseInfo[houseid][hGun3] == 0)
  841. {
  842. if(PlayerInfo[playerid][pMask] == 0)
  843. {
  844. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  845. format(str, sizeof(str), "* %s stores a %s into their safe.", PlayerICName(playerid), weaponname);
  846. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  847. }
  848. format(str, sizeof(str), "* You have stored a %s.", weaponname);
  849. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  850. HouseInfo[houseid][hGun3] = weaponid;
  851. TakeWeapon(playerid, weaponid);
  852. SetPlayerArmedWeapon(playerid, 0);
  853. HouseInfo[houseid][hModified] = 1;
  854. return 1;
  855. }
  856. else if(HouseInfo[houseid][hGun4] == 0 && PlayerInfo[playerid][pDonateRank] >= 2)
  857. {
  858. if(PlayerInfo[playerid][pMask] == 0)
  859. {
  860. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  861. format(str, sizeof(str), "* %s stores a %s into their safe.", PlayerICName(playerid), weaponname);
  862. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  863. }
  864. format(str, sizeof(str), "* You have stored a %s.", weaponname);
  865. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  866. HouseInfo[houseid][hGun4] = weaponid;
  867. TakeWeapon(playerid, weaponid);
  868. SetPlayerArmedWeapon(playerid, 0);
  869. HouseInfo[houseid][hModified] = 1;
  870. return 1;
  871. }
  872. else
  873. {
  874. SendClientMessage(playerid, COLOR_GRAD1, "None of your gun slots are empty.");
  875. }
  876. return 1;
  877. }
  878. else
  879. {
  880. SendClientMessage(playerid, COLOR_GRAD1, "You can not store this.");
  881. }
  882. }
  883. if(strcmp(action[1], "pot", true) == 0 || strcmp(action[1], "weed", true) == 0)
  884. {
  885. new potam = 0;
  886. if(sscanf(params, "s[32] s[32] d", action[0], action[1], potam)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house store pot [amount]");
  887. if(potam < 1 || potam > 1000) return SendClientMessage(playerid, COLOR_GRAD1, "Invalid amount.");
  888. if(potam > PlayerInfo[playerid][pPot]) return SendClientMessage(playerid, COLOR_GRAD1, "You don't have that much pot.");
  889. if(HouseInfo[houseid][hPot] +potam > 1000) return SendClientMessage(playerid, COLOR_GRAD1, "Your safe is at or greater than it's pot limit.");
  890. HouseInfo[houseid][hPot] += potam;
  891. PlayerInfo[playerid][pPot] -= potam;
  892. if(PlayerInfo[playerid][pMask] == 0)
  893. {
  894. format(str, sizeof(str), "* %s takes out some pot and puts it into their safe.", PlayerICName(playerid));
  895. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  896. }
  897. format(str, sizeof(str), "* You have stored %d pot into your safe.", potam);
  898. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  899. HouseInfo[houseid][hModified] = 1;
  900. }
  901. if(strcmp(action[1], "crack", true) == 0)
  902. {
  903. new crackam = 0;
  904. if(sscanf(params, "s[32] s[32] d", action[0], action[1], crackam)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house store crack [amount]");
  905. if(crackam < 1 || crackam > 1000) return SendClientMessage(playerid, COLOR_GRAD1, "Invalid amount.");
  906. if(crackam > PlayerInfo[playerid][pCrack]) return SendClientMessage(playerid, COLOR_GRAD1, "You don't have that much crack.");
  907. if(HouseInfo[houseid][hCrack] +crackam > 1000) return SendClientMessage(playerid, COLOR_GRAD1, "Your safe is at or greater than it's crack limit.");
  908. HouseInfo[houseid][hCrack] += crackam;
  909. PlayerInfo[playerid][pCrack] -= crackam;
  910. if(PlayerInfo[playerid][pMask] == 0)
  911. {
  912. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  913. format(str, sizeof(str), "* %s takes out some crack and puts it into their safe.", PlayerICName(playerid));
  914. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  915. }
  916. format(str, sizeof(str), "* You have stored %d crack into your safe.", crackam);
  917. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  918. HouseInfo[houseid][hModified] = 1;
  919. }
  920. if(strcmp(action[1], "materials", true) == 0 || strcmp(action[1], "mats", true) == 0)
  921. {
  922. new matam = 0;
  923. if(sscanf(params, "s[32] s[32] d", action[0], action[1], matam)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house store mats/materials [amount]");
  924. if(matam < 1 || matam > 500000) return SendClientMessage(playerid, COLOR_GRAD1, "Invalid amount.");
  925. if(matam > PlayerInfo[playerid][pMats]) return SendClientMessage(playerid, COLOR_GRAD1, "You don't have that many materials.");
  926. if(HouseInfo[houseid][hMaterials] +matam > 500000) return SendClientMessage(playerid, COLOR_GRAD1, "Your safe is at or greater than it's materials limit.");
  927. HouseInfo[houseid][hMaterials] += matam;
  928. PlayerInfo[playerid][pMats] -= matam;
  929. if(PlayerInfo[playerid][pMask] == 0)
  930. {
  931. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  932. format(str, sizeof(str), "* %s takes out some materials and puts it into their safe.", PlayerICName(playerid));
  933. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  934. }
  935. format(str, sizeof(str), "* You have stored %d materials into your safe.", matam);
  936. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  937. HouseInfo[houseid][hModified] = 1;
  938. }
  939. if(strcmp(action[1], "money", true) == 0 || strcmp(action[1], "cash", true) == 0)
  940. {
  941. new casham;
  942. if(sscanf(params, "s[32] s[32] d", action[0], action[1], casham)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house store money/cash [amount]");
  943. if(casham < 1 || casham > 1000000) return SendClientMessage(playerid, COLOR_GRAD1, "Invalid amount.");
  944. if(casham > PlayerInfo[playerid][pCash]) return SendClientMessage(playerid, COLOR_GRAD1, "You don't have that much cash.");
  945. if(HouseInfo[houseid][hCash] +casham > 1000000) return SendClientMessage(playerid, COLOR_GRAD1, "Your safe is at or greater than it's cash limit.");
  946. HouseInfo[houseid][hCash] += casham;
  947. PlayerInfo[playerid][pCash] -= casham;
  948. if(PlayerInfo[playerid][pMask] == 0)
  949. {
  950. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  951. format(str, sizeof(str), "* %s takes out some cash and puts it into their safe.", PlayerICName(playerid));
  952. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  953. }
  954. format(str, sizeof(str), "* You have stored $%d cash into your safe.", casham);
  955. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  956. HouseInfo[houseid][hModified] = 1;
  957. }
  958. return 1;
  959. }
  960. if(strcmp(action[0], "get", true) == 0)
  961. {
  962. if(sscanf(params, "s[32] s[32] ", action[0], action[1]))
  963. {
  964. if(PlayerInfo[playerid][pDonateRank] == 3)
  965. {
  966. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house get [item]");
  967. SendClientMessage(playerid, COLOR_GRAD2, "Items: gun, cash, materials, pot, crack");
  968. return 1;
  969. }
  970. else
  971. {
  972. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house get [item]");
  973. SendClientMessage(playerid, COLOR_GRAD2, "Items: gun, cash, materials, pot, crack");
  974. return 1;
  975. }
  976. }
  977. if(strcmp(action[1], "gun", true) == 0)
  978. {
  979. new slot = 0;
  980. if(sscanf(params, "s[32] s[32] d", action[0], action[1], slot))
  981. {
  982. if(PlayerInfo[playerid][pDonateRank] >= 2) SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house get gun [1-4]");
  983. else SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house get gun [1-3]");
  984. return 1;
  985. }
  986. new weaponname[64];
  987. if(slot == 1)
  988. {
  989. if(HouseInfo[houseid][hGun1] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "That slot is empty.");
  990. new weaponid = HouseInfo[houseid][hGun1];
  991. GivePlayerGun(playerid, weaponid);
  992. GetWeaponName(weaponid, weaponname, 64);
  993. if(PlayerInfo[playerid][pMask] == 0)
  994. {
  995. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  996. format(str, sizeof(str), "* %s takes a weapon from their safe.", PlayerICName(playerid));
  997. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  998. }
  999. format(str, sizeof(str), "* You have taken a %s from your house.", weaponname);
  1000. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  1001. HouseInfo[houseid][hGun1] = 0;
  1002. HouseInfo[houseid][hModified] = 1;
  1003. return 1;
  1004. }
  1005. if(slot == 2)
  1006. {
  1007. if(HouseInfo[houseid][hGun2] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "That slot is empty.");
  1008. new weaponid = HouseInfo[houseid][hGun2];
  1009. GivePlayerGun(playerid, weaponid);
  1010. GetWeaponName(weaponid, weaponname, 64);
  1011. if(PlayerInfo[playerid][pMask] == 0)
  1012. {
  1013. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  1014. format(str, sizeof(str), "* %s takes a weapon from their safe.", PlayerICName(playerid));
  1015. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  1016. }
  1017. format(str, sizeof(str), "* You have taken a %s from your house.", weaponname);
  1018. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  1019. HouseInfo[houseid][hGun2] = 0;
  1020. HouseInfo[houseid][hModified] = 1;
  1021. return 1;
  1022. }
  1023. if(slot == 3)
  1024. {
  1025. if(HouseInfo[houseid][hGun3] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "That slot is empty.");
  1026. new weaponid = HouseInfo[houseid][hGun3];
  1027. GivePlayerGun(playerid, weaponid);
  1028. GetWeaponName(weaponid, weaponname, 64);
  1029. if(PlayerInfo[playerid][pMask] == 0)
  1030. {
  1031. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  1032. format(str, sizeof(str), "* %s takes a weapon from their safe.", PlayerICName(playerid));
  1033. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  1034. }
  1035. format(str, sizeof(str), "* You have taken a %s from your house.", weaponname);
  1036. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  1037. HouseInfo[houseid][hGun3] = 0;
  1038. HouseInfo[houseid][hModified] = 1;
  1039. return 1;
  1040. }
  1041. if(slot == 4)
  1042. {
  1043. if(PlayerInfo[playerid][pDonateRank] < 2) return SendClientMessage(playerid, COLOR_GRAD1, "You're not a silver VIP or above.");
  1044. if(HouseInfo[houseid][hGun4] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "That slot is empty.");
  1045. new weaponid = HouseInfo[houseid][hGun4];
  1046. GivePlayerGun(playerid, weaponid);
  1047. GetWeaponName(weaponid, weaponname, 64);
  1048. if(PlayerInfo[playerid][pMask] == 0)
  1049. {
  1050. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  1051. format(str, sizeof(str), "* %s takes a weapon from their safe.", PlayerICName(playerid));
  1052. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  1053. }
  1054. format(str, sizeof(str), "* You have taken a %s from your house.", weaponname);
  1055. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  1056. HouseInfo[houseid][hGun4] = 0;
  1057. HouseInfo[houseid][hModified] = 1;
  1058. return 1;
  1059. }
  1060. else
  1061. {
  1062. SendClientMessage(playerid, COLOR_GRAD1, "Invalid weapon slot.");
  1063. return 1;
  1064. }
  1065. }
  1066. if(strcmp(action[1], "pot", true) == 0 || strcmp(action[1], "weed", true) == 0)
  1067. {
  1068. new potam = 0;
  1069. if(sscanf(params, "s[32] s[32] d", action[0], action[1], potam))
  1070. {
  1071. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house get pot [amount]");
  1072. return 1;
  1073. }
  1074. if(potam < 1 || potam > 1000) return SendClientMessage(playerid, COLOR_GRAD1, "Invalid amount.");
  1075. if(potam > HouseInfo[houseid][hPot]) return SendClientMessage(playerid, COLOR_GRAD1, "Your safe doesn't have that much pot.");
  1076. HouseInfo[houseid][hPot] -= potam;
  1077. PlayerInfo[playerid][pPot] += potam;
  1078. if(PlayerInfo[playerid][pMask] == 0)
  1079. {
  1080. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  1081. format(str, sizeof(str), "* %s takes some pot from their safe.", PlayerICName(playerid));
  1082. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  1083. }
  1084. format(str, sizeof(str), "* You have taken %d pot from your safe.", potam);
  1085. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  1086. HouseInfo[houseid][hModified] = 1;
  1087. }
  1088. if(strcmp(action[1], "crack", true) == 0)
  1089. {
  1090. new crackam = 0;
  1091. if(sscanf(params, "s[32] s[32] d", action[0], action[1], crackam))
  1092. {
  1093. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house get crack [amount]");
  1094. return 1;
  1095. }
  1096. if(crackam < 1 || crackam > 1000) return SendClientMessage(playerid, COLOR_GRAD1, "Invalid amount.");
  1097. if(crackam > HouseInfo[houseid][hCrack]) return SendClientMessage(playerid, COLOR_GRAD1, "Your safe doesn't have that much crack.");
  1098. HouseInfo[houseid][hCrack] -= crackam;
  1099. PlayerInfo[playerid][pCrack] += crackam;
  1100. if(PlayerInfo[playerid][pMask] == 0)
  1101. {
  1102. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  1103. format(str, sizeof(str), "* %s takes some crack from their safe.", PlayerICName(playerid));
  1104. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  1105. }
  1106. format(str, sizeof(str), "* You have taken %d crack from your safe.", crackam);
  1107. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  1108. HouseInfo[houseid][hModified] = 1;
  1109. }
  1110. if(strcmp(action[1], "materials", true) == 0 || strcmp(action[1], "mats", true) == 0)
  1111. {
  1112. new matam = 0;
  1113. if(sscanf(params, "s[32] s[32] d", action[0], action[1], matam))
  1114. {
  1115. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house get materials [amount]");
  1116. return 1;
  1117. }
  1118. if(matam < 1 || matam > 500000) return SendClientMessage(playerid, COLOR_GRAD1, "Invalid amount.");
  1119. if(matam > HouseInfo[houseid][hMaterials]) return SendClientMessage(playerid, COLOR_GRAD1, "Your safe doesn't have that many materials.");
  1120. HouseInfo[houseid][hMaterials] -= matam;
  1121. PlayerInfo[playerid][pMats] += matam;
  1122. if(PlayerInfo[playerid][pMask] == 0)
  1123. {
  1124. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  1125. format(str, sizeof(str), "* %s takes some materials from their safe.", PlayerICName(playerid));
  1126. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  1127. }
  1128. format(str, sizeof(str), "* You have taken %d materials from your safe.", matam);
  1129. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  1130. HouseInfo[houseid][hModified] = 1;
  1131. }
  1132. if(strcmp(action[1], "money", true) == 0 || strcmp(action[1], "cash", true) == 0)
  1133. {
  1134. new casham = 0;
  1135. if(sscanf(params, "s[32] s[32] d", action[0], action[1], casham))
  1136. {
  1137. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /house get money [amount]");
  1138. return 1;
  1139. }
  1140. if(casham < 1 || casham > 1000000) return SendClientMessage(playerid, COLOR_GRAD1, "Invalid amount.");
  1141. if(casham > HouseInfo[houseid][hCash]) return SendClientMessage(playerid, COLOR_GRAD1, "Your safe doesn't have that much cash.");
  1142. HouseInfo[houseid][hCash] -= casham;
  1143. PlayerInfo[playerid][pCash] += casham;
  1144. if(PlayerInfo[playerid][pMask] == 0)
  1145. {
  1146. // The str only gets sent if the player does NOT have a mask on due to the fact someone could reveal a hitman by knowing the owner of the house
  1147. format(str, sizeof(str), "* %s takes some cash from their safe.", PlayerICName(playerid));
  1148. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  1149. }
  1150. format(str, sizeof(str), "* You have taken $%d cash from your safe.", casham);
  1151. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  1152. HouseInfo[houseid][hModified] = 1;
  1153. }
  1154. return 1;
  1155. }
  1156. if(strcmp(action[0], "check", true) == 0)
  1157. {
  1158. DisplaySafeInfo(houseid, playerid);
  1159. return 1;
  1160. }
  1161. return 1;
  1162. }
  1163.  
  1164. CMD:setsale(playerid, params[])
  1165. {
  1166. if(PlayerInfo[playerid][pHouseID] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "You do not own a house.");
  1167. new confirmed[24];
  1168. if(!sscanf(params, "s[24]", confirmed))
  1169. {
  1170. if(!(strcmp(confirmed, "confirm", true) != 0))
  1171. {
  1172. if(!(gForSales[playerid][PlayerHasASaleBoard]))
  1173. {
  1174. new houseid = PlayerInfo[playerid][pHouseID];
  1175.  
  1176. if(HouseInfo[houseid][hOwnerID] != PlayerInfo[playerid][pID])
  1177. return SendClientMessage(playerid, COLOR_GREY, "You don't own this house.");
  1178.  
  1179. if(IsPlayerInRangeOfPoint(playerid, 15.0, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]))
  1180. {
  1181. new pcash = GetPlayerMoney(playerid);
  1182. if(pcash > 5000)
  1183. {
  1184. GiveMoney(playerid, -5000);
  1185. new Float:x, Float:y, Float:z, Float:Angle;
  1186. GetPlayerPos(playerid, x, y, z);
  1187. GetPlayerFacingAngle(playerid, Angle);
  1188. SendClientMessage(playerid, COLOR_LIGHTBLUE, "For-Sale was succesfully added, '/destroysale' in order to remove it.");
  1189. gForSales[playerid][Saleobject] = CreateDynamicObject(19471, (x -0.1), (y -0.1), (z -1), 0, 0, (Angle -270));
  1190. gForSales[playerid][PlayerHasASaleBoard] = true;
  1191. }
  1192. else SendClientMessage(playerid, COLOR_GREY, "You can't afford that.");
  1193. }
  1194. else SendClientMessage(playerid, COLOR_GREY, "You are not in range of your house.");
  1195. }
  1196. else SendClientMessage(playerid, COLOR_GREY, "You already have a For-Sale.");
  1197. }
  1198. }
  1199. else
  1200. {
  1201. SendClientMessage(playerid, COLOR_LIGHTBLUE, "** This costs 5000$, Point youself in the position you want it to be pointed at.");
  1202. SendClientMessage(playerid, COLOR_LIGHTBLUE, "** add the parameter \"confirm\" to confirm the sale-board.");
  1203. }
  1204. return 1;
  1205. }
  1206. CMD:destroysale(playerid, params[])
  1207. {
  1208. if(gForSales[playerid][PlayerHasASaleBoard])
  1209. {
  1210. new Float:x, Float:y, Float:z;
  1211. GetDynamicObjectPos(gForSales[playerid][Saleobject], x, y, z);
  1212. if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
  1213. {
  1214. DestroyDynamicObject(gForSales[playerid][Saleobject]);
  1215. gForSales[playerid][Saleobject] = 0;
  1216. SendClientMessage(playerid, COLOR_LIGHTBLUE, "For-Sale was succesfully destroyed");
  1217. gForSales[playerid][PlayerHasASaleBoard] = false;
  1218. }
  1219. else SendClientMessage(playerid, COLOR_GREY, "You have to be in range of your For-Sale in order to destroy it.");
  1220. }
  1221. else SendClientMessage(playerid, COLOR_GREY, "You do not have a For-Sale.");
  1222. return 1;
  1223. }
  1224.  
  1225. CMD:lockhouse(playerid, params[])
  1226. {
  1227. new houseid = PlayerInfo[playerid][pHouseID];
  1228. if(houseid !=0)
  1229. {
  1230. if(HouseInfo[houseid][hOwnerID] != PlayerInfo[playerid][pID])return SendClientMessage(playerid, COLOR_GREY, "You don't own this house.");
  1231. if(IsPlayerInRangeOfPoint(playerid, 1.0, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]) || IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[houseid][hInsideX], HouseInfo[houseid][hInsideY], HouseInfo[houseid][hInsideZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[houseid][hSQLID])
  1232. {
  1233. if(HouseInfo[houseid][hLocked])
  1234. {
  1235. format(str, sizeof(str), "* %s has unlocked the door to their property.", PlayerICName(playerid));
  1236. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  1237. HouseInfo[houseid][hLocked] = 0;
  1238. HouseInfo[houseid][hModified] = 1;
  1239. return 1;
  1240. }
  1241. else
  1242. {
  1243. format(str, sizeof(str), "* %s has locked the door to their property.", PlayerICName(playerid));
  1244. ProxDetector(30.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  1245. HouseInfo[houseid][hLocked] = 1;
  1246. HouseInfo[houseid][hModified] = 1;
  1247. return 1;
  1248. }
  1249. }
  1250. else
  1251. {
  1252. SendClientMessage(playerid, COLOR_GRAD1, "You are not near / inside the property you own.");
  1253. return 1;
  1254. }
  1255. }
  1256. return 1;
  1257. }
  1258. CMD:buyhouse(playerid, params[])
  1259. {
  1260. if(PlayerInfo[playerid][pHouseID] != 0)
  1261. return SendClientMessage(playerid, COLOR_GRAD1, "You already own a house.");
  1262.  
  1263. if(PlayerInfo[playerid][pLevel] == 1)
  1264. return SendClientMessage(playerid, COLOR_GRAD1, "You must be level 2+ to buy a house.");
  1265.  
  1266. new houseid = GetPlayerNearHouseID(playerid);
  1267.  
  1268. if(HouseInfo[houseid][hOwned] == 1)
  1269. return SendClientMessage(playerid, COLOR_GRAD1, "This property is already owned.");
  1270.  
  1271. if(PlayerInfo[playerid][pCash] < HouseInfo[houseid][hValue] && PlayerInfo[playerid][hTicket] == 0)
  1272. return SendClientMessage(playerid, COLOR_GRAD1, "You have incufficent funds to purchase this property.");
  1273.  
  1274. new location[MAX_ZONE_NAME];
  1275. location = GetHouseLocation(houseid);
  1276.  
  1277. if(sscanf(params, "s[128] ", str))
  1278. {
  1279. format(str, sizeof(str), "This property will cost you $%d, type {FF0000}/buyhouse confirm{F8ECE0} to purchase {FFFF00}%d %s", HouseInfo[houseid][hValue], houseid, location);
  1280. SendClientMessage(playerid, COLOR_WHITE, str);
  1281. return 1;
  1282. }
  1283. if(strcmp(str, "confirm", true) == 0)
  1284. {
  1285. HouseInfo[houseid][hOwned] = 1;
  1286. PlayerInfo[playerid][pHouseID] = houseid;
  1287. HouseInfo[houseid][hOwnerID] = PlayerInfo[playerid][pID];
  1288. strmid(HouseInfo[houseid][hOwner], PlayerName(playerid), 0, strlen(PlayerName(playerid)), 255);
  1289. GiveMoney(playerid, -HouseInfo[houseid][hValue]);
  1290. format(str, sizeof(str), "Congratulations, you just purchased {FFFF00}%d %s{F8ECE0} for $%d.", houseid, location, HouseInfo[houseid][hValue]);
  1291. SendClientMessage(playerid, COLOR_WHITE, str);
  1292. SendClientMessage(playerid, COLOR_WHITE, "Type {FF0000}/househelp{F8ECE0} for assistance.");
  1293. strdel(HouseInfo[houseid][hTag], 0, strlen(HouseInfo[houseid][hTag]));
  1294. strins(HouseInfo[houseid][hTag], "House", 0);
  1295. SetHouseTag(houseid);
  1296.  
  1297. format(str, sizeof(str), "%s has purchased a house in %s.", PlayerICName(playerid), location);
  1298. UpdateGameFeed(str, GAMEFEED_COLOR_GREEN);
  1299.  
  1300. HouseInfo[houseid][hModified] = 1;
  1301. return 1;
  1302. }
  1303. return 1;
  1304. }
  1305.  
  1306. CMD:sellhouse(playerid, params[])
  1307. {
  1308. new houseid = PlayerInfo[playerid][pHouseID];
  1309. if(PlayerInfo[playerid][pHouseID] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "You do not own a house to sell.");
  1310. if(!IsPlayerInRangeOfPoint(playerid, 20.0, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ])) return SendClientMessage(playerid, COLOR_GRAD1, "You are not near your house.");
  1311. new location[MAX_ZONE_NAME];
  1312. Get2DZone(location, MAX_ZONE_NAME, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]);
  1313. new selltoid, hoprice = 0;
  1314. if(sscanf(params, "ud", selltoid, hoprice))
  1315. {
  1316. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /sellhouse [PlayerID/PartOfName] [Price]");
  1317. return 1;
  1318. }
  1319. if(IsPlayerConnected(selltoid))
  1320. {
  1321. new Float:pgx, Float:pgy, Float:pgz;
  1322. GetPlayerPos(selltoid, pgx, pgy, pgz);
  1323. if(!IsPlayerInRangeOfPoint(playerid, 3.0, pgx, pgy, pgz)) return SendClientMessage(playerid, COLOR_GREY, "You are not near the player! ");
  1324. if(hoprice < 10000 || hoprice > 5000000) return SendClientMessage(playerid, COLOR_GRAD1, "Price must be in between $10,000 and $5,000,000.");
  1325. if(PlayerInfo[selltoid][pHouseID] != 0) return SendClientMessage(playerid, COLOR_GRAD1, "This player already owns a house.");
  1326. if(selltoid == playerid) return SendClientMessage(playerid, COLOR_GRAD1, "You can not sell your house to yourself.");
  1327. OfferedSellHouse[selltoid][0] = playerid;
  1328. OfferedSellHouse[selltoid][1] = hoprice;
  1329. OfferedSellHouse[selltoid][2] = houseid;
  1330. format(str, sizeof(str), "** %s has offered to sell you their house (%d %s) for $%d! /accept house to accept.", PlayerICName(playerid), houseid, location, hoprice);
  1331. SendClientMessage(selltoid, COLOR_LIGHTBLUE, str);
  1332. format(str, sizeof(str), "** You have offered to sell your house to %s (%d %s) for $%d.", PlayerICName(selltoid), houseid, location, hoprice);
  1333. SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
  1334. HouseInfo[houseid][hModified] = 1;
  1335. return 1;
  1336. }
  1337. return 1;
  1338. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement