housemarket.pwn 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976
  1. #include <YSI\y_hooks>
  2. #define MAX_LISTINGS_PER_PAGE (35)
  3. hook OnPlayerConnect(playerid)
  4. {
  5. AdTracking[playerid] = 0;
  6. HouseMarketTracking[playerid] = 0;
  7. ClearDoorSaleVariables(playerid);
  8. return 1;
  9. }
  10. hook OnPlayerDisconnect(playerid, reason)
  11. {
  12. for(new i = 0; i < sizeof(HouseInfo); i ++) if(HouseInfo[i][hOwnerID] == GetPlayerSQLId(playerid) && HouseInfo[i][Listed] == 1 && HouseInfo[i][PendingApproval] == 1) ClearHouseSaleVariables(i);
  13. foreach(new i : Player)
  14. {
  15. if(DDSaleTarget[i] == playerid && i != playerid)
  16. {
  17. SendClientMessageEx(i, COLOR_GREY, "The person purchasing your dynamic doors has disconnected.");
  18. ClearDoorSaleVariables(i);
  19. break;
  20. }
  21. }
  22. return 1;
  23. }
  24. ClearHouseSaleVariables(houseid)
  25. {
  26. HouseInfo[houseid][Listed] = 0;
  27. HouseInfo[houseid][PendingApproval] = 0;
  28. HouseInfo[houseid][ListedTimeStamp] = 0;
  29. HouseInfo[houseid][ListingPrice] = 0;
  30. for(new i = 0; i < 5; i ++)
  31. {
  32. if(i < 2) HouseInfo[houseid][LinkedGarage][i] = 0;
  33. HouseInfo[houseid][LinkedDoor][i] = 0;
  34. }
  35. strcpy(HouseInfo[houseid][ListingDescription], "N/A", 128);
  36. SaveHouse(houseid);
  37. return 1;
  38. }
  39. ShowListingInformation(playerid, houseid, dialogid)
  40. {
  41. new count[3];
  42. szMiscArray[0] = 0;
  43. format(szMiscArray, sizeof(szMiscArray), "General Information:\n\n » House ID: %d\n » Price: $%s\n » Seller: %s", houseid, number_format(HouseInfo[houseid][ListingPrice]), StripUnderscore(HouseInfo[houseid][hOwnerName]));
  44. if(strcmp("N/A", HouseInfo[houseid][ListingDescription], true) != 0) format(szMiscArray, sizeof(szMiscArray), "%s\n » Description: %s", szMiscArray, HouseInfo[houseid][ListingDescription]);
  45. format(szMiscArray, sizeof(szMiscArray), "%s\n » Expiry: %s", szMiscArray, date(HouseInfo[houseid][ListedTimeStamp], 4));
  46. strcat(szMiscArray, "\n\nLinked Dynamic Doors:\n");
  47. for(new i = 0; i < 5; i ++)
  48. {
  49. if(HouseInfo[houseid][LinkedDoor][i] != 0 && DDoorsInfo[HouseInfo[houseid][LinkedDoor][i]][ddOwner] == HouseInfo[houseid][hOwnerID])
  50. {
  51. format(szMiscArray, sizeof(szMiscArray), "%s\n » Door ID: %d (%s)", szMiscArray, HouseInfo[houseid][LinkedDoor][i], DDoorsInfo[HouseInfo[houseid][LinkedDoor][i]][ddDescription]);
  52. count[0] ++;
  53. }
  54. }
  55. if(count[0] == 0) strcat(szMiscArray, "\n » None");
  56. strcat(szMiscArray, "\n\nLinked Dynamic Gates:\n");
  57. for(new i = 0; i < sizeof(GateInfo); i ++)
  58. {
  59. if(GateInfo[i][gHID] == houseid)
  60. {
  61. format(szMiscArray, sizeof(szMiscArray), "%s\n » Gate ID: %d", szMiscArray, i);
  62. count[1] ++;
  63. }
  64. }
  65. if(count[1] == 0) strcat(szMiscArray, "\n » None");
  66. strcat(szMiscArray, "\n\nLinked Garages:\n");
  67. for(new i = 0; i < 2; i ++)
  68. {
  69. if(HouseInfo[houseid][LinkedGarage][i] != 0 && GarageInfo[HouseInfo[houseid][LinkedGarage][i]][gar_Owner] == HouseInfo[houseid][hOwnerID])
  70. {
  71. format(szMiscArray, sizeof(szMiscArray), "%s\n » Garage ID: %d", szMiscArray, HouseInfo[houseid][LinkedGarage][i]);
  72. count[2] ++;
  73. }
  74. }
  75. if(count[2] == 0) strcat(szMiscArray, "\n » None");
  76. ShowPlayerDialogEx(playerid, dialogid, DIALOG_STYLE_MSGBOX, "House Listing Information", szMiscArray, "Okay", "Cancel");
  77. return 1;
  78. }
  79. GetNearestOwnedHouse(playerid)
  80. {
  81. for(new i = 0; i < sizeof(HouseInfo); i ++) if(GetPlayerSQLId(playerid) == HouseInfo[i][hOwnerID] && IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hExtVW] && GetPlayerInterior(playerid) == HouseInfo[i][hExtIW]) return i;
  82. return -1;
  83. }
  84. ShowMainListingDialog(playerid)
  85. {
  86. new houseid;
  87. szMiscArray[0] = 0;
  88. houseid = GetNearestOwnedHouse(playerid);
  89. if(houseid == -1) return 1;
  90. format(szMiscArray, sizeof(szMiscArray), "Setting\tValue\nPrice\t$%s\nLinked Door 1\t%s\nLinked Door 2\t%s\nLinked Door 3\t%s\nLinked Door 4\t%s\nLinked Door 5\t%s\nLinked Garage 1\t%s\nLinked Garage 2\t%s\nDescription\t%s\nFinalize And Submit",
  91. number_format(HouseInfo[houseid][ListingPrice]), ReturnDoorLineDetails(playerid, HouseInfo[houseid][LinkedDoor][0]),
  92. ReturnDoorLineDetails(playerid, HouseInfo[houseid][LinkedDoor][1]), ReturnDoorLineDetails(playerid, HouseInfo[houseid][LinkedDoor][2]),
  93. ReturnDoorLineDetails(playerid, HouseInfo[houseid][LinkedDoor][3]), ReturnDoorLineDetails(playerid, HouseInfo[houseid][LinkedDoor][4]),
  94. ReturnGarageLineDetails(playerid, HouseInfo[houseid][LinkedGarage][0]), ReturnGarageLineDetails(playerid, HouseInfo[houseid][LinkedGarage][1]), HouseInfo[houseid][ListingDescription]);
  95. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEMAIN, DIALOG_STYLE_TABLIST_HEADERS, "House Market", szMiscArray, "Okay", "Cancel");
  96. return 1;
  97. }
  98. AdditionalAdvertisements(index)
  99. {
  100. for(new i = index; i < sizeof(HouseInfo); i ++) if(HouseInfo[i][Listed] == 1 && HouseInfo[i][PendingApproval] == 0) return true;
  101. return false;
  102. }
  103. task HouseMarket[60000]()
  104. {
  105. new bool:notification;
  106. for(new i = 0; i < sizeof(HouseInfo); i ++)
  107. {
  108. if(HouseInfo[i][Listed] == 1)
  109. {
  110. switch(HouseInfo[i][PendingApproval])
  111. {
  112. case 0:
  113. {
  114. if(gettime() >= HouseInfo[i][ListedTimeStamp])
  115. {
  116. ClearHouseSaleVariables(i);
  117. foreach(new p: Player)
  118. {
  119. if(gPlayerLogged{p} == 1 && HouseInfo[i][hOwnerID] == GetPlayerSQLId(p))
  120. {
  121. SendClientMessageEx(p, COLOR_GREY, "Your house listing has expired and has been removed from the market.");
  122. break;
  123. }
  124. }
  125. }
  126. }
  127. case 1:
  128. {
  129. if(notification == false)
  130. {
  131. ABroadCast(COLOR_LIGHTRED, "One or more house listing(s) are pending review.", 4, true);
  132. notification = true;
  133. }
  134. }
  135. }
  136. }
  137. }
  138. return 1;
  139. }
  140. CMD:al(playerid, params[]) return cmd_approvelisting(playerid, params);
  141. CMD:dli(playerid, params[]) return cmd_denylisting(playerid, params);
  142. CMD:houselistinghelp(playerid, params[])
  143. {
  144. SendClientMessageEx(playerid, COLOR_WHITE, "** HOUSE LISTING COMMANDS **");
  145. SendClientMessageEx(playerid, COLOR_GREY, "» /listhouse - Allows you to place a house listing ($500,000).");
  146. SendClientMessageEx(playerid, COLOR_GREY, "» /renewlisting - Allows you to renew an active house listing ($100,000).");
  147. SendClientMessageEx(playerid, COLOR_GREY, "» /listingdate - Allows you to view the date your house listing will expire on.");
  148. SendClientMessageEx(playerid, COLOR_GREY, "» /deletelisting - Allows you to delete a house listing you placed previously.");
  149. SendClientMessageEx(playerid, COLOR_GREY, "» /houselistings - Allows you to view a list of active house listings.");
  150. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1)
  151. {
  152. SendClientMessageEx(playerid, COLOR_GREY, "» {EE9A4D}SENIOR ADMIN{D8D8D8} /pendinglistings - Allows you to view a list of active house listings pending administrative approval.");
  153. SendClientMessageEx(playerid, COLOR_GREY, "» {EE9A4D}SENIOR ADMIN{D8D8D8} /listingdetails [House ID] - Allows you view the details of a specified and pending house listing.");
  154. SendClientMessageEx(playerid, COLOR_GREY, "» {EE9A4D}SENIOR ADMIN{D8D8D8} /(a)pprove(l)isting [House ID] - Allows you to approve the specified pending house listing.");
  155. SendClientMessageEx(playerid, COLOR_GREY, "» {EE9A4D}SENIOR ADMIN{D8D8D8} /(d)eny(li)sting [House ID] - Allows you to deny the specified pending house listing.");
  156. SendClientMessageEx(playerid, COLOR_GREY, "» {EE9A4D}SENIOR ADMIN{D8D8D8} /adeletelisting [House ID] - Allows you to delete the specified pending house listing.");
  157. SendClientMessageEx(playerid, COLOR_GREY, "* NOTICE: Using the (/admute) command will deny players the ability to post housing listings. *");
  158. }
  159. return 1;
  160. }
  161. CMD:denylisting(playerid, params[])
  162. {
  163. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are unauthorized to use this command.");
  164. new houseid, reason[64], string[128];
  165. if(sscanf(params, "ds[64]", houseid, reason)) return SendClientMessageEx(playerid, COLOR_GREY, "[USAGE]: /denylisting [House ID] [Reason]");
  166. if(houseid < 1 || houseid >= MAX_HOUSES)
  167. {
  168. format(szMiscArray, sizeof(szMiscArray), "The specified house ID must be between 1 and %d.", MAX_HOUSES - 1);
  169. SendClientMessageEx(playerid, COLOR_GREY, szMiscArray);
  170. return 1;
  171. }
  172. if(strlen(reason) < 3 || strlen(reason) > 60) return SendClientMessageEx(playerid, COLOR_GREY, "The specified reason cannot be under 3 characters or over 60 characters.");
  173. if(HouseInfo[houseid][hOwned] == 0) return SendClientMessageEx(playerid, COLOR_GREY, "The specified house is not currently owned.");
  174. if(HouseInfo[houseid][Listed] == 0 || HouseInfo[houseid][PendingApproval] == 0) return SendClientMessageEx(playerid, COLOR_GREY, "The specified house is not currently pending approval to be listed.");
  175. ClearHouseSaleVariables(houseid);
  176. format(string, sizeof(string), "You have denied house ID %d's house listing request (owner: %s), reason: %s.", houseid, StripUnderscore(HouseInfo[houseid][hOwnerName]), reason);
  177. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  178. foreach(new i: Player)
  179. {
  180. if(gPlayerLogged{i} == 1 && HouseInfo[houseid][hOwnerID] == GetPlayerSQLId(i))
  181. {
  182. format(string, sizeof(string), "%s denied your house listing request (house ID %d), reason: %s.", GetPlayerNameEx(playerid), houseid, reason);
  183. SendClientMessageEx(i, COLOR_LIGHTRED, string);
  184. break;
  185. }
  186. }
  187. PlayerInfo[playerid][pTrashReport] ++;
  188. format(string, sizeof(string), "AdmCmd: %s denied house ID %d's house listing request (owner: %s), reason: %s.", GetPlayerNameEx(playerid), houseid, StripUnderscore(HouseInfo[houseid][hOwnerName]), reason);
  189. ABroadCast(COLOR_LIGHTRED, string, 4);
  190. Log("logs/admin.log", string);
  191. return 1;
  192. }
  193. CMD:approvelisting(playerid, params[])
  194. {
  195. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are unauthorized to use this command.");
  196. new houseid, seller, string[128];
  197. if(sscanf(params, "d", houseid)) return SendClientMessageEx(playerid, COLOR_GREY, "[USAGE]: /approvelisting [House ID]");
  198. if(houseid < 1 || houseid >= MAX_HOUSES)
  199. {
  200. format(szMiscArray, sizeof(szMiscArray), "The specified house ID must be between 1 and %d.", MAX_HOUSES - 1);
  201. SendClientMessageEx(playerid, COLOR_GREY, szMiscArray);
  202. return 1;
  203. }
  204. if(HouseInfo[houseid][hOwned] == 0) return SendClientMessageEx(playerid, COLOR_GREY, "The specified house is not currently owned.");
  205. if(HouseInfo[houseid][Listed] == 0 || HouseInfo[houseid][PendingApproval] == 0) return SendClientMessageEx(playerid, COLOR_GREY, "The specified house is not currently pending approval to be listed.");
  206. seller = INVALID_PLAYER_ID;
  207. foreach(new i: Player)
  208. {
  209. if(gPlayerLogged{i} == 1 && HouseInfo[houseid][hOwnerID] == GetPlayerSQLId(i))
  210. {
  211. seller = i;
  212. break;
  213. }
  214. }
  215. switch(seller)
  216. {
  217. case INVALID_PLAYER_ID:
  218. {
  219. PlayerInfo[playerid][pAcceptReport] ++;
  220. ReportCount[playerid] ++;
  221. ReportHourCount[playerid] ++;
  222. format(string, sizeof(string), "House ID %d's listing is currently bugged, the listing has been removed.", houseid);
  223. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  224. return 1;
  225. }
  226. default:
  227. {
  228. if(GetPlayerCash(seller) < 500000)
  229. {
  230. ClearHouseSaleVariables(houseid);
  231. SendClientMessageEx(seller, COLOR_GREY, "Your house listing has been approved by an administrator, however you no longer have $500,000.");
  232. SendClientMessageEx(seller, COLOR_GREY, "Your house listing has not been placed on the market as you could not afford the initial posting fee.");
  233. PlayerInfo[playerid][pAcceptReport] ++;
  234. ReportCount[playerid] ++;
  235. ReportHourCount[playerid] ++;
  236. format(string, sizeof(string), "You have approved house ID %d's house listing request (insufficient funds - owner: %s).", houseid, StripUnderscore(HouseInfo[houseid][hOwnerName]));
  237. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  238. format(string, sizeof(string), "AdmCmd: %s approved house ID %d's house listing request (insufficient funds - owner: %s).", GetPlayerNameEx(playerid), houseid, StripUnderscore(HouseInfo[houseid][hOwnerName]));
  239. ABroadCast(COLOR_LIGHTRED, string, 4);
  240. Log("logs/admin.log", string);
  241. return 1;
  242. }
  243. else if(GetPlayerCash(seller) >= 500000)
  244. {
  245. GivePlayerCashEx(seller, TYPE_ONHAND, -500000);
  246. HouseInfo[houseid][PendingApproval] = 0;
  247. HouseInfo[houseid][ListedTimeStamp] = gettime() + 259200;
  248. SaveHouse(houseid);
  249. SendClientMessageEx(seller, COLOR_GREEN, "Your house listing has been approved by an administrator, you have been charged $500,000.");
  250. PlayerInfo[playerid][pAcceptReport] ++;
  251. ReportCount[playerid] ++;
  252. ReportHourCount[playerid] ++;
  253. format(string, sizeof(string), "You have approved house ID %d's house listing request (owner: %s).", houseid, StripUnderscore(HouseInfo[houseid][hOwnerName]));
  254. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  255. format(string, sizeof(string), "AdmCmd: %s approved house ID %d's house listing request (owner: %s).", GetPlayerNameEx(playerid), houseid, StripUnderscore(HouseInfo[houseid][hOwnerName]));
  256. ABroadCast(COLOR_LIGHTRED, string, 4);
  257. Log("logs/admin.log", string);
  258. return 1;
  259. }
  260. return 1;
  261. }
  262. }
  263. return 1;
  264. }
  265. CMD:adeletelisting(playerid, params[])
  266. {
  267. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are unauthorized to use this command.");
  268. new houseid, string[128];
  269. if(sscanf(params, "d", houseid)) return SendClientMessageEx(playerid, COLOR_GREY, "[USAGE]: /adeletelisting [House ID]");
  270. if(houseid < 1 || houseid >= MAX_HOUSES)
  271. {
  272. format(szMiscArray, sizeof(szMiscArray), "The specified house ID must be between 1 and %d.", MAX_HOUSES - 1);
  273. SendClientMessageEx(playerid, COLOR_GREY, szMiscArray);
  274. return 1;
  275. }
  276. if(HouseInfo[houseid][hOwned] == 0) return SendClientMessageEx(playerid, COLOR_GREY, "The specified house is not currently owned.");
  277. if(HouseInfo[houseid][Listed] == 0 || HouseInfo[houseid][PendingApproval] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "The specified house is not currently listed.");
  278. ClearHouseSaleVariables(houseid);
  279. format(string, sizeof(string), "You have deleted house ID %d's listing (owner: %s).", houseid, StripUnderscore(HouseInfo[houseid][hOwnerName]));
  280. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  281. format(string, sizeof(string), "AdmCmd: %s deleted house ID %d's house listing (owner: %s).", GetPlayerNameEx(playerid), houseid, StripUnderscore(HouseInfo[houseid][hOwnerName]));
  282. ABroadCast(COLOR_LIGHTRED, string, 4);
  283. Log("logs/admin.log", string);
  284. return 1;
  285. }
  286. CMD:listingdetails(playerid, params[])
  287. {
  288. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are unauthorized to use this command.");
  289. new houseid;
  290. if(sscanf(params, "d", houseid)) return SendClientMessageEx(playerid, COLOR_GREY, "[USAGE]: /listingdetails [House ID]");
  291. szMiscArray[0] = 0;
  292. if(houseid < 1 || houseid >= MAX_HOUSES)
  293. {
  294. format(szMiscArray, sizeof(szMiscArray), "The specified house ID must be between 1 and %d.", MAX_HOUSES - 1);
  295. SendClientMessageEx(playerid, COLOR_GREY, szMiscArray);
  296. return 1;
  297. }
  298. if(HouseInfo[houseid][hOwned] == 0) return SendClientMessageEx(playerid, COLOR_GREY, "The specified house is not currently owned.");
  299. if(HouseInfo[houseid][Listed] == 0 || HouseInfo[houseid][PendingApproval] == 0) return SendClientMessageEx(playerid, COLOR_GREY, "The specified house is not currently pending approval to be listed.");
  300. ShowListingInformation(playerid, houseid, DIALOG_LISTINGINFORMATION);
  301. return 1;
  302. }
  303. CMD:pendinglistings(playerid, params[])
  304. {
  305. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are unauthorized to use this command.");
  306. new count, string[64];
  307. SendClientMessageEx(playerid, COLOR_WHITE, "** HOUSE LISTINGS PENDING APPROVAL: **");
  308. for(new i = 0; i < sizeof(HouseInfo); i ++)
  309. {
  310. if(HouseInfo[i][hOwned] == 1 && HouseInfo[i][Listed] == 1 && HouseInfo[i][PendingApproval] == 1)
  311. {
  312. format(string, sizeof(string), "(House ID: %d) Owner: %s", i, StripUnderscore(HouseInfo[i][hOwnerName]));
  313. SendClientMessageEx(playerid, COLOR_GREY, string);
  314. count ++;
  315. }
  316. }
  317. if(count == 0) return SendClientMessageEx(playerid, COLOR_GREY, "There are not currently any house listings pending approval.");
  318. return 1;
  319. }
  320. CMD:listhouse(playerid, params[])
  321. {
  322. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
  323. if(PlayerInfo[playerid][pADMute] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are muted from advertisements.");
  324. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while injured.");
  325. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings right now.");
  326. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while in jail.");
  327. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be at least level 3 to access house listings.");
  328. if(GetPlayerCash(playerid) < 500000) return SendClientMessageEx(playerid, COLOR_GREY, "You must have at least $500,000 to place a house listing.");
  329. new houseid;
  330. if(servernumber == 2) return SendClientMessage(playerid, COLOR_WHITE, "This command is disabled!");
  331. houseid = GetNearestOwnedHouse(playerid);
  332. if(houseid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not near a house that you own.");
  333. if(HouseInfo[houseid][Listed] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This house is already listed on the house market.");
  334. HouseInfo[houseid][ListingPrice] = 0;
  335. HouseInfo[houseid][PendingApproval] = 0;
  336. HouseInfo[houseid][ListedTimeStamp] = 0;
  337. for(new i = 0; i < 5; i ++)
  338. {
  339. if(i < 2) HouseInfo[houseid][LinkedGarage][i] = 0;
  340. HouseInfo[houseid][LinkedDoor][i] = 0;
  341. }
  342. strcpy(HouseInfo[houseid][ListingDescription], "N/A", 128);
  343. SaveHouse(houseid);
  344. ShowMainListingDialog(playerid);
  345. return 1;
  346. }
  347. CMD:listingdate(playerid, params[])
  348. {
  349. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
  350. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while injured.");
  351. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings right now.");
  352. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while in jail.");
  353. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be at least level 3 to access house listings.");
  354. new houseid, string[128];
  355. if(servernumber == 2) return SendClientMessage(playerid, COLOR_WHITE, "This command is disabled!");
  356. houseid = GetNearestOwnedHouse(playerid);
  357. if(houseid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not near a house that you own.");
  358. if(HouseInfo[houseid][Listed] == 0 || HouseInfo[houseid][PendingApproval] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This house is not currently listed on the house market.");
  359. format(string, sizeof(string), "Your house listing will expire on %s.", date(HouseInfo[houseid][ListedTimeStamp], 4));
  360. SendClientMessageEx(playerid, COLOR_WHITE, string);
  361. return 1;
  362. }
  363. CMD:renewlisting(playerid, params[])
  364. {
  365. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
  366. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while injured.");
  367. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings right now.");
  368. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while in jail.");
  369. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be at least level 3 to access house listings.");
  370. if(GetPlayerCash(playerid) < 100000) return SendClientMessageEx(playerid, COLOR_GREY, "You must have at least $100,000 to renew your house listing.");
  371. new houseid, string[128];
  372. if(servernumber == 2) return SendClientMessage(playerid, COLOR_WHITE, "This command is disabled!");
  373. houseid = GetNearestOwnedHouse(playerid);
  374. if(houseid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not near a house that you own.");
  375. if(HouseInfo[houseid][Listed] == 0 || HouseInfo[houseid][PendingApproval] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This house is not currently listed on the house market.");
  376. HouseInfo[houseid][ListedTimeStamp] += 86400;
  377. SaveHouse(houseid);
  378. format(string, sizeof(string), "You have renewed your house listing by a day, it will expire on %s.", date(HouseInfo[houseid][ListedTimeStamp], 4));
  379. SendClientMessageEx(playerid, COLOR_GREEN, string);
  380. GivePlayerCashEx(playerid, TYPE_ONHAND, -100000);
  381. return 1;
  382. }
  383. CMD:deletelisting(playerid, params[])
  384. {
  385. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
  386. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while injured.");
  387. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings right now.");
  388. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while in jail.");
  389. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be at least level 3 to access house listings.");
  390. new houseid;
  391. if(servernumber == 2) return SendClientMessage(playerid, COLOR_WHITE, "This command is disabled!");
  392. houseid = GetNearestOwnedHouse(playerid);
  393. if(houseid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not near a house that you own.");
  394. if(HouseInfo[houseid][Listed] == 0 || HouseInfo[houseid][PendingApproval] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This house is not currently listed on the house market.");
  395. ClearHouseSaleVariables(houseid);
  396. SendClientMessageEx(playerid, COLOR_GREY, "You have taken your house listing off of the market.");
  397. return 1;
  398. }
  399. CMD:houselistings(playerid, params[])
  400. {
  401. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
  402. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while injured.");
  403. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings right now.");
  404. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while in jail.");
  405. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be at least level 3 to access house listings.");
  406. new count[4], location[MAX_ZONE_NAME];
  407. szMiscArray[0] = 0;
  408. for(new i = 0; i < sizeof(HouseInfo); i ++)
  409. {
  410. if(HouseInfo[i][hOwned] == 1 && HouseInfo[i][Listed] == 1 && HouseInfo[i][PendingApproval] == 0)
  411. {
  412. location = "San Andreas";
  413. for(new l = 1; l < sizeof(count); l ++) count[l] = 0;
  414. for(new l = 0; l < 5; l ++)
  415. {
  416. if(l < 2) if(HouseInfo[i][LinkedGarage][l] != 0) count[3] ++;
  417. if(HouseInfo[i][LinkedDoor][l] != 0) count[1] ++;
  418. }
  419. for(new l = 0; l < sizeof(GateInfo); l ++) if(GateInfo[l][gHID] == i) count[2] ++;
  420. Get3DZone(HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ], location, sizeof(location));
  421. format(szMiscArray, sizeof(szMiscArray), "%s\n(%d) [$%s] [%s] [%d DD(s)] [%d DG(s)] [%d G(s)]", szMiscArray, i, number_format(HouseInfo[i][ListingPrice]), location, count[1], count[2], count[3]);
  422. AdTracking[playerid] = i;
  423. count[0] ++;
  424. }
  425. if(count[0] == MAX_LISTINGS_PER_PAGE) break;
  426. }
  427. if(count[0] == 0) return SendClientMessage(playerid, COLOR_GREY, "There are no active advertisements at this time.");
  428. if(count[0] == MAX_LISTINGS_PER_PAGE) format(szMiscArray, sizeof(szMiscArray), "%s\n[Next Page...]", szMiscArray);
  429. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSELISTINGS, DIALOG_STYLE_LIST, "House Listings", szMiscArray, "Okay", "Cancel");
  430. return 1;
  431. }
  432. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  433. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  434. new string[128];
  435. switch(dialogid)
  436. {
  437. case DIALOG_LISTHOUSEMAIN:
  438. {
  439. new houseid;
  440. houseid = GetNearestOwnedHouse(playerid);
  441. switch(response)
  442. {
  443. case false: if(houseid != -1) return ClearHouseSaleVariables(houseid);
  444. case true:
  445. {
  446. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
  447. if(PlayerInfo[playerid][pADMute] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are muted from advertisements.");
  448. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while injured.");
  449. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings right now.");
  450. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while in jail.");
  451. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be at least level 3 to access house listings.");
  452. if(GetPlayerCash(playerid) < 500000) return SendClientMessageEx(playerid, COLOR_GREY, "You must have at least $500,000 to place a house listing.");
  453. if(houseid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not near a house that you own.");
  454. if(HouseInfo[houseid][Listed] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This house is already listed on the house market.");
  455. switch(listitem)
  456. {
  457. case 0: return ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEPRICE, DIALOG_STYLE_INPUT, "House Listings", "Input the price of your listing below.", "Okay", "Cancel");
  458. case 1..5:
  459. {
  460. HouseMarketTracking[playerid] = listitem - 1;
  461. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEDOORS, DIALOG_STYLE_INPUT, "House Listings", "Input the ID of a door to link it to your listing. Input \"0\" to remove a dynamic door.", "Okay", "Cancel");
  462. return 1;
  463. }
  464. case 6, 7:
  465. {
  466. HouseMarketTracking[playerid] = listitem - 6;
  467. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEGARAGES, DIALOG_STYLE_INPUT, "House Listings", "Input the ID of a garage to link it to your listing. Input \"0\" to remove a garage..", "Okay", "Cancel");
  468. return 1;
  469. }
  470. case 8: return ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEDESCRIPTION, DIALOG_STYLE_INPUT, "House Listings", "Input the description of your listing below.", "Okay", "Cancel");
  471. case 9:
  472. {
  473. if(HouseInfo[houseid][ListingPrice] == 0)
  474. {
  475. SendClientMessageEx(playerid, COLOR_GREY, "You must specify a price before submitting your listing.");
  476. ShowMainListingDialog(playerid);
  477. return 1;
  478. }
  479. for(new i = 0; i < 5; i ++)
  480. {
  481. if(i < 2) if(HouseInfo[houseid][LinkedGarage][i] != 0 && GetPlayerSQLId(playerid) != GarageInfo[HouseInfo[houseid][LinkedGarage][i]][gar_Owner]) HouseInfo[houseid][LinkedGarage][i] = 0;
  482. if(HouseInfo[houseid][LinkedDoor][i] != 0 && GetPlayerSQLId(playerid) != DDoorsInfo[HouseInfo[houseid][LinkedDoor][i]][ddOwner]) HouseInfo[houseid][LinkedDoor][i] = 0;
  483. }
  484. HouseInfo[houseid][Listed] = 1;
  485. HouseInfo[houseid][PendingApproval] = 1;
  486. SaveHouse(houseid);
  487. SendClientMessageEx(playerid, COLOR_GREEN, "Your housing listing has been submitted for review by server administration.");
  488. format(string, sizeof(string), "[New House Listing Request]: House ID %d, Owner: %s.", houseid, GetPlayerNameEx(playerid));
  489. ABroadCast(COLOR_LIGHTRED, string, 4);
  490. return 1;
  491. }
  492. }
  493. return 1;
  494. }
  495. }
  496. return 1;
  497. }
  498. case DIALOG_LISTHOUSEPRICE:
  499. {
  500. switch(response)
  501. {
  502. case false: return ShowMainListingDialog(playerid);
  503. case true:
  504. {
  505. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
  506. if(PlayerInfo[playerid][pADMute] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are muted from advertisements.");
  507. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while injured.");
  508. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings right now.");
  509. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while in jail.");
  510. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be at least level 3 to access house listings.");
  511. if(GetPlayerCash(playerid) < 500000) return SendClientMessageEx(playerid, COLOR_GREY, "You must have at least $500,000 to place a house listing.");
  512. new houseid, price;
  513. houseid = GetNearestOwnedHouse(playerid);
  514. if(houseid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not near a house that you own.");
  515. if(HouseInfo[houseid][Listed] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This house is already listed on the house market.");
  516. if(sscanf(inputtext, "d", price))
  517. {
  518. SendClientMessageEx(playerid, COLOR_GREY, "The specified price must be numerical.");
  519. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEPRICE, DIALOG_STYLE_INPUT, "House Listings", "Input the price of your listing below.", "Okay", "Cancel");
  520. return 1;
  521. }
  522. if(price < 100000 || price > 500000000)
  523. {
  524. SendClientMessageEx(playerid, COLOR_GREY, "The specified price cannot be under $100,000 or over $500,000,000.");
  525. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEPRICE, DIALOG_STYLE_INPUT, "House Listings", "Input the price of your listing below.", "Okay", "Cancel");
  526. return 1;
  527. }
  528. if(price == HouseInfo[houseid][ListingPrice])
  529. {
  530. format(string, sizeof(string), "Your listing price is already set to $%s.", number_format(price));
  531. SendClientMessageEx(playerid, COLOR_GREY, string);
  532. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEPRICE, DIALOG_STYLE_INPUT, "House Listings", "Input the price of your listing below.", "Okay", "Cancel");
  533. return 1;
  534. }
  535. HouseInfo[houseid][ListingPrice] = price;
  536. SaveHouse(houseid);
  537. SendClientMessageEx(playerid, COLOR_WHITE, "You have updated your listing price.");
  538. ShowMainListingDialog(playerid);
  539. return 1;
  540. }
  541. }
  542. return 1;
  543. }
  544. case DIALOG_LISTHOUSEDESCRIPTION:
  545. {
  546. switch(response)
  547. {
  548. case false: return ShowMainListingDialog(playerid);
  549. case true:
  550. {
  551. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
  552. if(PlayerInfo[playerid][pADMute] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are muted from advertisements.");
  553. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while injured.");
  554. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings right now.");
  555. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while in jail.");
  556. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be at least level 3 to access house listings.");
  557. if(GetPlayerCash(playerid) < 500000) return SendClientMessageEx(playerid, COLOR_GREY, "You must have at least $500,000 to place a house listing.");
  558. new houseid;
  559. houseid = GetNearestOwnedHouse(playerid);
  560. if(houseid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not near a house that you own.");
  561. if(HouseInfo[houseid][Listed] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This house is already listed on the house market.");
  562. if(strlen(inputtext) < 1 || strlen(inputtext) > 128)
  563. {
  564. SendClientMessageEx(playerid, COLOR_GREY, "The listing description cannot be under 1 character or over 128 characters.");
  565. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEDESCRIPTION, DIALOG_STYLE_INPUT, "House Listings", "Input the description of your listing below.", "Okay", "Cancel");
  566. return 1;
  567. }
  568. if(strcmp(inputtext, HouseInfo[houseid][ListingDescription], false) == 0)
  569. {
  570. SendClientMessageEx(playerid, COLOR_GREY, "The description you have specified is already set the set description.");
  571. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEDESCRIPTION, DIALOG_STYLE_INPUT, "House Listings", "Input the description of your listing below.", "Okay", "Cancel");
  572. return 1;
  573. }
  574. for(new i = 0; i < strlen(inputtext) - 7; i ++)
  575. {
  576. if(inputtext[i] == '{' && inputtext[i + 7] == '}')
  577. {
  578. strmid(string, inputtext, i + 1, i + 7);
  579. if(ishex(string))
  580. {
  581. strdel(inputtext, i, i + 8);
  582. continue;
  583. }
  584. }
  585. }
  586. strcpy(HouseInfo[houseid][ListingDescription], inputtext, 128);
  587. SaveHouse(houseid);
  588. SendClientMessageEx(playerid, COLOR_WHITE, "You have updated your listing description.");
  589. ShowMainListingDialog(playerid);
  590. return 1;
  591. }
  592. }
  593. return 1;
  594. }
  595. case DIALOG_LISTHOUSEDOORS:
  596. {
  597. switch(response)
  598. {
  599. case false: return ShowMainListingDialog(playerid);
  600. case true:
  601. {
  602. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
  603. if(PlayerInfo[playerid][pADMute] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are muted from advertisements.");
  604. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while injured.");
  605. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings right now.");
  606. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while in jail.");
  607. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be at least level 3 to access house listings.");
  608. if(GetPlayerCash(playerid) < 500000) return SendClientMessageEx(playerid, COLOR_GREY, "You must have at least $500,000 to place a house listing.");
  609. new houseid, doorid;
  610. houseid = GetNearestOwnedHouse(playerid);
  611. if(houseid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not near a house that you own.");
  612. if(HouseInfo[houseid][Listed] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This house is already listed on the house market.");
  613. if(sscanf(inputtext, "d", doorid))
  614. {
  615. SendClientMessageEx(playerid, COLOR_GREY, "The specified door ID must be numerical.");
  616. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEDOORS, DIALOG_STYLE_INPUT, "House Listings", "Input the ID of a door to link it to your listing. Input \"0\" to remove a dynamic door.", "Okay", "Cancel");
  617. return 1;
  618. }
  619. if(doorid < 0 || doorid >= MAX_DDOORS)
  620. {
  621. SendClientMessageEx(playerid, COLOR_GREY, "Invalid door ID specified.");
  622. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEDOORS, DIALOG_STYLE_INPUT, "House Listings", "Input the ID of a door to link it to your listing. Input \"0\" to remove a dynamic door.", "Okay", "Cancel");
  623. return 1;
  624. }
  625. for(new i = 0; i < 5; i ++)
  626. {
  627. if(HouseInfo[houseid][LinkedDoor][i] == doorid && doorid != 0)
  628. {
  629. SendClientMessageEx(playerid, COLOR_GREY, "The specified dynamic door is already linked to your listing.");
  630. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEDOORS, DIALOG_STYLE_INPUT, "House Listings", "Input the ID of a door to link it to your listing. Input \"0\" to remove a dynamic door.", "Okay", "Cancel");
  631. return 1;
  632. }
  633. }
  634. switch(doorid)
  635. {
  636. case 0:
  637. {
  638. if(HouseInfo[houseid][LinkedDoor][HouseMarketTracking[playerid]] == 0)
  639. {
  640. SendClientMessageEx(playerid, COLOR_GREY, "You do not currently have a linked dynamic door in the specified slot.");
  641. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEDOORS, DIALOG_STYLE_INPUT, "House Listings", "Input the ID of a door to link it to your listing. Input \"0\" to remove a dynamic door.", "Okay", "Cancel");
  642. return 1;
  643. }
  644. HouseInfo[houseid][LinkedDoor][HouseMarketTracking[playerid]] = 0;
  645. SaveHouse(houseid);
  646. SendClientMessageEx(playerid, COLOR_WHITE, "You have updated/removed the dynamic door(s) linked to your listing.");
  647. ShowMainListingDialog(playerid);
  648. return 1;
  649. }
  650. default:
  651. {
  652. if(DDoorsInfo[doorid][ddOwner] != GetPlayerSQLId(playerid))
  653. {
  654. SendClientMessageEx(playerid, COLOR_GREY, "You do not own the specified dynamic door.");
  655. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEDOORS, DIALOG_STYLE_INPUT, "House Listings", "Input the ID of a door to link it to your listing. Input \"0\" to remove a dynamic door.", "Okay", "Cancel");
  656. return 1;
  657. }
  658. if(HouseInfo[houseid][hIntIW] != DDoorsInfo[doorid][ddInteriorInt] || HouseInfo[houseid][hIntVW] != DDoorsInfo[doorid][ddInteriorVW])
  659. {
  660. SendClientMessageEx(playerid, COLOR_GREY, "The specified dynamic door is not linked to your house.");
  661. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEDOORS, DIALOG_STYLE_INPUT, "House Listings", "Input the ID of a door to link it to your listing. Input \"0\" to remove a dynamic door.", "Okay", "Cancel");
  662. return 1;
  663. }
  664. HouseInfo[houseid][LinkedDoor][HouseMarketTracking[playerid]] = doorid;
  665. SaveHouse(houseid);
  666. SendClientMessageEx(playerid, COLOR_WHITE, "You have updated the dynamic door(s) linked to your listing.");
  667. ShowMainListingDialog(playerid);
  668. return 1;
  669. }
  670. }
  671. return 1;
  672. }
  673. }
  674. return 1;
  675. }
  676. case DIALOG_LISTHOUSEGARAGES:
  677. {
  678. switch(response)
  679. {
  680. case false: return ShowMainListingDialog(playerid);
  681. case true:
  682. {
  683. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
  684. if(PlayerInfo[playerid][pADMute] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are muted from advertisements.");
  685. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while injured.");
  686. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings right now.");
  687. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while in jail.");
  688. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be at least level 3 to access house listings.");
  689. if(GetPlayerCash(playerid) < 500000) return SendClientMessageEx(playerid, COLOR_GREY, "You must have at least $500,000 to place a house listing.");
  690. new houseid, garageid;
  691. houseid = GetNearestOwnedHouse(playerid);
  692. if(houseid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not near a house that you own.");
  693. if(HouseInfo[houseid][Listed] == 1) return SendClientMessageEx(playerid, COLOR_GREY, "This house is already listed on the house market.");
  694. if(sscanf(inputtext, "d", garageid))
  695. {
  696. SendClientMessageEx(playerid, COLOR_GREY, "The specified garage ID must be numerical.");
  697. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEGARAGES, DIALOG_STYLE_INPUT, "House Listings", "Input the ID of a garage to link it to your listing. Input \"0\" to remove a garage..", "Okay", "Cancel");
  698. return 1;
  699. }
  700. if(garageid < 0 || garageid >= MAX_GARAGES)
  701. {
  702. SendClientMessageEx(playerid, COLOR_GREY, "Invalid garage ID specified.");
  703. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEGARAGES, DIALOG_STYLE_INPUT, "House Listings", "Input the ID of a garage to link it to your listing. Input \"0\" to remove a garage..", "Okay", "Cancel");
  704. return 1;
  705. }
  706. for(new i = 0; i < 2; i ++)
  707. {
  708. if(HouseInfo[houseid][LinkedGarage][i] == garageid && garageid != 0)
  709. {
  710. SendClientMessageEx(playerid, COLOR_GREY, "The specified garage is already linked to your listing.");
  711. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEGARAGES, DIALOG_STYLE_INPUT, "House Listings", "Input the ID of a garage to link it to your listing. Input \"0\" to remove a garage..", "Okay", "Cancel");
  712. return 1;
  713. }
  714. }
  715. switch(garageid)
  716. {
  717. case 0:
  718. {
  719. if(HouseInfo[houseid][LinkedGarage][HouseMarketTracking[playerid]] == 0)
  720. {
  721. SendClientMessageEx(playerid, COLOR_GREY, "You do not currently have a linked garage in the specified slot.");
  722. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEGARAGES, DIALOG_STYLE_INPUT, "House Listings", "Input the ID of a garage to link it to your listing. Input \"0\" to remove a garage..", "Okay", "Cancel");
  723. return 1;
  724. }
  725. HouseInfo[houseid][LinkedGarage][HouseMarketTracking[playerid]] = 0;
  726. SaveHouse(houseid);
  727. SendClientMessageEx(playerid, COLOR_WHITE, "You have updated/removed the gate(s) linked to your listing.");
  728. ShowMainListingDialog(playerid);
  729. return 1;
  730. }
  731. default:
  732. {
  733. if(DDoorsInfo[garageid][ddOwner] != GetPlayerSQLId(playerid))
  734. {
  735. SendClientMessageEx(playerid, COLOR_GREY, "You do not own the specified garage.");
  736. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSEGARAGES, DIALOG_STYLE_INPUT, "House Listings", "Input the ID of a garage to link it to your listing. Input \"0\" to remove a garage..", "Okay", "Cancel");
  737. return 1;
  738. }
  739. HouseInfo[houseid][LinkedGarage][HouseMarketTracking[playerid]] = garageid;
  740. SaveHouse(houseid);
  741. SendClientMessageEx(playerid, COLOR_WHITE, "You have updated the garage(s) linked to your listing.");
  742. ShowMainListingDialog(playerid);
  743. return 1;
  744. }
  745. }
  746. return 1;
  747. }
  748. }
  749. return 1;
  750. }
  751. case DIALOG_LISTHOUSELISTINGS:
  752. {
  753. if(response)
  754. {
  755. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
  756. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while injured.");
  757. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings right now.");
  758. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while in jail.");
  759. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be at least level 3 to access house listings.");
  760. szMiscArray[0] = 0;
  761. new houseid, position[2], count[4], location[MAX_ZONE_NAME];
  762. if(strcmp(inputtext, "[Next Page...]", true) == 0)
  763. {
  764. for(new i = AdTracking[playerid] + 1; i < sizeof(HouseInfo); i ++)
  765. {
  766. if(HouseInfo[i][hOwned] == 1 && HouseInfo[i][Listed] == 1 && HouseInfo[i][PendingApproval] == 0)
  767. {
  768. location = "San Andreas";
  769. for(new l = 1; l < sizeof(count); l ++) count[l] = 0;
  770. for(new l = 0; l < 5; l ++)
  771. {
  772. if(l < 2) if(HouseInfo[i][LinkedGarage][l] != 0) count[3] ++;
  773. if(HouseInfo[i][LinkedDoor][l] != 0) count[1] ++;
  774. }
  775. for(new l = 0; l < sizeof(GateInfo); l ++) if(GateInfo[l][gHID] == i) count[2] ++;
  776. Get3DZone(HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ], location, sizeof(location));
  777. format(szMiscArray, sizeof(szMiscArray), "%s\n(%d) [$%s] [%s] [%d DD(s)] [%d DG(s)] [%d G(s)]", szMiscArray, i, number_format(HouseInfo[i][ListingPrice]), location, count[1], count[2], count[3]);
  778. AdTracking[playerid] = i;
  779. count[0] ++;
  780. }
  781. if(count[0] == MAX_LISTINGS_PER_PAGE) break;
  782. }
  783. if(count[0] == 0) return SendClientMessage(playerid, COLOR_GREY, "There are no active advertisements at this time.");
  784. if(count[0] == MAX_LISTINGS_PER_PAGE && AdditionalAdvertisements(AdTracking[playerid] + 1)) strcat(szMiscArray, "\n[Next Page...]");
  785. ShowPlayerDialogEx(playerid, DIALOG_LISTHOUSELISTINGS, DIALOG_STYLE_LIST, "House Listings", szMiscArray, "Okay", "Cancel");
  786. return 1;
  787. }
  788. position[0] = strfind(inputtext, "(");
  789. position[1] = strfind(inputtext, ")");
  790. strmid(string, inputtext, position[0] + 1, position[1]);
  791. houseid = strval(string);
  792. if(HouseInfo[houseid][hOwned] == 0 || HouseInfo[houseid][Listed] == 0 || HouseInfo[houseid][PendingApproval] == 1)
  793. {
  794. SendClientMessageEx(playerid, COLOR_GREY, "The specified house is not currently for sale.");
  795. cmd_houselistings(playerid, "");
  796. return 1;
  797. }
  798. HouseMarketTracking[playerid] = houseid;
  799. ShowListingInformation(playerid, houseid, DIALOG_SELECTEDLISTING);
  800. return 1;
  801. }
  802. }
  803. case DIALOG_SELECTEDLISTING:
  804. {
  805. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
  806. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while injured.");
  807. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings right now.");
  808. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while in jail.");
  809. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be at least level 3 to access house listings.");
  810. switch(response)
  811. {
  812. case false: return cmd_houselistings(playerid, "");
  813. case true:
  814. {
  815. if(HouseInfo[HouseMarketTracking[playerid]][hOwned] == 0 || HouseInfo[HouseMarketTracking[playerid]][Listed] == 0 || HouseInfo[HouseMarketTracking[playerid]][PendingApproval] == 1)
  816. {
  817. SendClientMessageEx(playerid, COLOR_GREY, "The specified house is not currently for sale.");
  818. cmd_houselistings(playerid, "");
  819. return 1;
  820. }
  821. ShowPlayerDialogEx(playerid, DIALOG_LISTINGOPTIONS, DIALOG_STYLE_LIST, "House Listings", "Visit House\nPurchase House", "Okay", "Cancel");
  822. return 1;
  823. }
  824. }
  825. return 1;
  826. }
  827. case DIALOG_LISTINGOPTIONS:
  828. {
  829. if(gPlayerLogged{playerid} == 0) return SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
  830. if(GetPVarType(playerid, "Injured")) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while injured.");
  831. if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings right now.");
  832. if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't use house listings while in jail.");
  833. if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessageEx(playerid, COLOR_GREY, "You must be at least level 3 to access house listings.");
  834. if(HouseInfo[HouseMarketTracking[playerid]][hOwned] == 0 || HouseInfo[HouseMarketTracking[playerid]][Listed] == 0 || HouseInfo[HouseMarketTracking[playerid]][PendingApproval] == 1)
  835. {
  836. SendClientMessageEx(playerid, COLOR_GREY, "The specified house is not currently for sale.");
  837. cmd_houselistings(playerid, "");
  838. return 1;
  839. }
  840. switch(response)
  841. {
  842. case false: return ShowListingInformation(playerid, HouseMarketTracking[playerid], DIALOG_SELECTEDLISTING);
  843. case true:
  844. {
  845. switch(listitem)
  846. {
  847. case 0:
  848. {
  849. if(GetPlayerSQLId(playerid) == HouseInfo[HouseMarketTracking[playerid]][hOwnerID])
  850. {
  851. SendClientMessageEx(playerid, COLOR_GREY, "You cannot visit your own house through house listings, use (/home).");
  852. ShowPlayerDialogEx(playerid, DIALOG_LISTINGOPTIONS, DIALOG_STYLE_LIST, "House Listings", "Visit House\nPurchase House", "Okay", "Cancel");
  853. return 1;
  854. }
  855. if(HouseInfo[HouseMarketTracking[playerid]][hExtIW] != 0 || HouseInfo[HouseMarketTracking[playerid]][hExtVW] != 0)
  856. {
  857. SendClientMessageEx(playerid, COLOR_GREY, "The specified house's entry point is not outside. Contact the owner to visit it.");
  858. ShowPlayerDialogEx(playerid, DIALOG_LISTINGOPTIONS, DIALOG_STYLE_LIST, "House Listings", "Visit House\nPurchase House", "Okay", "Cancel");
  859. return 1;
  860. }
  861. DisablePlayerCheckpoint(playerid);
  862. SetPlayerCheckpoint(playerid, HouseInfo[HouseMarketTracking[playerid]][hExteriorX], HouseInfo[HouseMarketTracking[playerid]][hExteriorY], HouseInfo[HouseMarketTracking[playerid]][hExteriorZ], 4.0);
  863. gPlayerCheckpointStatus[playerid] = CHECKPOINT_HOME;
  864. hInviteHouse[playerid] = HouseMarketTracking[playerid];
  865. SendClientMessageEx(playerid, COLOR_WHITE, "A checkpoint has been set to the specified house.");
  866. return 1;
  867. }
  868. case 1:
  869. {
  870. if(GetPlayerSQLId(playerid) == HouseInfo[HouseMarketTracking[playerid]][hOwnerID])
  871. {
  872. SendClientMessageEx(playerid, COLOR_GREY, "You cannot purchase your own house.");
  873. ShowPlayerDialogEx(playerid, DIALOG_LISTINGOPTIONS, DIALOG_STYLE_LIST, "House Listings", "Visit House\nPurchase House", "Okay", "Cancel");
  874. return 1;
  875. }
  876. if(Homes[playerid] >= MAX_OWNABLE_HOUSES)
  877. {
  878. SendClientMessageEx(playerid, COLOR_GREY, "You cannot own any more houses.");
  879. ShowPlayerDialogEx(playerid, DIALOG_LISTINGOPTIONS, DIALOG_STYLE_LIST, "House Listings", "Visit House\nPurchase House", "Okay", "Cancel");
  880. return 1;
  881. }
  882. if(GetPlayerCash(playerid) < HouseInfo[HouseMarketTracking[playerid]][ListingPrice])
  883. {
  884. format(string, sizeof(string), "You cannot afford this $%s house.", number_format(HouseInfo[HouseMarketTracking[playerid]][ListingPrice]));
  885. SendClientMessageEx(playerid, COLOR_GREY, string);
  886. ShowPlayerDialogEx(playerid, DIALOG_LISTINGOPTIONS, DIALOG_STYLE_LIST, "House Listings", "Visit House\nPurchase House", "Okay", "Cancel");
  887. return 1;
  888. }
  889. new name[24], bool:online;
  890. foreach(new i: Player)
  891. {
  892. if(gPlayerLogged{i} == 1 && HouseInfo[HouseMarketTracking[playerid]][hOwnerID] == GetPlayerSQLId(i))
  893. {
  894. GivePlayerCashEx(i, TYPE_BANK, HouseInfo[HouseMarketTracking[playerid]][ListingPrice]);
  895. format(string, sizeof(string), "%s purchased your house (house ID: %d) for $%s.", GetPlayerNameEx(playerid), HouseMarketTracking[playerid], number_format(HouseInfo[HouseMarketTracking[playerid]][ListingPrice]));
  896. SendClientMessageEx(i, COLOR_GREEN, string);
  897. online = true;
  898. break;
  899. }
  900. }
  901. if(online == false)
  902. {
  903. szMiscArray[0] = 0;
  904. mysql_escape_string(HouseInfo[HouseMarketTracking[playerid]][hOwnerName], name);
  905. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "UPDATE `accounts` SET `Bank`=`Bank`+%d WHERE `Username`='%s'", HouseInfo[HouseMarketTracking[playerid]][ListingPrice], name);
  906. mysql_tquery(MainPipeline, szMiscArray, "", "i", playerid);
  907. format(string, sizeof(string), "I purchased your house (ID: %d) for $%s.", HouseMarketTracking[playerid], number_format(HouseInfo[HouseMarketTracking[playerid]][ListingPrice]));
  908. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "INSERT INTO `letters` (`Sender_Id`, `Receiver_Id`, `Date`, `Message`, `Delivery_Min`, `Notify`) VALUES (%d, %d, NOW(), '%e', 0, 1)", GetPlayerSQLId(playerid), HouseInfo[HouseMarketTracking[playerid]][hOwnerID], string);
  909. mysql_tquery(MainPipeline, szMiscArray, "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  910. }
  911. format(string, sizeof(string), "You have purchased house ID %d for $%s.", HouseMarketTracking[playerid], number_format(HouseInfo[HouseMarketTracking[playerid]][ListingPrice]));
  912. SendClientMessageEx(playerid, COLOR_GREEN, string);
  913. Homes[playerid] ++;
  914. GivePlayerCashEx(playerid, TYPE_ONHAND, -HouseInfo[HouseMarketTracking[playerid]][ListingPrice]);
  915. for(new i = 0; i < 5; i ++)
  916. {
  917. if(i < 2)
  918. {
  919. if(HouseInfo[HouseMarketTracking[playerid]][LinkedGarage][i] != 0 && HouseInfo[HouseMarketTracking[playerid]][hOwnerID] == GarageInfo[HouseInfo[HouseMarketTracking[playerid]][LinkedGarage][i]][gar_Owner])
  920. {
  921. strcpy(GarageInfo[HouseInfo[HouseMarketTracking[playerid]][LinkedGarage][i]][gar_OwnerName], GetPlayerNameEx(playerid), MAX_PLAYER_NAME);
  922. GarageInfo[HouseInfo[HouseMarketTracking[playerid]][LinkedGarage][i]][gar_Owner] = GetPlayerSQLId(playerid);
  923. CreateGarage(HouseInfo[HouseMarketTracking[playerid]][LinkedGarage][i]);
  924. SaveGarage(HouseInfo[HouseMarketTracking[playerid]][LinkedGarage][i]);
  925. }
  926. }
  927. if(HouseInfo[HouseMarketTracking[playerid]][LinkedDoor][i] != 0 && HouseInfo[HouseMarketTracking[playerid]][hOwnerID] == DDoorsInfo[HouseInfo[HouseMarketTracking[playerid]][LinkedDoor][i]][ddOwner])
  928. {
  929. strcpy(DDoorsInfo[HouseInfo[HouseMarketTracking[playerid]][LinkedDoor][i]][ddOwnerName], GetPlayerNameEx(playerid), MAX_PLAYER_NAME);
  930. DDoorsInfo[HouseInfo[HouseMarketTracking[playerid]][LinkedDoor][i]][ddOwner] = GetPlayerSQLId(playerid);
  931. DestroyDynamicPickup(DDoorsInfo[HouseInfo[HouseMarketTracking[playerid]][LinkedDoor][i]][ddPickupID]);
  932. if(IsValidDynamic3DTextLabel(DDoorsInfo[HouseInfo[HouseMarketTracking[playerid]][LinkedDoor][i]][ddTextID])) DestroyDynamic3DTextLabel(DDoorsInfo[HouseInfo[HouseMarketTracking[playerid]][LinkedDoor][i]][ddTextID]);
  933. CreateDynamicDoor(HouseInfo[HouseMarketTracking[playerid]][LinkedDoor][i]);
  934. SaveDynamicDoor(HouseInfo[HouseMarketTracking[playerid]][LinkedDoor][i]);
  935. }
  936. }
  937. if(PlayerInfo[playerid][pPhousekey] == INVALID_HOUSE_ID) PlayerInfo[playerid][pPhousekey] = HouseMarketTracking[playerid];
  938. else PlayerInfo[playerid][pPhousekey2] = HouseMarketTracking[playerid];
  939. HouseInfo[HouseMarketTracking[playerid]][hOwnerID] = GetPlayerSQLId(playerid);
  940. strcpy(HouseInfo[HouseMarketTracking[playerid]][hOwnerName], GetPlayerNameEx(playerid), MAX_PLAYER_NAME);
  941. ReloadHouseText(HouseMarketTracking[playerid]);
  942. ClearHouseSaleVariables(HouseMarketTracking[playerid]);
  943. return 1;
  944. }
  945. }
  946. }
  947. }
  948. return 1;
  949. }
  950. }
  951. return 0;
  952. }