1
0

houses.pwn 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Dynamic Housing System
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #include <YSI\y_hooks>
  34. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  35. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  36. if(dialogid == DIALOG_HOUSEINVITE)
  37. {
  38. if(response)
  39. {
  40. if(IsPlayerConnected(hInviteOfferTo[playerid]))
  41. {
  42. new j = 0, zone[MAX_ZONE_NAME];
  43. for(new i; i < MAX_HOUSES; i++)
  44. {
  45. if(GetPlayerSQLId(playerid) == HouseInfo[i][hOwnerID])
  46. {
  47. if(listitem == j)
  48. {
  49. Get3DZone(HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ], zone, MAX_ZONE_NAME);
  50. SetPVarInt(playerid, "LastHouseInvite", gettime());
  51. new istring[128];
  52. hInviteHouse[hInviteOfferTo[playerid]] = i;
  53. hInviteOffer[hInviteOfferTo[playerid]] = playerid;
  54. format(istring, sizeof(istring), " %s has invited you to their house in %s (type /accept invite).", GetPlayerNameEx(playerid), zone);
  55. SendClientMessageEx(hInviteOfferTo[playerid], COLOR_LIGHTBLUE, istring);
  56. format(istring, sizeof(istring), " You have invited %s to your house in %s.", GetPlayerNameEx(hInviteOfferTo[playerid]), zone);
  57. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, istring);
  58. return 1;
  59. }
  60. j++;
  61. }
  62. }
  63. }
  64. else
  65. {
  66. hInviteOfferTo[playerid] = INVALID_PLAYER_ID;
  67. SendClientMessageEx(playerid, COLOR_GRAD2, "The player you attempted to invite to you house disconnected or timed out.");
  68. }
  69. }
  70. }
  71. return 0;
  72. }
  73. stock SaveHouse(houseid) {
  74. szMiscArray[0] = 0;
  75. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "UPDATE `houses` SET \
  76. `Owned`=%d, \
  77. `Level`=%d, \
  78. `Description`='%s', \
  79. `OwnerID`=%d, \
  80. `ExteriorX`=%f, \
  81. `ExteriorY`=%f, \
  82. `ExteriorZ`=%f, \
  83. `ExteriorR`=%f, \
  84. `InteriorX`=%f, \
  85. `InteriorY`=%f, \
  86. `InteriorZ`=%f, \
  87. `InteriorR`=%f, \
  88. `ExtIW`=%d, \
  89. `ExtVW`=%d, \
  90. `IntIW`=%d, \
  91. `IntVW`=%d \
  92. WHERE `id` =%d",
  93. HouseInfo[houseid][hOwned],
  94. HouseInfo[houseid][hLevel],
  95. g_mysql_ReturnEscaped(HouseInfo[houseid][hDescription]),
  96. HouseInfo[houseid][hOwnerID],
  97. HouseInfo[houseid][hExteriorX],
  98. HouseInfo[houseid][hExteriorY],
  99. HouseInfo[houseid][hExteriorZ],
  100. HouseInfo[houseid][hExteriorR],
  101. HouseInfo[houseid][hInteriorX],
  102. HouseInfo[houseid][hInteriorY],
  103. HouseInfo[houseid][hInteriorZ],
  104. HouseInfo[houseid][hInteriorR],
  105. HouseInfo[houseid][hExtIW],
  106. HouseInfo[houseid][hExtVW],
  107. HouseInfo[houseid][hIntIW],
  108. HouseInfo[houseid][hIntVW],
  109. houseid+1
  110. );
  111. mysql_tquery(MainPipeline, szMiscArray, "OnSaveHouse", "ii", houseid, 0);
  112. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "UPDATE `houses` SET \
  113. `Lock`=%d, \
  114. `Rentable`=%d, \
  115. `RentFee`=%d, \
  116. `Value`=%d, \
  117. `SafeMoney`=%d, \
  118. `Pot`=%d, \
  119. `Crack`=%d, \
  120. `Materials`=%d, \
  121. `Heroin`=%d, \
  122. `Meth`=%d, \
  123. `Ecstasy`=%d, \
  124. `Weapons0`=%d, \
  125. `Weapons1`=%d, \
  126. `Weapons2`=%d, \
  127. `Weapons3`=%d, \
  128. `GLUpgrade`=%d, \
  129. `CustomInterior`=%d, \
  130. `CustomExterior`=%d, \
  131. `ExteriorA`=%f, \
  132. `InteriorA`=%f, \
  133. `MailX`=%f, \
  134. `MailY`=%f, \
  135. `MailZ`=%f, \
  136. `MailA`=%f, \
  137. `MailType`=%d, \
  138. `ClosetX`=%f, \
  139. `ClosetY`=%f, \
  140. `ClosetZ`=%f \
  141. WHERE `id` =%d",
  142. HouseInfo[houseid][hLock],
  143. HouseInfo[houseid][hRentable],
  144. HouseInfo[houseid][hRentFee],
  145. HouseInfo[houseid][hValue],
  146. HouseInfo[houseid][hSafeMoney],
  147. HouseInfo[houseid][hPot],
  148. HouseInfo[houseid][hCrack],
  149. HouseInfo[houseid][hMaterials],
  150. HouseInfo[houseid][hHeroin],
  151. HouseInfo[houseid][hMeth],
  152. HouseInfo[houseid][hEcstasy],
  153. HouseInfo[houseid][hWeapons][0],
  154. HouseInfo[houseid][hWeapons][1],
  155. HouseInfo[houseid][hWeapons][2],
  156. HouseInfo[houseid][hWeapons][3],
  157. //HouseInfo[houseid][hWeapons][4],
  158. HouseInfo[houseid][hGLUpgrade],
  159. HouseInfo[houseid][hCustomInterior],
  160. HouseInfo[houseid][hCustomExterior],
  161. HouseInfo[houseid][hExteriorA],
  162. HouseInfo[houseid][hInteriorA],
  163. HouseInfo[houseid][hMailX],
  164. HouseInfo[houseid][hMailY],
  165. HouseInfo[houseid][hMailZ],
  166. HouseInfo[houseid][hMailA],
  167. HouseInfo[houseid][hMailType],
  168. HouseInfo[houseid][hClosetX],
  169. HouseInfo[houseid][hClosetY],
  170. HouseInfo[houseid][hClosetZ],
  171. houseid+1
  172. );
  173. mysql_tquery(MainPipeline, szMiscArray, "OnSaveHouse", "ii", houseid, 1);
  174. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "UPDATE `houses` SET \
  175. `SignDesc`='%s', \
  176. `SignX`=%f, \
  177. `SignY`=%f, \
  178. `SignZ`=%f, \
  179. `SignA`=%f, \
  180. `SignExpire`=%d, \
  181. `LastLogin`=%d, \
  182. `Expire`=%d, \
  183. `Inactive`=%d, \
  184. `Ignore`=%d, \
  185. `Counter`=%d \
  186. WHERE `id` =%d",
  187. g_mysql_ReturnEscaped(HouseInfo[houseid][hSignDesc]),
  188. HouseInfo[houseid][hSign][0],
  189. HouseInfo[houseid][hSign][1],
  190. HouseInfo[houseid][hSign][2],
  191. HouseInfo[houseid][hSign][3],
  192. HouseInfo[houseid][hSignExpire],
  193. HouseInfo[houseid][hLastLogin],
  194. HouseInfo[houseid][hExpire],
  195. HouseInfo[houseid][hInactive],
  196. HouseInfo[houseid][hIgnore],
  197. HouseInfo[houseid][hCounter],
  198. houseid+1
  199. );
  200. mysql_tquery(MainPipeline, szMiscArray, "OnSaveHouse", "ii", houseid, 2);
  201. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "UPDATE `houses` SET \
  202. `Listed`=%d, \
  203. `PendingApproval`=%d, \
  204. `ListedTimeStamp`=%d, \
  205. `ListingPrice`=%d, \
  206. `LinkedDoor0`=%d, \
  207. `LinkedDoor1`=%d, \
  208. `LinkedDoor2`=%d, \
  209. `LinkedDoor3`=%d, \
  210. `LinkedDoor4`=%d, \
  211. `ListingDescription`='%s', \
  212. `LinkedGarage0`=%d, \
  213. `LinkedGarage1`=%d, \
  214. `Lights`=%d \
  215. WHERE `id`=%d",
  216. HouseInfo[houseid][Listed],
  217. HouseInfo[houseid][PendingApproval],
  218. HouseInfo[houseid][ListedTimeStamp],
  219. HouseInfo[houseid][ListingPrice],
  220. HouseInfo[houseid][LinkedDoor][0],
  221. HouseInfo[houseid][LinkedDoor][1],
  222. HouseInfo[houseid][LinkedDoor][2],
  223. HouseInfo[houseid][LinkedDoor][3],
  224. HouseInfo[houseid][LinkedDoor][4],
  225. HouseInfo[houseid][ListingDescription],
  226. HouseInfo[houseid][LinkedGarage][0],
  227. HouseInfo[houseid][LinkedGarage][1],
  228. HouseInfo[houseid][h_iLights],
  229. houseid+1
  230. ); // Array starts from zero, MySQL starts at 1 (this is why we are adding one).
  231. mysql_tquery(MainPipeline, szMiscArray, "OnSaveHouse", "ii", houseid, 3);
  232. }
  233. forward OnSaveHouse(i, thread);
  234. public OnSaveHouse(i, thread) {
  235. if(mysql_errno(MainPipeline)) printf("Error saving HouseID %d (Thread: %d)", i, thread);
  236. printf("Successfully saved HouseID %d (Thread: %d)", i, thread);
  237. return 1;
  238. }
  239. stock LoadHouse(houseid)
  240. {
  241. new string[128];
  242. //printf("[LoadHouse] Loading HouseID %d's data from database...", houseid);
  243. mysql_format(MainPipeline, string, sizeof(string), "SELECT OwnerName.Username, h.* FROM houses h LEFT JOIN accounts OwnerName ON h.OwnerID = OwnerName.id WHERE h.id = %d", houseid+1); // Array starts at zero, MySQL starts at one.
  244. mysql_tquery(MainPipeline, string, "OnLoadHouse", "i", houseid);
  245. }
  246. stock LoadHouses()
  247. {
  248. printf("[LoadHouses] Loading data from database...");
  249. mysql_tquery(MainPipeline, "SELECT OwnerName.Username, h.* FROM houses h LEFT JOIN accounts OwnerName ON h.OwnerID = OwnerName.id", "OnLoadHouses", "");
  250. }
  251. forward OnLoadHouse(index);
  252. public OnLoadHouse(index)
  253. {
  254. new rows, szField[24];
  255. szMiscArray[0] = 0;
  256. cache_get_row_count(rows);
  257. for(new row; row < rows; row++)
  258. {
  259. cache_get_value_name_int(row, "id", HouseInfo[index][hSQLId]);
  260. cache_get_value_name_int(row, "Owned", HouseInfo[index][hOwned]);
  261. cache_get_value_name_int(row, "Level", HouseInfo[index][hLevel]);
  262. cache_get_value_name(row, "Description", HouseInfo[index][hDescription], 16);
  263. cache_get_value_name_int(row, "OwnerID", HouseInfo[index][hOwnerID]);
  264. cache_get_value_name(row, "Username", HouseInfo[index][hOwnerName], MAX_PLAYER_NAME);
  265. cache_get_value_name_float(row, "ExteriorX", HouseInfo[index][hExteriorX]);
  266. cache_get_value_name_float(row, "ExteriorY", HouseInfo[index][hExteriorY]);
  267. cache_get_value_name_float(row, "ExteriorZ", HouseInfo[index][hExteriorZ]);
  268. cache_get_value_name_float(row, "ExteriorR", HouseInfo[index][hExteriorR]);
  269. cache_get_value_name_float(row, "ExteriorA", HouseInfo[index][hExteriorA]);
  270. cache_get_value_name_int(row, "CustomExterior", HouseInfo[index][hCustomExterior]);
  271. cache_get_value_name_float(row, "InteriorX", HouseInfo[index][hInteriorX]);
  272. cache_get_value_name_float(row, "InteriorY", HouseInfo[index][hInteriorY]);
  273. cache_get_value_name_float(row, "InteriorZ", HouseInfo[index][hInteriorZ]);
  274. cache_get_value_name_float(row, "InteriorR", HouseInfo[index][hInteriorR]);
  275. cache_get_value_name_float(row, "InteriorA", HouseInfo[index][hInteriorA]);
  276. cache_get_value_name_int(row, "CustomInterior", HouseInfo[index][hCustomInterior]);
  277. cache_get_value_name_int(row, "ExtIW", HouseInfo[index][hExtIW]);
  278. cache_get_value_name_int(row, "ExtVW", HouseInfo[index][hExtVW]);
  279. cache_get_value_name_int(row, "IntIW", HouseInfo[index][hIntIW]);
  280. cache_get_value_name_int(row, "IntVW", HouseInfo[index][hIntVW]);
  281. cache_get_value_name_int(row, "Lock", HouseInfo[index][hLock]);
  282. cache_get_value_name_int(row, "Rentable", HouseInfo[index][hRentable]);
  283. cache_get_value_name_int(row, "RentFee", HouseInfo[index][hRentFee]);
  284. cache_get_value_name_int(row, "Value", HouseInfo[index][hValue]);
  285. cache_get_value_name_int(row, "SafeMoney", HouseInfo[index][hSafeMoney]);
  286. cache_get_value_name_int(row, "Pot", HouseInfo[index][hPot]);
  287. cache_get_value_name_int(row, "Crack", HouseInfo[index][hCrack]);
  288. cache_get_value_name_int(row, "Materials", HouseInfo[index][hMaterials]);
  289. cache_get_value_name_int(row, "Heroin", HouseInfo[index][hHeroin]);
  290. cache_get_value_name_int(row, "Meth", HouseInfo[index][hMeth]);
  291. cache_get_value_name_int(row, "Ecstasy", HouseInfo[index][hEcstasy]);
  292. for(new i; i < 5; i++)
  293. {
  294. format(szField, sizeof(szField), "Weapons%d", i);
  295. cache_get_value_name_int(row, szField, HouseInfo[index][hWeapons][i]);
  296. }
  297. cache_get_value_name_int(row, "GLUpgrade", HouseInfo[index][hGLUpgrade]);
  298. cache_get_value_name_int(row, "PickupID", HouseInfo[index][hPickupID]);
  299. cache_get_value_name_float(row, "MailX", HouseInfo[index][hMailX]);
  300. cache_get_value_name_float(row, "MailY", HouseInfo[index][hMailY]);
  301. cache_get_value_name_float(row, "MailZ", HouseInfo[index][hMailZ]);
  302. cache_get_value_name_float(row, "MailA", HouseInfo[index][hMailA]);
  303. cache_get_value_name_int(row, "MailType", HouseInfo[index][hMailType]);
  304. cache_get_value_name_float(row, "ClosetX", HouseInfo[index][hClosetX]);
  305. cache_get_value_name_float(row, "ClosetY", HouseInfo[index][hClosetY]);
  306. cache_get_value_name_float(row, "ClosetZ", HouseInfo[index][hClosetZ]);
  307. cache_get_value_name(row, "SignDesc", HouseInfo[index][hSignDesc], 64);
  308. cache_get_value_name_float(row, "SignX", HouseInfo[index][hSign][0]);
  309. cache_get_value_name_float(row, "SignY", HouseInfo[index][hSign][1]);
  310. cache_get_value_name_float(row, "SignZ", HouseInfo[index][hSign][2]);
  311. cache_get_value_name_float(row, "SignA", HouseInfo[index][hSign][3]);
  312. cache_get_value_name_int(row, "SignExpire", HouseInfo[index][hSignExpire]);
  313. cache_get_value_name_int(row, "LastLogin", HouseInfo[index][hLastLogin]);
  314. cache_get_value_name_int(row, "Expire", HouseInfo[index][hExpire]);
  315. cache_get_value_name_int(row, "Inactive", HouseInfo[index][hInactive]);
  316. cache_get_value_name_int(row, "Ignore", HouseInfo[index][hIgnore]);
  317. cache_get_value_name_int(row, "Counter", HouseInfo[index][hCounter]);
  318. cache_get_value_name_int(row, "Listed", HouseInfo[index][Listed]);
  319. cache_get_value_name_int(row, "PendingApproval", HouseInfo[index][PendingApproval]);
  320. cache_get_value_name_int(row, "ListedTimeStamp", HouseInfo[index][ListedTimeStamp]);
  321. cache_get_value_name_int(row, "ListingPrice", HouseInfo[index][ListingPrice]);
  322. cache_get_value_name(row, "ListingDescription", HouseInfo[index][ListingDescription], 128);
  323. for(new i = 0; i < 5; i ++)
  324. {
  325. format(szField, sizeof(szField), "LinkedDoor%d", i);
  326. cache_get_value_name_int(row, szField, HouseInfo[index][LinkedDoor][i]);
  327. }
  328. cache_get_value_name_int(row, "LinkedGarage0", HouseInfo[index][LinkedGarage][0]);
  329. cache_get_value_name_int(row, "LinkedGarage1", HouseInfo[index][LinkedGarage][1]);
  330. cache_get_value_name_int(row, "Lights", HouseInfo[index][h_iLights]);
  331. if(HouseInfo[index][hExteriorX] != 0.0) ReloadHousePickup(index);
  332. if(HouseInfo[index][hClosetX] != 0.0) HouseInfo[index][hClosetTextID] = CreateDynamic3DTextLabel("Closet\n/closet to use", 0xFFFFFF88, HouseInfo[index][hClosetX], HouseInfo[index][hClosetY], HouseInfo[index][hClosetZ]+0.5,10.0, .testlos = 1, .worldid = HouseInfo[index][hIntVW], .interiorid = HouseInfo[index][hIntIW], .streamdistance = 10.0);
  333. if(HouseInfo[index][hMailX] != 0.0) RenderHouseMailbox(index);
  334. if(HouseInfo[index][hSignExpire] != 0 && gettime() >= HouseInfo[index][hSignExpire])
  335. {
  336. format(szMiscArray, sizeof(szMiscArray), "[EXPIRE - OnLoad] House Sale Sign Expired - Housed ID: %d", index);
  337. Log("logs/house.log", szMiscArray);
  338. DeleteHouseSaleSign(index);
  339. }
  340. if(HouseInfo[index][hSign][0] != 0.0) CreateHouseSaleSign(index);
  341. }
  342. return 1;
  343. }
  344. forward OnLoadHouses();
  345. public OnLoadHouses()
  346. {
  347. new i, rows;
  348. szMiscArray[0] = 0;
  349. cache_get_row_count(rows);
  350. while(i < rows)
  351. {
  352. /*HouseInfo[i][hSQLId] = cache_get_field_content_int(i, "id", MainPipeline);
  353. HouseInfo[i][hOwned] = cache_get_field_content_int(i, "Owned", MainPipeline);
  354. HouseInfo[i][hLevel] = cache_get_field_content_int(i, "Level", MainPipeline);
  355. cache_get_field_content(i, "Description", HouseInfo[i][hDescription], MainPipeline, 16);
  356. HouseInfo[i][hOwnerID] = cache_get_field_content_int(i, "OwnerID", MainPipeline);
  357. cache_get_field_content(i, "Username", HouseInfo[i][hOwnerName], MainPipeline, MAX_PLAYER_NAME);
  358. HouseInfo[i][hExteriorX] = cache_get_field_content_float(i, "ExteriorX", MainPipeline);
  359. HouseInfo[i][hExteriorY] = cache_get_field_content_float(i, "ExteriorY", MainPipeline);
  360. HouseInfo[i][hExteriorZ] = cache_get_field_content_float(i, "ExteriorZ", MainPipeline);
  361. HouseInfo[i][hExteriorR] = cache_get_field_content_float(i, "ExteriorR", MainPipeline);
  362. HouseInfo[i][hExteriorA] = cache_get_field_content_float(i, "ExteriorA", MainPipeline);
  363. HouseInfo[i][hCustomExterior] = cache_get_field_content_int(i, "CustomExterior", MainPipeline);
  364. HouseInfo[i][hInteriorX] = cache_get_field_content_float(i, "InteriorX", MainPipeline);
  365. HouseInfo[i][hInteriorY] = cache_get_field_content_float(i, "InteriorY", MainPipeline);
  366. HouseInfo[i][hInteriorZ] = cache_get_field_content_float(i, "InteriorZ", MainPipeline);
  367. HouseInfo[i][hInteriorR] = cache_get_field_content_float(i, "InteriorR", MainPipeline);
  368. HouseInfo[i][hInteriorA] = cache_get_field_content_float(i, "InteriorA", MainPipeline);
  369. HouseInfo[i][hCustomInterior] = cache_get_field_content_int(i, "CustomInterior", MainPipeline);
  370. HouseInfo[i][hExtIW] = cache_get_field_content_int(i, "ExtIW", MainPipeline);
  371. HouseInfo[i][hExtVW] = cache_get_field_content_int(i, "ExtVW", MainPipeline);
  372. HouseInfo[i][hIntIW] = cache_get_field_content_int(i, "IntIW", MainPipeline);
  373. HouseInfo[i][hIntVW] = cache_get_field_content_int(i, "IntVW", MainPipeline);
  374. HouseInfo[i][hLock] = cache_get_field_content_int(i, "Lock", MainPipeline);
  375. HouseInfo[i][hRentable] = cache_get_field_content_int(i, "Rentable", MainPipeline);
  376. HouseInfo[i][hRentFee] = cache_get_field_content_int(i, "RentFee", MainPipeline);
  377. HouseInfo[i][hValue] = cache_get_field_content_int(i, "Value", MainPipeline);
  378. HouseInfo[i][hSafeMoney] = cache_get_field_content_int(i, "SafeMoney", MainPipeline);
  379. HouseInfo[i][hPot] = cache_get_field_content_int(i, "Pot", MainPipeline);
  380. HouseInfo[i][hCrack] = cache_get_field_content_int(i, "Crack", MainPipeline);
  381. HouseInfo[i][hMaterials] = cache_get_field_content_int(i, "Materials", MainPipeline);
  382. HouseInfo[i][hHeroin] = cache_get_field_content_int(i, "Heroin", MainPipeline);
  383. for(new j; j < 5; j++)
  384. {
  385. format(szField, sizeof(szField), "Weapons%d", j);
  386. HouseInfo[i][hWeapons][j] = cache_get_field_content_int(i, szField, MainPipeline);
  387. }
  388. HouseInfo[i][hGLUpgrade] = cache_get_field_content_int(i, "GLUpgrade", MainPipeline);
  389. HouseInfo[i][hPickupID] = cache_get_field_content_int(i, "PickupID", MainPipeline);
  390. HouseInfo[i][hMailX] = cache_get_field_content_float(i, "MailX", MainPipeline);
  391. HouseInfo[i][hMailY] = cache_get_field_content_float(i, "MailY", MainPipeline);
  392. HouseInfo[i][hMailZ] = cache_get_field_content_float(i, "MailZ", MainPipeline);
  393. HouseInfo[i][hMailA] = cache_get_field_content_float(i, "MailA", MainPipeline);
  394. HouseInfo[i][hMailType] = cache_get_field_content_int(i, "MailType", MainPipeline);
  395. HouseInfo[i][hClosetX] = cache_get_field_content_float(i, "ClosetX", MainPipeline);
  396. HouseInfo[i][hClosetY] = cache_get_field_content_float(i, "ClosetY", MainPipeline);
  397. HouseInfo[i][hClosetZ] = cache_get_field_content_float(i, "ClosetZ", MainPipeline);
  398. cache_get_field_content(i, "SignDesc", HouseInfo[i][hSignDesc], MainPipeline, 64);
  399. HouseInfo[i][hSign][0] = cache_get_field_content_float(i, "SignX", MainPipeline);
  400. HouseInfo[i][hSign][1] = cache_get_field_content_float(i, "SignY", MainPipeline);
  401. HouseInfo[i][hSign][2] = cache_get_field_content_float(i, "SignZ", MainPipeline);
  402. HouseInfo[i][hSign][3] = cache_get_field_content_float(i, "SignA", MainPipeline);
  403. HouseInfo[i][hSignExpire] = cache_get_field_content_int(i, "SignExpire", MainPipeline);
  404. HouseInfo[i][hLastLogin] = cache_get_field_content_int(i, "LastLogin", MainPipeline);
  405. HouseInfo[i][hExpire] = cache_get_field_content_int(i, "Expire", MainPipeline);
  406. HouseInfo[i][hInactive] = cache_get_field_content_int(i, "Inactive", MainPipeline);
  407. HouseInfo[i][hIgnore] = cache_get_field_content_int(i, "Ignore", MainPipeline);
  408. HouseInfo[i][hCounter] = cache_get_field_content_int(i, "Counter", MainPipeline);
  409. HouseInfo[i][Listed] = cache_get_field_content_int(i, "Listed", MainPipeline);
  410. HouseInfo[i][PendingApproval] = cache_get_field_content_int(i, "PendingApproval", MainPipeline);
  411. HouseInfo[i][ListedTimeStamp] = cache_get_field_content_int(i, "ListedTimeStamp", MainPipeline);
  412. HouseInfo[i][ListingPrice] = cache_get_field_content_int(i, "ListingPrice", MainPipeline);
  413. cache_get_field_content(i, "ListingDescription", HouseInfo[i][ListingDescription], MainPipeline, 128);
  414. for(new l = 0; l < 5; l ++)
  415. {
  416. format(szField, sizeof(szField), "LinkedDoor%d", l);
  417. HouseInfo[i][LinkedDoor][l] = cache_get_field_content_int(i, szField, MainPipeline);
  418. }
  419. HouseInfo[i][LinkedGarage][0] = cache_get_field_content_int(i, "LinkedGarage0", MainPipeline);
  420. HouseInfo[i][LinkedGarage][1] = cache_get_field_content_int(i, "LinkedGarage1", MainPipeline);
  421. if(HouseInfo[i][hExteriorX] != 0.0) ReloadHousePickup(i);
  422. if(HouseInfo[i][hClosetX] != 0.0) HouseInfo[i][hClosetTextID] = CreateDynamic3DTextLabel("Closet\n/closet to use", 0xFFFFFF88, HouseInfo[i][hClosetX], HouseInfo[i][hClosetY], HouseInfo[i][hClosetZ]+0.5,10.0, .testlos = 1, .worldid = HouseInfo[i][hIntVW], .interiorid = HouseInfo[i][hIntIW], .streamdistance = 10.0);
  423. if(HouseInfo[i][hMailX] != 0.0) RenderHouseMailbox(i);
  424. if(HouseInfo[i][hSignExpire] != 0 && gettime() >= HouseInfo[i][hSignExpire])
  425. {
  426. format(szMiscArray, sizeof(szMiscArray), "[EXPIRE - OnLoad] House Sale Sign Expired - Housed ID: %d", i);
  427. Log("logs/house.log", szMiscArray);
  428. DeleteHouseSaleSign(i);
  429. }
  430. if(HouseInfo[i][hSign][0] != 0.0) CreateHouseSaleSign(i);*/
  431. LoadHouse(i);
  432. i++;
  433. }
  434. if(i > 0) printf("[LoadHouses] %d houses rehashed/loaded.", i);
  435. else printf("[LoadHouses] Failed to load any houses.");
  436. }
  437. stock ReloadHouseText(houseid)
  438. {
  439. new string[128];
  440. if(HouseInfo[houseid][hOwned])
  441. {
  442. if(HouseInfo[houseid][hRentable]) format(string, sizeof(string), "This house is owned by\n%s\nRent: $%s\nLevel: %d\nID: %d\nType /rentroom to rent a room", StripUnderscore(HouseInfo[houseid][hOwnerName]), number_format(HouseInfo[houseid][hRentFee]), HouseInfo[houseid][hLevel], houseid);
  443. else format(string, sizeof(string), "This house is owned by\n%s\nLevel: %d\nID: %d", StripUnderscore(HouseInfo[houseid][hOwnerName]), HouseInfo[houseid][hLevel], houseid);
  444. }
  445. else format(string, sizeof(string), "This house is\n for sale!\n Description: %s\nCost: $%s\n Level: %d\nID: %d\nTo buy this house type /buyhouse", HouseInfo[houseid][hDescription], number_format(HouseInfo[houseid][hValue]), HouseInfo[houseid][hLevel], houseid);
  446. UpdateDynamic3DTextLabelText(HouseInfo[houseid][hTextID], HouseInfo[houseid][hInactive] ? COLOR_LIGHTBLUE : COLOR_GREEN, string);
  447. }
  448. stock ReloadHousePickup(houseid)
  449. {
  450. if(IsValidDynamicPickup(HouseInfo[houseid][hPickupID])) DestroyDynamicPickup(HouseInfo[houseid][hPickupID]), HouseInfo[houseid][hPickupID] = -1;
  451. if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hTextID])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hTextID]), HouseInfo[houseid][hTextID] = Text3D:-1;
  452. if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hTextID_int])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hTextID_int]), HouseInfo[houseid][hTextID_int] = Text3D:-1;
  453. if(IsValidDynamicPickup(HouseInfo[houseid][hPickupID_int])) DestroyDynamicPickup(HouseInfo[houseid][hPickupID_int]), HouseInfo[houseid][hPickupID_int] = -1;
  454. if(IsValidDynamicArea(HouseInfo[houseid][hAreaID][0])) DestroyDynamicArea(HouseInfo[houseid][hAreaID][0]), HouseInfo[houseid][hAreaID][0] = -1;
  455. if(IsValidDynamicArea(HouseInfo[houseid][hAreaID][1])) DestroyDynamicArea(HouseInfo[houseid][hAreaID][1]), HouseInfo[houseid][hAreaID][1] = -1;
  456. if(HouseInfo[houseid][hExteriorX] == 0.0) return 1;
  457. new string[128];
  458. if(HouseInfo[houseid][hOwned])
  459. {
  460. if(HouseInfo[houseid][hRentable])
  461. format(string, sizeof(string), "This house is owned by\n%s\nRent: $%s\nLevel: %d\nID: %d\nType /rentroom to rent a room", StripUnderscore(HouseInfo[houseid][hOwnerName]), number_format(HouseInfo[houseid][hRentFee]), HouseInfo[houseid][hLevel], houseid);
  462. else
  463. format(string, sizeof(string), "This house is owned by\n%s\nLevel: %d\nID: %d", StripUnderscore(HouseInfo[houseid][hOwnerName]), HouseInfo[houseid][hLevel], houseid);
  464. }
  465. else
  466. format(string, sizeof(string), "This house is\n for sale!\n Description: %s\nCost: $%s\n Level: %d\nID: %d\nTo buy this house type /buyhouse", HouseInfo[houseid][hDescription], number_format(HouseInfo[houseid][hValue]), HouseInfo[houseid][hLevel], houseid);
  467. HouseInfo[houseid][hTextID] = CreateDynamic3DTextLabel(string, HouseInfo[houseid][hInactive] ? COLOR_LIGHTBLUE : COLOR_GREEN, HouseInfo[houseid][hExteriorX], HouseInfo[houseid][hExteriorY], HouseInfo[houseid][hExteriorZ]+0.5,10.0, .testlos = 1, .worldid = HouseInfo[houseid][hExtVW], .interiorid = HouseInfo[houseid][hExtIW], .streamdistance = 10.0);
  468. HouseInfo[houseid][hPickupID] = CreateDynamicPickup(HouseInfo[houseid][hInactive] ? 1272 : 1273, 23, HouseInfo[houseid][hExteriorX], HouseInfo[houseid][hExteriorY], HouseInfo[houseid][hExteriorZ], .worldid = HouseInfo[houseid][hExtVW], .interiorid = HouseInfo[houseid][hExtIW]);
  469. HouseInfo[houseid][hPickupID_int] = CreateDynamicPickup(1559, 23, HouseInfo[houseid][hInteriorX], HouseInfo[houseid][hInteriorY], HouseInfo[houseid][hInteriorZ], .worldid = HouseInfo[houseid][hIntVW], .interiorid = HouseInfo[houseid][hIntIW]);
  470. if(IsValidDynamicArea(HouseInfo[houseid][hAreaID][0])) DestroyDynamicArea(HouseInfo[houseid][hAreaID][0]);
  471. if(IsValidDynamicArea(HouseInfo[houseid][hAreaID][1])) DestroyDynamicArea(HouseInfo[houseid][hAreaID][1]);
  472. HouseInfo[houseid][hAreaID][0] = CreateDynamicSphere(HouseInfo[houseid][hExteriorX], HouseInfo[houseid][hExteriorY], HouseInfo[houseid][hExteriorZ], 2.5, HouseInfo[houseid][hExtVW], HouseInfo[houseid][hExtIW]);
  473. HouseInfo[houseid][hAreaID][1] = CreateDynamicSphere(HouseInfo[houseid][hInteriorX], HouseInfo[houseid][hInteriorY], HouseInfo[houseid][hInteriorZ], 2.5, HouseInfo[houseid][hIntVW], HouseInfo[houseid][hIntIW]);
  474. format(szMiscArray, sizeof(szMiscArray), "ID %d | VW: %d", houseid, HouseInfo[houseid][hIntVW]);
  475. HouseInfo[houseid][hTextID_int] = CreateDynamic3DTextLabel(szMiscArray, COLOR_GRAD1, HouseInfo[houseid][hInteriorX], HouseInfo[houseid][hInteriorY], HouseInfo[houseid][hInteriorZ], 5.0, .worldid = HouseInfo[houseid][hIntVW], .interiorid = HouseInfo[houseid][hIntIW]);
  476. Streamer_SetIntData(STREAMER_TYPE_AREA, HouseInfo[houseid][hAreaID][0], E_STREAMER_EXTRA_ID, houseid);
  477. Streamer_SetIntData(STREAMER_TYPE_AREA, HouseInfo[houseid][hAreaID][1], E_STREAMER_EXTRA_ID, houseid);
  478. return 1;
  479. }
  480. stock SaveHouses()
  481. {
  482. for(new i = 0; i < MAX_HOUSES; i++)
  483. {
  484. SaveHouse(i);
  485. }
  486. ABroadCast(COLOR_LIGHTRED, "House saving finished.", 4);
  487. return 1;
  488. }
  489. stock RehashHouse(houseid)
  490. {
  491. HouseInfo[houseid][hSQLId] = -1;
  492. HouseInfo[houseid][hOwned] = 0;
  493. HouseInfo[houseid][hLevel] = 0;
  494. HouseInfo[houseid][hCustomInterior] = 0;
  495. HouseInfo[houseid][hOwnerID] = -1;
  496. format(HouseInfo[houseid][hOwnerName], 128, "Nobody");
  497. HouseInfo[houseid][hExteriorX] = 0.0;
  498. HouseInfo[houseid][hExteriorY] = 0.0;
  499. HouseInfo[houseid][hExteriorZ] = 0.0;
  500. HouseInfo[houseid][hExteriorR] = 0.0;
  501. HouseInfo[houseid][hExteriorA] = 0.0;
  502. HouseInfo[houseid][hInteriorX] = 0.0;
  503. HouseInfo[houseid][hInteriorY] = 0.0;
  504. HouseInfo[houseid][hInteriorZ] = 0.0;
  505. HouseInfo[houseid][hInteriorR] = 0.0;
  506. HouseInfo[houseid][hInteriorA] = 0.0;
  507. HouseInfo[houseid][hExtIW] = 0;
  508. HouseInfo[houseid][hExtVW] = 0;
  509. HouseInfo[houseid][hIntIW] = 0;
  510. HouseInfo[houseid][hIntVW] = 0;
  511. HouseInfo[houseid][hLock] = 0;
  512. HouseInfo[houseid][hRentable] = 0;
  513. HouseInfo[houseid][hRentFee] = 0;
  514. HouseInfo[houseid][hValue] = 0;
  515. HouseInfo[houseid][hSafeMoney] = 0;
  516. HouseInfo[houseid][hPot] = 0;
  517. HouseInfo[houseid][hCrack] = 0;
  518. HouseInfo[houseid][hMaterials] = 0;
  519. HouseInfo[houseid][hHeroin] = 0;
  520. HouseInfo[houseid][hEcstasy] = 0;
  521. HouseInfo[houseid][hMeth] = 0;
  522. HouseInfo[houseid][hWeapons][0] = 0;
  523. HouseInfo[houseid][hWeapons][1] = 0;
  524. HouseInfo[houseid][hWeapons][2] = 0;
  525. HouseInfo[houseid][hWeapons][3] = 0;
  526. HouseInfo[houseid][hWeapons][4] = 0;
  527. HouseInfo[houseid][hGLUpgrade] = 0;
  528. if(IsValidDynamicPickup(HouseInfo[houseid][hPickupID])) DestroyDynamicPickup(HouseInfo[houseid][hPickupID]);
  529. if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hTextID])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hTextID]);
  530. HouseInfo[houseid][hCustomExterior] = 0;
  531. HouseInfo[houseid][hMailX] = 0.0;
  532. HouseInfo[houseid][hMailY] = 0.0;
  533. HouseInfo[houseid][hMailZ] = 0.0;
  534. HouseInfo[houseid][hMailA] = 0.0;
  535. HouseInfo[houseid][hMailType] = 0;
  536. if(IsValidDynamicObject(HouseInfo[houseid][hMailObjectId])) DestroyDynamicObject(HouseInfo[houseid][hMailObjectId]);
  537. if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hMailTextID])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hMailTextID]);
  538. HouseInfo[houseid][hClosetX] = 0.0;
  539. HouseInfo[houseid][hClosetY] = 0.0;
  540. HouseInfo[houseid][hClosetZ] = 0.0;
  541. if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hClosetTextID])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hClosetTextID]);
  542. LoadHouse(houseid);
  543. }
  544. stock RehashHouses()
  545. {
  546. printf("[RehashHouses] Deleting houses from server...");
  547. for(new i = 0; i < MAX_HOUSES; i++)
  548. {
  549. RehashHouse(i);
  550. }
  551. //LoadHouses();
  552. }
  553. CMD:househelp(playerid, params[])
  554. {
  555. SetPVarInt(playerid, "HelpResultCat0", 6);
  556. Help_ListCat(playerid, DIALOG_HELPCATOTHER1);
  557. return 1;
  558. }
  559. CMD:ohousehelp(playerid, params[])
  560. {
  561. SendClientMessageEx(playerid, COLOR_GREEN,"_______________________________________");
  562. SendClientMessageEx(playerid, COLOR_WHITE,"*** HOUSE HELP *** - type a command for more infomation.");
  563. SendClientMessageEx(playerid, COLOR_GRAD3,"*** HOUSE *** /lockhouse /setrentable /setrent /evict /evictall /sellmyhouse /ringbell");
  564. SendClientMessageEx(playerid, COLOR_GRAD3,"*** HOUSE *** /hwithdraw /hdeposit /hbalance /getgun /storegun /closet(add/remove) /houseinvite");
  565. SendClientMessageEx(playerid, COLOR_GRAD3,"*** HOUSE *** /movegate /setgatepass /placemailbox /destroymailbox /getmail /sendmail");
  566. SendClientMessageEx(playerid, COLOR_GRAD3,"*** HOUSE *** /workbench /houselights");
  567. return 1;
  568. }
  569. CMD:renthelp(playerid, params[])
  570. {
  571. SetPVarInt(playerid, "HelpResultCat0", 8);
  572. Help_ListCat(playerid, DIALOG_HELPCATOTHER1);
  573. return 1;
  574. }
  575. CMD:orenthelp(playerid, params[])
  576. {
  577. SendClientMessageEx(playerid, COLOR_GREEN,"_______________________________________");
  578. SendClientMessageEx(playerid, COLOR_WHITE,"*** RENTING HELP *** - type a command for more infomation.");
  579. SendClientMessageEx(playerid, COLOR_GRAD3,"*** RENT *** /unrent /enter /exit /lock /home");
  580. return 1;
  581. }
  582. CMD:buyhouse(playerid, params[])
  583. {
  584. if(IsPlayerInRangeOfPoint(playerid, 100.0, 1109.0, 1537.0, 5.0) && PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_WHITE, "You cannot use this command in this area!");
  585. new string[128];
  586. new Float:oldposx, Float:oldposy, Float:oldposz;
  587. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  588. for(new h = 0; h < sizeof(HouseInfo); h++)
  589. {
  590. if(IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ]) && GetPlayerInterior(playerid) == HouseInfo[h][hExtIW] && GetPlayerVirtualWorld(playerid) == HouseInfo[h][hExtVW])
  591. {
  592. if(PlayerInfo[playerid][pFreezeHouse] == 1) return SendClientMessageEx(playerid, COLOR_WHITE, "ERROR: Your house assets are frozen, you cannot buy a house!");
  593. if(HouseInfo[h][hOwned] == 0)
  594. {
  595. if(PlayerInfo[playerid][pLevel] < HouseInfo[h][hLevel])
  596. {
  597. format(string, sizeof(string), " You must be Level %d to purchase this!", HouseInfo[h][hLevel]);
  598. SendClientMessageEx(playerid, COLOR_GRAD5, string);
  599. return 1;
  600. }
  601. if(Homes[playerid] >= 2 && PlayerInfo[playerid][pDonateRank] < 4) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot own another home.");
  602. else if(Homes[playerid] >= 3 && PlayerInfo[playerid][pDonateRank] >= 4) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot own another home.");
  603. if(GetPlayerCash(playerid) > HouseInfo[h][hValue])
  604. {
  605. if(PlayerInfo[playerid][pPhousekey] == INVALID_HOUSE_ID) PlayerInfo[playerid][pPhousekey] = h;
  606. else if(PlayerInfo[playerid][pPhousekey2] == INVALID_HOUSE_ID) PlayerInfo[playerid][pPhousekey2] = h;
  607. else if(PlayerInfo[playerid][pPhousekey3] == INVALID_HOUSE_ID && PlayerInfo[playerid][pDonateRank] >= 4) PlayerInfo[playerid][pPhousekey3] = h;
  608. else return SendClientMessageEx(playerid, COLOR_GREY, "You have no free house slot left.");
  609. HouseInfo[h][hOwned] = 1;
  610. HouseInfo[h][hOwnerID] = GetPlayerSQLId(playerid);
  611. strcat((HouseInfo[h][hOwnerName][0] = 0, HouseInfo[h][hOwnerName]), GetPlayerNameEx(playerid), MAX_PLAYER_NAME);
  612. Homes[playerid]++;
  613. GivePlayerCash(playerid,-HouseInfo[h][hValue]);
  614. SetPlayerInterior(playerid,HouseInfo[h][hIntIW]);
  615. SetPlayerPos(playerid, HouseInfo[h][hInteriorX], HouseInfo[h][hInteriorY], HouseInfo[h][hInteriorZ]);
  616. GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by moving to this door and typing /exit.", 5000, 3);
  617. PlayerInfo[playerid][pInt] = HouseInfo[h][hIntIW];
  618. SendClientMessageEx(playerid, COLOR_WHITE, "Congratulations on your new purchase!");
  619. SendClientMessageEx(playerid, COLOR_WHITE, "Type /help to review the property help section!");
  620. SaveHouse(h);
  621. OnPlayerStatsUpdate(playerid);
  622. PlayerInfo[playerid][pVW] = HouseInfo[h][hIntVW];
  623. SetPlayerVirtualWorld(playerid,HouseInfo[h][hIntVW]);
  624. ReloadHouseText(h);
  625. format(string,sizeof(string),"%s(%d) (IP: %s) has bought house ID %d for $%d.",GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid),h,HouseInfo[h][hValue]);
  626. Log("logs/house.log", string);
  627. if(HouseInfo[h][hCustomInterior] == 1) Player_StreamPrep(playerid, HouseInfo[h][hInteriorX],HouseInfo[h][hInteriorY],HouseInfo[h][hInteriorZ], FREEZE_TIME);
  628. return 1;
  629. }
  630. else return SendClientMessageEx(playerid, COLOR_GREY, " You don't have the cash for that!");
  631. }
  632. else return SendClientMessageEx(playerid, COLOR_GREY, "This house is owned.");
  633. }
  634. }
  635. return 1;
  636. }
  637. CMD:rentroom(playerid, params[])
  638. {
  639. //new string[128];
  640. new Float:oldposx, Float:oldposy, Float:oldposz;
  641. new playername[MAX_PLAYER_NAME];
  642. GetPlayerName(playerid, playername, sizeof(playername));
  643. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  644. for(new h = 0; h < sizeof(HouseInfo); h++)
  645. {
  646. if(IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ]) && GetPlayerInterior(playerid) == HouseInfo[h][hExtIW] && GetPlayerVirtualWorld(playerid) == HouseInfo[h][hExtVW] && HouseInfo[h][hRentFee] >= 1)
  647. {
  648. if(!strcmp(HouseInfo[h][hOwnerName], "Nobody", true))
  649. {
  650. SendClientMessageEx( playerid, COLOR_WHITE, "You can't rent an unowned house." );
  651. }
  652. else
  653. {
  654. if(PlayerInfo[playerid][pPhousekey] != INVALID_HOUSE_ID && HouseInfo[PlayerInfo[playerid][pPhousekey]][hOwnerID] == GetPlayerSQLId(playerid))
  655. {
  656. SendClientMessageEx(playerid, COLOR_WHITE, " You already own a house, type /sellmyhouse if you want to rent this one.");
  657. return 1;
  658. }
  659. if(GetPlayerCash(playerid) > HouseInfo[h][hRentFee])
  660. {
  661. if( HouseInfo[h][hRentable] == 0 )
  662. {
  663. SendClientMessageEx(playerid, COLOR_WHITE, "This house is not rentable.");
  664. return 1;
  665. }
  666. else
  667. {
  668. PlayerInfo[playerid][pRenting] = h;
  669. GivePlayerCash(playerid,-HouseInfo[h][hRentFee]);
  670. HouseInfo[h][hSafeMoney] = HouseInfo[h][hSafeMoney]+HouseInfo[h][hRentFee];
  671. SetPlayerInterior(playerid,HouseInfo[h][hIntIW]);
  672. SetPlayerPos(playerid,HouseInfo[h][hInteriorX],HouseInfo[h][hInteriorY],HouseInfo[h][hInteriorZ]);
  673. GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by moving to this door and typing /exit.", 5000, 3);
  674. PlayerInfo[playerid][pInt] = HouseInfo[h][hIntIW];
  675. PlayerInfo[playerid][pVW] = HouseInfo[h][hIntVW];
  676. SetPlayerVirtualWorld(playerid,HouseInfo[h][hIntVW]);
  677. SendClientMessageEx(playerid, COLOR_WHITE, "Congratulations. You can enter and exit here any time you want.");
  678. SendClientMessageEx(playerid, COLOR_WHITE, "Type /help to review the property help section.");
  679. OnPlayerStatsUpdate(playerid);
  680. //new ip[32];
  681. //GetPlayerIp(playerid,ip,sizeof(ip));
  682. //format(string,sizeof(string),"%s (IP: %s) has rented house ID %d (owned by %s) for $%d.",GetPlayerNameEx(playerid),ip,h,HouseInfo[h][hOwnerID],HouseInfo[h][hRentFee]);
  683. //Log("logs/house.log", string);
  684. if(HouseInfo[h][hCustomInterior] == 1) Player_StreamPrep(playerid, HouseInfo[h][hInteriorX],HouseInfo[h][hInteriorY],HouseInfo[h][hInteriorZ], FREEZE_TIME);
  685. return 1;
  686. }
  687. }
  688. else
  689. {
  690. SendClientMessageEx(playerid, COLOR_WHITE, "You don't have the cash for that.");
  691. return 1;
  692. }
  693. }
  694. }
  695. }
  696. return 1;
  697. }
  698. CMD:unrent(playerid, params[])
  699. {
  700. new playername[MAX_PLAYER_NAME];
  701. GetPlayerName(playerid, playername, sizeof(playername));
  702. if(PlayerInfo[playerid][pPhousekey] != INVALID_HOUSE_ID && HouseInfo[PlayerInfo[playerid][pPhousekey]][hOwnerID] == GetPlayerSQLId(playerid))
  703. {
  704. SendClientMessageEx(playerid, COLOR_WHITE, " You own this house!");
  705. return 1;
  706. }
  707. if( PlayerInfo[playerid][pRenting] != INVALID_HOUSE_ID )
  708. {
  709. PlayerInfo[playerid][pRenting] = INVALID_HOUSE_ID;
  710. SendClientMessageEx(playerid, COLOR_WHITE, "You are now homeless.");
  711. }
  712. return 1;
  713. }
  714. CMD:ringbell(playerid, params[])
  715. {
  716. for(new h; h < sizeof(HouseInfo); h++) if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ])) {
  717. new
  718. string[75 + MAX_PLAYER_NAME];
  719. foreach(new i: Player)
  720. {
  721. if((IsPlayerInRangeOfPoint(i, 15.0, HouseInfo[h][hInteriorX], HouseInfo[h][hInteriorY], HouseInfo[h][hInteriorZ])) && GetPlayerVirtualWorld(i) == HouseInfo[h][hIntVW] && GetPlayerInterior(i) == HouseInfo[h][hIntIW]) {
  722. format(string,sizeof(string),"%s's doorbell rings.", StripUnderscore(HouseInfo[h][hOwnerName]));
  723. SendClientMessageEx(i,COLOR_PURPLE,string);
  724. GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~n~~w~The doorbell rings...", 4000,3);
  725. break;
  726. }
  727. }
  728. format(string,sizeof(string),"* %s presses a button next to the door, ringing the doorbell of %s's house.", GetPlayerNameEx(playerid), StripUnderscore(HouseInfo[h][hOwnerName]));
  729. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  730. }
  731. return 1;
  732. }
  733. CMD:home(playerid, params[])
  734. {
  735. if(CheckPointCheck(playerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "Please ensure that your current checkpoint is destroyed first (you either have material packages, or another existing checkpoint).");
  736. if(!Homes[playerid]) return SendClientMessageEx(playerid, COLOR_GRAD2, "You don't own a home!"), GameTextForPlayer(playerid, "~w~You are homeless", 5000, 1);
  737. new home;
  738. if(sscanf(params, "d", home) || !(1 <= home <= 3)) return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /home [1, 2 or 3]");
  739. switch(home)
  740. {
  741. case 1:
  742. {
  743. if(PlayerInfo[playerid][pPhousekey] == INVALID_HOUSE_ID) return SendClientMessageEx(playerid, COLOR_GRAD2, "You do not own a house in that slot.");
  744. SetPlayerCheckpoint(playerid,HouseInfo[PlayerInfo[playerid][pPhousekey]][hExteriorX], HouseInfo[PlayerInfo[playerid][pPhousekey]][hExteriorY], HouseInfo[PlayerInfo[playerid][pPhousekey]][hExteriorZ], 4.0);
  745. SetPVarInt(playerid, "hInviteHouse", PlayerInfo[playerid][pPhousekey]);
  746. }
  747. case 2:
  748. {
  749. if(PlayerInfo[playerid][pPhousekey2] == INVALID_HOUSE_ID) return SendClientMessageEx(playerid, COLOR_GRAD2, "You do not own a house in that slot.");
  750. SetPlayerCheckpoint(playerid,HouseInfo[PlayerInfo[playerid][pPhousekey2]][hExteriorX], HouseInfo[PlayerInfo[playerid][pPhousekey2]][hExteriorY], HouseInfo[PlayerInfo[playerid][pPhousekey2]][hExteriorZ], 4.0);
  751. SetPVarInt(playerid, "hInviteHouse", PlayerInfo[playerid][pPhousekey2]);
  752. }
  753. case 3:
  754. {
  755. if(PlayerInfo[playerid][pPhousekey3] == INVALID_HOUSE_ID) return SendClientMessageEx(playerid, COLOR_GRAD2, "You do not own a house in that slot.");
  756. SetPlayerCheckpoint(playerid,HouseInfo[PlayerInfo[playerid][pPhousekey3]][hExteriorX], HouseInfo[PlayerInfo[playerid][pPhousekey3]][hExteriorY], HouseInfo[PlayerInfo[playerid][pPhousekey3]][hExteriorZ], 4.0);
  757. SetPVarInt(playerid, "hInviteHouse", PlayerInfo[playerid][pPhousekey3]);
  758. }
  759. }
  760. GameTextForPlayer(playerid, "~w~Waypoint set ~r~Home", 5000, 1);
  761. gPlayerCheckpointStatus[playerid] = CHECKPOINT_HOME;
  762. return 1;
  763. }
  764. CMD:sellmyhouse(playerid, params[])
  765. {
  766. if(servernumber == 2) return SendClientMessage(playerid, COLOR_WHITE, "This command is disabled!");
  767. if(Homes[playerid] > 0)
  768. {
  769. if(PlayerInfo[playerid][pFreezeHouse] == 1) return SendClientMessageEx(playerid, COLOR_WHITE, "ERROR: Your house assets are frozen, you cannot sell your house!");
  770. new string[128], giveplayerid, price;
  771. if(sscanf(params, "ud", giveplayerid, price)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /sellmyhouse [player] [price]");
  772. if(price < 1) return SendClientMessageEx(playerid, COLOR_GREY, "Price must be higher than 0.");
  773. if(!IsPlayerConnected(giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "Player is currently not connected to the server.");
  774. if(Homes[giveplayerid] >= MAX_OWNABLE_HOUSES && PlayerInfo[giveplayerid][pDonateRank] < 4) return SendClientMessageEx(playerid, COLOR_GREY, "They cannot own another home.");
  775. if(Homes[giveplayerid] >= 3) return SendClientMessageEx(playerid, COLOR_GREY, "They cannot own another home.");
  776. if(PlayerInfo[giveplayerid][pFreezeHouse] == 1)
  777. {
  778. SendClientMessageEx(giveplayerid, COLOR_WHITE, "ERROR: Your house assets are frozen, you cannot buy a house!");
  779. SendClientMessageEx(playerid, COLOR_WHITE, "ERROR: Their house assets are frozen, you cannot sell them a house!");
  780. return 1;
  781. }
  782. for(new i; i < MAX_HOUSES; i++)
  783. {
  784. 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])
  785. {
  786. if(PlayerInfo[giveplayerid][pLevel] >= HouseInfo[i][hLevel])
  787. {
  788. if(ProxDetectorS(8.0, playerid, giveplayerid) && GetPlayerVirtualWorld(giveplayerid) == HouseInfo[i][hExtVW] && GetPlayerInterior(giveplayerid) == HouseInfo[i][hExtIW])
  789. {
  790. if(PlayerInfo[playerid][pBackpack] > 0 && HouseInfo[i][hSQLId] == PlayerInfo[playerid][pBStoredH] && !GetPVarInt(playerid, "confirmhousell"))
  791. {
  792. SetPVarInt(playerid, "confirmhousell", 1);
  793. return SendClientMessageEx(playerid, COLOR_WHITE, "ERROR: You have a backpack stored in this house, withdraw it first or you will lose it, please confirm!");
  794. }
  795. HouseOffer[giveplayerid] = playerid;
  796. HousePrice[giveplayerid] = price;
  797. House[giveplayerid] = i;
  798. format(string, sizeof(string), "* You offered %s to buy your house for $%s.", GetPlayerNameEx(giveplayerid), number_format(price));
  799. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
  800. format(string, sizeof(string), "* %s has offered you their house for $%s, (type /accept house) to buy.", GetPlayerNameEx(playerid), number_format(price));
  801. SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
  802. DeletePVar(playerid, "confirmhousell");
  803. return 1;
  804. }
  805. else return SendClientMessageEx(playerid, COLOR_GREY, "That person is not near you.");
  806. }
  807. else return SendClientMessageEx(playerid, COLOR_GREY, "The person you are trying to sell your house to is not the appropriate level to buy this house.");
  808. }
  809. }
  810. SendClientMessageEx(playerid, COLOR_GREY, "You are not at a house that you own.");
  811. }
  812. else return SendClientMessageEx(playerid, COLOR_GREY, "You don't own a house.");
  813. return 1;
  814. }
  815. CMD:asellhouse(playerid, params[])
  816. {
  817. if (PlayerInfo[playerid][pAdmin] >= 4)
  818. {
  819. new playername[MAX_PLAYER_NAME];
  820. GetPlayerName(playerid, playername, sizeof(playername));
  821. new string[128], house;
  822. if(sscanf(params, "d", house)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /asellhouse [houseid]");
  823. HouseInfo[house][hLock] = 1;
  824. foreach(new p : Player) {
  825. if(HouseInfo[house][hOwnerID] == PlayerInfo[p][pId]) Homes[p]--;
  826. if(PlayerInfo[p][pPhousekey] == house) PlayerInfo[p][pPhousekey] = INVALID_HOUSE_ID;
  827. else if(PlayerInfo[p][pPhousekey2] == house) PlayerInfo[p][pPhousekey2] = INVALID_HOUSE_ID;
  828. else if(PlayerInfo[p][pPhousekey3] == house) PlayerInfo[playerid][pPhousekey3] = INVALID_HOUSE_ID;
  829. }
  830. new ip[32];
  831. GetPlayerIp(playerid,ip,sizeof(ip));
  832. format(string,sizeof(string),"Administrator %s (IP: %s) has admin-sold house ID %d (was owned by %s(%d)).", GetPlayerNameEx(playerid), ip, house, HouseInfo[house][hOwnerName], HouseInfo[house][hOwnerID]);
  833. Log("logs/house.log", string);
  834. ClearHouse(house);
  835. format( HouseInfo[house][hOwnerName], 128, "Nobody" );
  836. HouseInfo[house][hOwnerID] = -1;
  837. HouseInfo[house][hGLUpgrade] = 1;
  838. PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
  839. format(string, sizeof(string), "~w~You have sold house %d.", house);
  840. GameTextForPlayer(playerid, string, 10000, 3);
  841. SaveHouse(house);
  842. ReloadHousePickup(house);
  843. return 1;
  844. }
  845. else
  846. {
  847. SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use that command.");
  848. }
  849. return 1;
  850. }
  851. CMD:goinhouse(playerid, params[])
  852. {
  853. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pShopTech] >= 1)
  854. {
  855. new housenum;
  856. if(sscanf(params, "d", housenum)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /goinhouse [housenumber]");
  857. if(housenum <= 0 || housenum >= MAX_HOUSES)
  858. {
  859. format(szMiscArray, sizeof(szMiscArray), "House ID must be between 1 and %d.", MAX_HOUSES - 1);
  860. return SendClientMessageEx(playerid, COLOR_GREY, szMiscArray);
  861. }
  862. House_VistorCheck(housenum);
  863. SetPlayerInterior(playerid,HouseInfo[housenum][hIntIW]);
  864. SetPlayerPos(playerid, HouseInfo[housenum][hInteriorX], HouseInfo[housenum][hInteriorY], HouseInfo[housenum][hInteriorZ]);
  865. GameTextForPlayer(playerid, "~w~Teleporting", 5000, 1);
  866. PlayerInfo[playerid][pInt] = HouseInfo[housenum][hIntIW];
  867. PlayerInfo[playerid][pVW] = HouseInfo[housenum][hIntVW];
  868. SetPlayerVirtualWorld(playerid,HouseInfo[housenum][hIntVW]);
  869. if(HouseInfo[housenum][hCustomInterior] == 1) Player_StreamPrep(playerid, HouseInfo[housenum][hInteriorX],HouseInfo[housenum][hInteriorY],HouseInfo[housenum][hInteriorZ], FREEZE_TIME);
  870. }
  871. return 1;
  872. }
  873. CMD:gotohouse(playerid, params[])
  874. {
  875. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pShopTech] >= 1)
  876. {
  877. new housenum;
  878. if(sscanf(params, "d", housenum)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /gotohouse [housenumber]");
  879. if(housenum <= 0 || housenum >= MAX_HOUSES)
  880. {
  881. format(szMiscArray, sizeof(szMiscArray), "House ID must be between 1 and %d.", MAX_HOUSES - 1);
  882. return SendClientMessageEx(playerid, COLOR_GREY, szMiscArray);
  883. }
  884. SetPlayerPos(playerid, HouseInfo[housenum][hExteriorX], HouseInfo[housenum][hExteriorY], HouseInfo[housenum][hExteriorZ]);
  885. PlayerInfo[playerid][pInt] = HouseInfo[housenum][hExtIW];
  886. SetPlayerInterior(playerid,HouseInfo[housenum][hExtIW]);
  887. PlayerInfo[playerid][pVW] = HouseInfo[housenum][hExtVW];
  888. SetPlayerVirtualWorld(playerid,HouseInfo[housenum][hExtVW]);
  889. GameTextForPlayer(playerid, "~w~Teleporting", 5000, 1);
  890. SetPlayerInterior(playerid, 0);
  891. PlayerInfo[playerid][pInt] = 0;
  892. }
  893. return 1;
  894. }
  895. CMD:hnext(playerid, params[])
  896. {
  897. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pShopTech] >= 1)
  898. {
  899. SendClientMessageEx(playerid, COLOR_RED, "* Listing next available house...");
  900. for(new x;x<MAX_HOUSES;x++)
  901. {
  902. if(HouseInfo[x][hExteriorX] == 0.0) // If the house is at blueberry!
  903. {
  904. new string[128];
  905. format(string, sizeof(string), "%d is available to use.", x);
  906. SendClientMessageEx(playerid, COLOR_WHITE, string);
  907. break;
  908. }
  909. }
  910. }
  911. else
  912. {
  913. SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  914. return 1;
  915. }
  916. return 1;
  917. }
  918. CMD:hname(playerid, params[])
  919. {
  920. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1)
  921. {
  922. SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  923. return 1;
  924. }
  925. new string[128], houseid, ownername[24];
  926. if(sscanf(params, "ds[24]", houseid, ownername)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /hname [houseid] [name]");
  927. format(HouseInfo[houseid][hOwnerName], 24, "%s", ownername);
  928. format(string, sizeof(string), "You have set the house owner to %s", ownername);
  929. HouseInfo[houseid][hOwned] = 1;
  930. SendClientMessageEx(playerid, COLOR_WHITE, string);
  931. ReloadHouseText(houseid);
  932. SaveHouse(houseid);
  933. format(string, sizeof(string), "%s has edited HouseID %d's Owner to %s.", GetPlayerNameEx(playerid), houseid, ownername);
  934. Log("logs/hedit.log", string);
  935. return 1;
  936. }
  937. CMD:hedit(playerid, params[])
  938. {
  939. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1 && PlayerInfo[playerid][pShopTech] < 1)
  940. {
  941. SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  942. return 1;
  943. }
  944. new string[128], choice[32], houseid, amount;
  945. if(sscanf(params, "s[32]dD", choice, houseid, amount))
  946. {
  947. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /hedit [name] [houseid] [(Optional)amount]");
  948. SendClientMessageEx(playerid, COLOR_GREY, "Available names: Exterior, Interior, VW, CustomInterior, CustomExterior, Class (1-3), Level, Price, Delete, Ignore");
  949. return 1;
  950. }
  951. if(strcmp(choice, "ignore", true) == 0)
  952. {
  953. if(PlayerInfo[playerid][pAdmin] < 99999) return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  954. SendClientMessageEx(playerid, COLOR_WHITE, HouseInfo[houseid][hIgnore] ? ("House set to be checked in Inactive Player Resource checks!"):("House set to be ignored from Inactive Player Resource checks!"));
  955. HouseInfo[houseid][hIgnore] = !HouseInfo[houseid][hIgnore];
  956. HouseInfo[houseid][hInactive] = 0;
  957. HouseInfo[houseid][hExpire] = 0;
  958. HouseInfo[houseid][hCounter] = 0;
  959. SaveHouse(houseid);
  960. format(string, sizeof(string), "%s has edited HouseID %d's Ignore state to %d.", GetPlayerNameEx(playerid), houseid, HouseInfo[houseid][hIgnore]);
  961. Log("logs/hedit.log", string);
  962. }
  963. else if(strcmp(choice, "delete", true) == 0)
  964. {
  965. if(HouseInfo[houseid][hExteriorX] == 0.0) return SendClientMessageEx(playerid, COLOR_GRAD1, "This house does not exist!");
  966. // Do not reset the SQL ID as the house still exists but is not owned by any player and it isn't spawned
  967. HouseInfo[houseid][hOwned] = 0;
  968. HouseInfo[houseid][hLevel] = 0;
  969. HouseInfo[houseid][hCustomInterior] = 0;
  970. HouseInfo[houseid][hOwnerID] = -1;
  971. format(HouseInfo[houseid][hOwnerName], 128, "Nobody");
  972. HouseInfo[houseid][hExteriorX] = 0.0;
  973. HouseInfo[houseid][hExteriorY] = 0.0;
  974. HouseInfo[houseid][hExteriorZ] = 0.0;
  975. HouseInfo[houseid][hExteriorR] = 0.0;
  976. HouseInfo[houseid][hExteriorA] = 0.0;
  977. HouseInfo[houseid][hInteriorX] = 0.0;
  978. HouseInfo[houseid][hInteriorY] = 0.0;
  979. HouseInfo[houseid][hInteriorZ] = 0.0;
  980. HouseInfo[houseid][hInteriorR] = 0.0;
  981. HouseInfo[houseid][hInteriorA] = 0.0;
  982. HouseInfo[houseid][hExtIW] = 0;
  983. HouseInfo[houseid][hExtVW] = 0;
  984. HouseInfo[houseid][hIntIW] = 0;
  985. HouseInfo[houseid][hIntVW] = 0;
  986. HouseInfo[houseid][hLock] = 0;
  987. HouseInfo[houseid][hRentable] = 0;
  988. HouseInfo[houseid][hRentFee] = 0;
  989. HouseInfo[houseid][hValue] = 0;
  990. HouseInfo[houseid][hSafeMoney] = 0;
  991. HouseInfo[houseid][hPot] = 0;
  992. HouseInfo[houseid][hCrack] = 0;
  993. HouseInfo[houseid][hMaterials] = 0;
  994. HouseInfo[houseid][hHeroin] = 0;
  995. HouseInfo[houseid][hEcstasy] = 0;
  996. HouseInfo[houseid][hMeth] = 0;
  997. HouseInfo[houseid][hWeapons][0] = 0;
  998. HouseInfo[houseid][hWeapons][1] = 0;
  999. HouseInfo[houseid][hWeapons][2] = 0;
  1000. HouseInfo[houseid][hWeapons][3] = 0;
  1001. HouseInfo[houseid][hWeapons][4] = 0;
  1002. HouseInfo[houseid][hGLUpgrade] = 0;
  1003. if(IsValidDynamicPickup(HouseInfo[houseid][hPickupID])) DestroyDynamicPickup(HouseInfo[houseid][hPickupID]);
  1004. if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hTextID])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hTextID]);
  1005. HouseInfo[houseid][hCustomExterior] = 0;
  1006. HouseInfo[houseid][hMailX] = 0.0;
  1007. HouseInfo[houseid][hMailY] = 0.0;
  1008. HouseInfo[houseid][hMailZ] = 0.0;
  1009. HouseInfo[houseid][hMailA] = 0.0;
  1010. HouseInfo[houseid][hMailType] = 0;
  1011. if(IsValidDynamicObject(HouseInfo[houseid][hMailObjectId])) DestroyDynamicObject(HouseInfo[houseid][hMailObjectId]);
  1012. if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hMailTextID])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hMailTextID]);
  1013. HouseInfo[houseid][hClosetX] = 0.0;
  1014. HouseInfo[houseid][hClosetY] = 0.0;
  1015. HouseInfo[houseid][hClosetZ] = 0.0;
  1016. if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hClosetTextID])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hClosetTextID]);
  1017. SaveHouse(houseid);
  1018. format(string, sizeof(string), "You have deleted house id %d.", houseid);
  1019. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1020. format(string, sizeof(string), "%s has deleted house id %d", GetPlayerNameEx(playerid), houseid);
  1021. Log("logs/hedit.log", string);
  1022. return true;
  1023. }
  1024. else if(strcmp(choice, "interior", true) == 0)
  1025. {
  1026. new Float: Pos[3];
  1027. GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  1028. format(szMiscArray, sizeof(szMiscArray), "%s has edited HouseID %d's Interior. (B: %f, %f, %f | A: %f, %f, %f)", GetPlayerNameEx(playerid), houseid, HouseInfo[houseid][hInteriorX], HouseInfo[houseid][hInteriorY], HouseInfo[houseid][hInteriorZ], Pos[0], Pos[1], Pos[2]);
  1029. Log("logs/hedit.log", szMiscArray);
  1030. GetPlayerPos(playerid, HouseInfo[houseid][hInteriorX], HouseInfo[houseid][hInteriorY], HouseInfo[houseid][hInteriorZ]);
  1031. GetPlayerFacingAngle(playerid, HouseInfo[houseid][hInteriorA]);
  1032. HouseInfo[houseid][hIntIW] = GetPlayerInterior( playerid );
  1033. HouseInfo[houseid][hIntVW] = houseid+6000;
  1034. SendClientMessageEx( playerid, COLOR_WHITE, "You have changed the interior!" );
  1035. SaveHouse(houseid);
  1036. ReloadHousePickup(houseid);
  1037. return 1;
  1038. }
  1039. else if(strcmp(choice, "custominterior", true) == 0)
  1040. {
  1041. if(HouseInfo[houseid][hCustomInterior] == 0)
  1042. {
  1043. HouseInfo[houseid][hCustomInterior] = 1;
  1044. SendClientMessageEx( playerid, COLOR_WHITE, "House set to custom interior!" );
  1045. }
  1046. else
  1047. {
  1048. HouseInfo[houseid][hCustomInterior] = 0;
  1049. SendClientMessageEx( playerid, COLOR_WHITE, "House set to normal (not custom) interior!" );
  1050. }
  1051. SaveHouse(houseid);
  1052. ReloadHousePickup(houseid);
  1053. format(string, sizeof(string), "%s has edited HouseID %d's Custom Interior.", GetPlayerNameEx(playerid), houseid);
  1054. Log("logs/hedit.log", string);
  1055. return 1;
  1056. }
  1057. else if(strcmp(choice, "customexterior", true) == 0)
  1058. {
  1059. if(HouseInfo[houseid][hCustomExterior] == 0)
  1060. {
  1061. HouseInfo[houseid][hCustomExterior] = 1;
  1062. SendClientMessageEx( playerid, COLOR_WHITE, "House set to custom exterior!" );
  1063. }
  1064. else
  1065. {
  1066. HouseInfo[houseid][hCustomExterior] = 0;
  1067. SendClientMessageEx( playerid, COLOR_WHITE, "House set to normal (not custom) exterior!" );
  1068. }
  1069. SaveHouse(houseid);
  1070. ReloadHousePickup(houseid);
  1071. format(string, sizeof(string), "%s has edited HouseID %d's Custom Exterior.", GetPlayerNameEx(playerid), houseid);
  1072. Log("logs/hedit.log", string);
  1073. return 1;
  1074. }
  1075. else if(strcmp(choice, "exterior", true) == 0)
  1076. {
  1077. new Float: Pos[3];
  1078. GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  1079. format(szMiscArray, sizeof(szMiscArray), "%s has edited HouseID %d's Exterior. (B: %f, %f, %f | A: %f, %f, %f)", GetPlayerNameEx(playerid), houseid, HouseInfo[houseid][hExteriorX], HouseInfo[houseid][hExteriorY], HouseInfo[houseid][hExteriorZ], Pos[0], Pos[1], Pos[2]);
  1080. Log("logs/hedit.log", szMiscArray);
  1081. GetPlayerPos(playerid, HouseInfo[houseid][hExteriorX], HouseInfo[houseid][hExteriorY], HouseInfo[houseid][hExteriorZ]);
  1082. GetPlayerFacingAngle(playerid, HouseInfo[houseid][hExteriorA]);
  1083. HouseInfo[houseid][hExtIW] = GetPlayerInterior(playerid);
  1084. HouseInfo[houseid][hExtVW] = GetPlayerVirtualWorld(playerid);
  1085. SendClientMessageEx( playerid, COLOR_WHITE, "You have changed the exterior!" );
  1086. SaveHouse(houseid);
  1087. ReloadHousePickup(houseid);
  1088. }
  1089. else if(strcmp(choice, "VW", true) == 0)
  1090. {
  1091. HouseInfo[houseid][hIntVW] = amount;
  1092. format(string, sizeof(string), "You have changed the home's interior VW to %d.", amount);
  1093. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1094. SaveHouse(houseid);
  1095. format(string, sizeof(string), "%s has edited House ID %d's interior VW to %d.", GetPlayerNameEx(playerid), houseid, amount);
  1096. Log("logs/hedit.log", string);
  1097. return 1;
  1098. }
  1099. else if(strcmp(choice, "level", true) == 0)
  1100. {
  1101. HouseInfo[houseid][hLevel] = amount;
  1102. format(string, sizeof(string), "You have set the house level to %d.", amount);
  1103. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1104. ReloadHouseText(houseid);
  1105. format(string, sizeof(string), "%s has edited HouseID %d's Level to %d.", GetPlayerNameEx(playerid), houseid, amount);
  1106. Log("logs/hedit.log", string);
  1107. }
  1108. else if(strcmp(choice, "price", true) == 0)
  1109. {
  1110. HouseInfo[houseid][hValue] = amount;
  1111. format(string, sizeof(string), "You have set the houses price to $%d.", amount );
  1112. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1113. ReloadHouseText(houseid);
  1114. format(string, sizeof(string), "%s has edited HouseID %d's Price to $%d.", GetPlayerNameEx(playerid), amount);
  1115. Log("logs/hedit.log", string);
  1116. }
  1117. else if(strcmp(choice, "class", true) == 0)
  1118. {
  1119. switch(amount)
  1120. {
  1121. case 1:
  1122. {
  1123. format(HouseInfo[houseid][hDescription], 128, "Low" );
  1124. SendClientMessageEx(playerid, COLOR_WHITE, "You have set the house's class to 1 (Low)" );
  1125. }
  1126. case 2:
  1127. {
  1128. format(HouseInfo[houseid][hDescription], 128, "Medium" );
  1129. SendClientMessageEx(playerid, COLOR_WHITE, "You have set the house's class to 2 (Medium)" );
  1130. }
  1131. case 3:
  1132. {
  1133. format(HouseInfo[houseid][hDescription], 128, "High" );
  1134. SendClientMessageEx(playerid, COLOR_WHITE, "You have set the house's class to 3 (High)" );
  1135. }
  1136. }
  1137. if(HouseInfo[houseid][hOwned] ==0)
  1138. {
  1139. format(string, sizeof(string), "This home is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\nID: %d\nTo buy this house type /buyhouse",HouseInfo[houseid][hDescription],HouseInfo[houseid][hValue],HouseInfo[houseid][hLevel],houseid);
  1140. UpdateDynamic3DTextLabelText(HouseInfo[houseid][hTextID], COLOR_GREEN, string);
  1141. }
  1142. format(string, sizeof(string), "%s has edited HouseID %d's Class to %d.", GetPlayerNameEx(playerid), houseid, amount);
  1143. Log("logs/hedit.log", string);
  1144. }
  1145. SaveHouse(houseid);
  1146. return 1;
  1147. }
  1148. CMD:shophouse(playerid, params[])
  1149. {
  1150. if(PlayerInfo[playerid][pShopTech] < 1) return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  1151. new string[128], choice[32], houseid, amount, invoice[64];
  1152. if(sscanf(params, "s[32]dDs[64]", choice, houseid, amount, invoice))
  1153. {
  1154. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /shophouse [name] [houseid] [amount] [invoice #]");
  1155. SendClientMessageEx(playerid, COLOR_GREY, "Available names: Exterior, Interior, CustomInterior, Class (1-3), Level, Price");
  1156. return 1;
  1157. }
  1158. if(strcmp(choice, "interior", true) == 0)
  1159. {
  1160. GetPlayerPos( playerid, HouseInfo[houseid][hInteriorX], HouseInfo[houseid][hInteriorY], HouseInfo[houseid][hInteriorZ] );
  1161. HouseInfo[houseid][hIntIW] = GetPlayerInterior( playerid );
  1162. HouseInfo[houseid][hIntVW] = houseid+6000;
  1163. SendClientMessageEx( playerid, COLOR_WHITE, "You have changed the interior!" );
  1164. SaveHouse(houseid);
  1165. return 1;
  1166. }
  1167. else if(strcmp(choice, "custominterior", true) == 0)
  1168. {
  1169. if(HouseInfo[houseid][hCustomInterior] == 0)
  1170. {
  1171. HouseInfo[houseid][hCustomInterior] = 1;
  1172. SendClientMessageEx( playerid, COLOR_WHITE, "House set to custom interior!" );
  1173. }
  1174. else
  1175. {
  1176. HouseInfo[houseid][hCustomInterior] = 0;
  1177. SendClientMessageEx( playerid, COLOR_WHITE, "House set to normal (not custom) interior!" );
  1178. }
  1179. SaveHouse(houseid);
  1180. return 1;
  1181. }
  1182. else if(strcmp(choice, "customexterior", true) == 0)
  1183. {
  1184. if(HouseInfo[houseid][hCustomExterior] == 0)
  1185. {
  1186. HouseInfo[houseid][hCustomExterior] = 1;
  1187. SendClientMessageEx( playerid, COLOR_WHITE, "House set to custom exterior!" );
  1188. }
  1189. else
  1190. {
  1191. HouseInfo[houseid][hCustomExterior] = 0;
  1192. SendClientMessageEx( playerid, COLOR_WHITE, "House set to normal (not custom) exterior!" );
  1193. }
  1194. SaveHouse(houseid);
  1195. return 1;
  1196. }
  1197. else if(strcmp(choice, "exterior", true) == 0)
  1198. {
  1199. GetPlayerPos( playerid, HouseInfo[houseid][hExteriorX], HouseInfo[houseid][hExteriorY], HouseInfo[houseid][hExteriorZ] );
  1200. HouseInfo[houseid][hExtIW] = GetPlayerInterior(playerid);
  1201. HouseInfo[houseid][hExtVW] = GetPlayerVirtualWorld(playerid);
  1202. SendClientMessageEx( playerid, COLOR_WHITE, "You have changed the exterior!" );
  1203. SaveHouse(houseid);
  1204. ReloadHousePickup(houseid);
  1205. }
  1206. else if(strcmp(choice, "level", true) == 0)
  1207. {
  1208. HouseInfo[houseid][hLevel] = amount;
  1209. format(string, sizeof(string), "You have set the house level to %d.", amount);
  1210. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1211. ReloadHouseText(houseid);
  1212. }
  1213. else if(strcmp(choice, "price", true) == 0)
  1214. {
  1215. HouseInfo[houseid][hValue] = amount;
  1216. format(string, sizeof(string), "You have set the houses price to $%d.", amount );
  1217. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1218. ReloadHouseText(houseid);
  1219. }
  1220. else if(strcmp(choice, "class", true) == 0)
  1221. {
  1222. switch(amount)
  1223. {
  1224. case 1:
  1225. {
  1226. format(HouseInfo[houseid][hDescription], 128, "Low" );
  1227. SendClientMessageEx(playerid, COLOR_WHITE, "You have set the house's class to 1 (Low)" );
  1228. }
  1229. case 2:
  1230. {
  1231. format(HouseInfo[houseid][hDescription], 128, "Medium" );
  1232. SendClientMessageEx(playerid, COLOR_WHITE, "You have set the house's class to 2 (Medium)" );
  1233. }
  1234. case 3:
  1235. {
  1236. format(HouseInfo[houseid][hDescription], 128, "High" );
  1237. SendClientMessageEx(playerid, COLOR_WHITE, "You have set the house's class to 3 (High)" );
  1238. }
  1239. }
  1240. if(HouseInfo[houseid][hOwned] ==0)
  1241. {
  1242. format(string, sizeof(string), "This home is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\nID: %d\nTo buy this house type /buyhouse",HouseInfo[houseid][hDescription],HouseInfo[houseid][hValue],HouseInfo[houseid][hLevel],houseid);
  1243. UpdateDynamic3DTextLabelText(HouseInfo[houseid][hTextID], COLOR_GREEN, string);
  1244. }
  1245. }
  1246. SaveHouse(houseid);
  1247. format(string, sizeof(string), "[SHOPHOUSE] %s modified %s on house %d to %d - Invoice %s", GetPlayerNameEx(playerid), choice, houseid, amount, invoice);
  1248. Log("logs/shoplog.log", string);
  1249. return 1;
  1250. }
  1251. CMD:shophousename(playerid, params[])
  1252. {
  1253. if(PlayerInfo[playerid][pShopTech] < 1)
  1254. {
  1255. SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  1256. return 1;
  1257. }
  1258. new string[128], houseid, ownername[MAX_PLAYER_NAME], invoice[64];
  1259. if(sscanf(params, "ds[24]s[64]", houseid, ownername, invoice)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /shophousename [houseid] [name] [invoice]");
  1260. format(HouseInfo[houseid][hOwnerName], sizeof(ownername), "%s", ownername);
  1261. format(string, sizeof(string), "You have set the house owner to %s", ownername);
  1262. HouseInfo[houseid][hOwned] = 1;
  1263. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1264. DestroyDynamicPickup(HouseInfo[houseid][hPickupID]);
  1265. HouseInfo[houseid][hPickupID] = CreateDynamicPickup(1273, 23, HouseInfo[houseid][hExteriorX], HouseInfo[houseid][hExteriorY], HouseInfo[houseid][hExteriorZ], .worldid = HouseInfo[houseid][hExtVW], .interiorid = HouseInfo[houseid][hExtIW]);
  1266. ReloadHouseText(houseid);
  1267. SaveHouse(houseid);
  1268. format(string, sizeof(string), "[SHOPHOUSE] %s modified Owner on house %d to %s - Invoice %s", GetPlayerNameEx(playerid), houseid, ownername, invoice);
  1269. Log("logs/shoplog.log", string);
  1270. return 1;
  1271. }
  1272. CMD:houseinvite(playerid, params[])
  1273. {
  1274. if(Homes[playerid] > 0)
  1275. {
  1276. new giveplayerid, hstring[1024], title[64], zone[MAX_ZONE_NAME];
  1277. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /houseinvite [player]");
  1278. if(gettime()-GetPVarInt(playerid, "LastHouseInvite") < 15) return SendClientMessageEx(playerid, COLOR_GRAD2, "You can only use /houseinvite once every 15 seconds, please wait!");
  1279. if(giveplayerid != INVALID_PLAYER_ID)
  1280. {
  1281. hInviteOfferTo[playerid] = giveplayerid;
  1282. format(title, sizeof(title), "House Invite for %s", GetPlayerNameEx(giveplayerid));
  1283. for(new i; i < MAX_HOUSES; i++)
  1284. {
  1285. if(GetPlayerSQLId(playerid) == HouseInfo[i][hOwnerID])
  1286. {
  1287. Get3DZone(HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ], zone, MAX_ZONE_NAME);
  1288. format(hstring, sizeof(hstring), "%s\nHouse ID %d - Location: %s", hstring, i, zone);
  1289. }
  1290. }
  1291. ShowPlayerDialogEx(playerid, DIALOG_HOUSEINVITE, DIALOG_STYLE_LIST, title, hstring, "Select", "Cancel");
  1292. }
  1293. else return SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid player specified.");
  1294. }
  1295. else return SendClientMessageEx(playerid, COLOR_GREY, "You don't own a house.");
  1296. return 1;
  1297. }
  1298. CMD:hinvite(playerid, params[]) {
  1299. return cmd_houseinvite(playerid, params);
  1300. }
  1301. CMD:setrentable(playerid, params[])
  1302. {
  1303. if(Homes[playerid] > 0)
  1304. {
  1305. for(new i; i < MAX_HOUSES; i++)
  1306. {
  1307. if(GetPlayerSQLId(playerid) == HouseInfo[i][hOwnerID] && ((IsPlayerInRangeOfPoint(playerid, 5.0, HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hExtVW] && GetPlayerInterior(playerid) == HouseInfo[i][hExtIW]) ||
  1308. (IsPlayerInRangeOfPoint(playerid, 50, HouseInfo[i][hInteriorX], HouseInfo[i][hInteriorY], HouseInfo[i][hInteriorZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hIntVW] && GetPlayerInterior(playerid) == HouseInfo[i][hIntIW])))
  1309. {
  1310. if(!HouseInfo[i][hRentable])
  1311. {
  1312. HouseInfo[i][hRentable] = 1;
  1313. ReloadHouseText(i);
  1314. return SendClientMessageEx(playerid, COLOR_WHITE, "This house is now rentable.");
  1315. }
  1316. else
  1317. {
  1318. HouseInfo[i][hRentable] = 0;
  1319. ReloadHouseText(i);
  1320. return SendClientMessageEx(playerid, COLOR_WHITE, "This house is no longer rentable." );
  1321. }
  1322. }
  1323. }
  1324. SendClientMessageEx(playerid, COLOR_GREY, "You're not at a house that you own.");
  1325. }
  1326. else return SendClientMessageEx(playerid, COLOR_GREY, "You don't own a house.");
  1327. return 1;
  1328. }
  1329. CMD:setrent(playerid, params[])
  1330. {
  1331. new string[128], fee;
  1332. if(Homes[playerid] > 0)
  1333. {
  1334. for(new i; i < MAX_HOUSES; i++)
  1335. {
  1336. if(GetPlayerSQLId(playerid) == HouseInfo[i][hOwnerID] && ((IsPlayerInRangeOfPoint(playerid, 5.0, HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hExtVW] && GetPlayerInterior(playerid) == HouseInfo[i][hExtIW]) ||
  1337. (IsPlayerInRangeOfPoint(playerid, 50, HouseInfo[i][hInteriorX], HouseInfo[i][hInteriorY], HouseInfo[i][hInteriorZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hIntVW] && GetPlayerInterior(playerid) == HouseInfo[i][hIntIW])))
  1338. {
  1339. if(sscanf(params, "d", fee)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /setrent [fee]");
  1340. if(!(1 <= fee <= 10000)) return SendClientMessageEx(playerid, COLOR_WHITE, "Minimum rent is $1, maximum rent is $10,000.");
  1341. else
  1342. {
  1343. HouseInfo[i][hRentFee] = fee;
  1344. format(string, sizeof(string), "You have set your house's rent fee to $%s.", number_format(HouseInfo[i][hRentFee]));
  1345. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1346. ReloadHouseText(i);
  1347. return 1;
  1348. }
  1349. }
  1350. }
  1351. SendClientMessageEx(playerid, COLOR_GREY, "You're not at a house that you own.");
  1352. }
  1353. else return SendClientMessageEx(playerid, COLOR_GREY, "You don't own a house.");
  1354. return 1;
  1355. }
  1356. CMD:evict(playerid, params[])
  1357. {
  1358. new string[128], giveplayerid;
  1359. if(Homes[playerid] > 0)
  1360. {
  1361. for(new i; i < MAX_HOUSES; i++)
  1362. {
  1363. if(GetPlayerSQLId(playerid) == HouseInfo[i][hOwnerID] && ((IsPlayerInRangeOfPoint(playerid, 5.0, HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hExtVW] && GetPlayerInterior(playerid) == HouseInfo[i][hExtIW]) ||
  1364. (IsPlayerInRangeOfPoint(playerid, 50, HouseInfo[i][hInteriorX], HouseInfo[i][hInteriorY], HouseInfo[i][hInteriorZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hIntVW] && GetPlayerInterior(playerid) == HouseInfo[i][hIntIW])))
  1365. {
  1366. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /evict [player]");
  1367. if(IsPlayerConnected(giveplayerid))
  1368. {
  1369. if(giveplayerid == playerid) return SendClientMessageEx(playerid, COLOR_WHITE, "You can't evict yourself.");
  1370. else if(PlayerInfo[giveplayerid][pRenting] == i)
  1371. {
  1372. format(string, sizeof(string), "%s has evicted you from their house.", GetPlayerNameEx(playerid));
  1373. SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
  1374. format(string, sizeof(string), "You have evicted %s from your house.", GetPlayerNameEx(giveplayerid));
  1375. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1376. PlayerInfo[giveplayerid][pRenting] = INVALID_HOUSE_ID;
  1377. return 1;
  1378. }
  1379. else return SendClientMessageEx(playerid, COLOR_WHITE, "That person isn't renting at your house.");
  1380. }
  1381. else return SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid player specified.");
  1382. }
  1383. }
  1384. SendClientMessageEx(playerid, COLOR_GREY, "You're not at a house that you own.");
  1385. }
  1386. else return SendClientMessageEx(playerid, COLOR_GREY, "You don't own a house.");
  1387. return 1;
  1388. }
  1389. CMD:evictall(playerid, params[])
  1390. {
  1391. if(Homes[playerid] > 0)
  1392. {
  1393. for(new i; i < MAX_HOUSES; i++)
  1394. {
  1395. if(GetPlayerSQLId(playerid) == HouseInfo[i][hOwnerID] && ((IsPlayerInRangeOfPoint(playerid, 5.0, HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hExtVW] && GetPlayerInterior(playerid) == HouseInfo[i][hExtIW]) ||
  1396. (IsPlayerInRangeOfPoint(playerid, 50, HouseInfo[i][hInteriorX], HouseInfo[i][hInteriorY], HouseInfo[i][hInteriorZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hIntVW] && GetPlayerInterior(playerid) == HouseInfo[i][hIntIW])))
  1397. {
  1398. new giveplayerid, string[56];
  1399. foreach(new p: Player)
  1400. {
  1401. if(PlayerInfo[p][pRenting] == i)
  1402. {
  1403. format(string, sizeof(string), "%s has evicted you from their house.", GetPlayerNameEx(playerid));
  1404. SendClientMessageEx(p, COLOR_WHITE, string);
  1405. PlayerInfo[p][pRenting] = INVALID_HOUSE_ID;
  1406. ++giveplayerid;
  1407. }
  1408. }
  1409. format(string, sizeof(string), "%d online players have been evicted from your house.", giveplayerid);
  1410. return SendClientMessageEx(playerid, COLOR_WHITE, string);
  1411. }
  1412. }
  1413. SendClientMessageEx(playerid, COLOR_GREY, "You're not at a house that you own.");
  1414. }
  1415. else return SendClientMessageEx(playerid, COLOR_GREY, "You don't own a house.");
  1416. return 1;
  1417. }
  1418. CMD:lockhouse(playerid, params[])
  1419. {
  1420. if(PlayerInfo[playerid][pFreezeHouse] != 0) return SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot do this while having your assets frozen!");
  1421. if(Homes[playerid] > 0)
  1422. {
  1423. for(new i; i < MAX_HOUSES; i++)
  1424. {
  1425. if(GetPlayerSQLId(playerid) == HouseInfo[i][hOwnerID] && ((IsPlayerInRangeOfPoint(playerid, 5.0, HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hExtVW] && GetPlayerInterior(playerid) == HouseInfo[i][hExtIW]) ||
  1426. (IsPlayerInRangeOfPoint(playerid, 5.0, HouseInfo[i][hInteriorX], HouseInfo[i][hInteriorY], HouseInfo[i][hInteriorZ]) && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hIntVW] && GetPlayerInterior(playerid) == HouseInfo[i][hIntIW])))
  1427. {
  1428. new szMessage[30 + MAX_PLAYER_NAME];
  1429. if(HouseInfo[i][hLock] == 1)
  1430. {
  1431. HouseInfo[i][hLock] = 0;
  1432. format(szMessage, sizeof(szMessage), "* %s has unlocked their house.", GetPlayerNameEx(playerid));
  1433. return ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  1434. }
  1435. else
  1436. {
  1437. HouseInfo[i][hLock] = 1;
  1438. format(szMessage, sizeof(szMessage), "* %s has locked their house.", GetPlayerNameEx(playerid));
  1439. return ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  1440. }
  1441. }
  1442. }
  1443. SendClientMessageEx(playerid, COLOR_GREY, "You're not at a house that you own.");
  1444. }
  1445. else return SendClientMessageEx(playerid, COLOR_GREY, "You don't own a house.");
  1446. return 1;
  1447. }
  1448. CMD:hstatus(playerid, params[])
  1449. {
  1450. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1 && PlayerInfo[playerid][pShopTech] < 1) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
  1451. new hid;
  1452. if(sscanf(params, "i", hid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /hstatus [hid]");
  1453. new string[128];
  1454. format(string,sizeof(string),"|___________ House Status (ID: %d) (OwnerID: %d)___________|", hid, HouseInfo[hid][hOwnerID]);
  1455. SendClientMessageEx(playerid, COLOR_GREEN, string);
  1456. format(string, sizeof(string), "(Ext) X: %f | Y: %f | Z: %f | (Int) X: %f | Y: %f | Z: %f", HouseInfo[hid][hExteriorX], HouseInfo[hid][hExteriorY], HouseInfo[hid][hExteriorZ], HouseInfo[hid][hInteriorX], HouseInfo[hid][hInteriorY], HouseInfo[hid][hInteriorZ]);
  1457. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1458. format(string, sizeof(string), "Custom Int: %d | Custom Ext: %d | Exterior VW: %d | Exterior Int: %d | Interior VW: %d | Interior Int: %d", HouseInfo[hid][hCustomInterior], HouseInfo[hid][hCustomExterior], HouseInfo[hid][hExtVW], HouseInfo[hid][hExtIW], HouseInfo[hid][hIntVW], HouseInfo[hid][hIntIW]);
  1459. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1460. format(string, sizeof(string), "Money: %d | Pot: %d | Crack: %d | Meth: %d | Ecstasy: %d | Heroin: %d | Materials: %d", HouseInfo[hid][hSafeMoney], HouseInfo[hid][hPot], HouseInfo[hid][hCrack], HouseInfo[hid][hMeth], HouseInfo[hid][hEcstasy], HouseInfo[hid][hHeroin], HouseInfo[hid][hMaterials]);
  1461. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1462. format(string, sizeof(string), "Weapons - %d | %d | %d | %d | %d | GLUpgrade: %d", HouseInfo[hid][hWeapons][0], HouseInfo[hid][hWeapons][1], HouseInfo[hid][hWeapons][2], HouseInfo[hid][hWeapons][3], HouseInfo[hid][hWeapons][4], HouseInfo[hid][hGLUpgrade]);
  1463. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1464. format(string, sizeof(string), "Mailbox - Type: %d | X: %f | Y: %f | Z: %f", HouseInfo[hid][hMailType], HouseInfo[hid][hMailX], HouseInfo[hid][hMailY], HouseInfo[hid][hMailZ]);
  1465. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1466. format(string, sizeof(string), "Closet - X: %f | Y: %f | Z: %f", HouseInfo[hid][hClosetX], HouseInfo[hid][hClosetY], HouseInfo[hid][hClosetZ]);
  1467. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1468. format(string, sizeof(string), "Sale Sign - X: %f | Y: %f | Z: %f", HouseInfo[hid][hSign][0], HouseInfo[hid][hSign][1], HouseInfo[hid][hSign][2]);
  1469. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1470. format(string, sizeof(string), "Sale Sign - Description: %s | Expires in: %s", HouseInfo[hid][hSignDesc], (HouseInfo[hid][hSignExpire]) ? ConvertTimeS(HouseInfo[hid][hSignExpire]-gettime()):("None"));
  1471. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1472. format(string, sizeof(string), "Inactivity - Status: %s | Expires: %s | Ignore: %d (1 = admin | 2 = shop) | Counter: %d", HouseInfo[hid][hInactive] ? ("Inactive"):("Active"), !HouseInfo[hid][hExpire] ? ("N/A"):date(HouseInfo[hid][hExpire], 4), HouseInfo[hid][hIgnore], HouseInfo[hid][hCounter]);
  1473. SendClientMessageEx(playerid, COLOR_WHITE, string);
  1474. return 1;
  1475. }
  1476. CMD:hnear(playerid, params[])
  1477. {
  1478. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1 || PlayerInfo[playerid][pShopTech] >= 1)
  1479. {
  1480. new option;
  1481. if(!sscanf(params, "d", option))
  1482. {
  1483. new string[64];
  1484. format(string, sizeof(string), "* Listing all houses within 30 meters of you in VW %d...", option);
  1485. SendClientMessageEx(playerid, COLOR_RED, string);
  1486. for(new i, szMessage[128]; i < MAX_HOUSES; i++)
  1487. {
  1488. if(option == -1)
  1489. {
  1490. if(IsPlayerInRangeOfPoint(playerid, 30, HouseInfo[i][hInteriorX], HouseInfo[i][hInteriorY], HouseInfo[i][hInteriorZ]) && HouseInfo[i][hIntVW] == option)
  1491. {
  1492. format(szMessage, sizeof(szMessage), "(Interior) House ID %d | %f from you | Interior: %d", i, GetPlayerDistanceFromPoint(playerid, HouseInfo[i][hInteriorX], HouseInfo[i][hInteriorY], HouseInfo[i][hInteriorZ]), HouseInfo[i][hIntIW]);
  1493. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  1494. }
  1495. if(IsPlayerInRangeOfPoint(playerid, 30, HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ]) && HouseInfo[i][hExtVW] == option)
  1496. {
  1497. format(szMessage, sizeof(szMessage), "(Exterior) House ID %d | %f from you | Interior: %d", i, GetPlayerDistanceFromPoint(playerid, HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ]), HouseInfo[i][hExtIW]);
  1498. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  1499. }
  1500. }
  1501. else
  1502. {
  1503. if(IsPlayerInRangeOfPoint(playerid, 30, HouseInfo[i][hInteriorX], HouseInfo[i][hInteriorY], HouseInfo[i][hInteriorZ]) && HouseInfo[i][hIntVW] == option)
  1504. {
  1505. format(szMessage, sizeof(szMessage), "(Interior) House ID %d | %f from you | Interior: %d", i, GetPlayerDistanceFromPoint(playerid, HouseInfo[i][hInteriorX], HouseInfo[i][hInteriorY], HouseInfo[i][hInteriorZ]), HouseInfo[i][hIntIW]);
  1506. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  1507. }
  1508. if(IsPlayerInRangeOfPoint(playerid, 30, HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ]) && HouseInfo[i][hExtVW] == option)
  1509. {
  1510. format(szMessage, sizeof(szMessage), "(Exterior) House ID %d | %f from you | Interior: %d", i, GetPlayerDistanceFromPoint(playerid, HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ]), HouseInfo[i][hExtIW]);
  1511. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  1512. }
  1513. }
  1514. }
  1515. }
  1516. else
  1517. {
  1518. SendClientMessageEx(playerid, COLOR_RED, "* Listing all houses within 30 meters of you...");
  1519. for(new i, szMessage[128]; i < MAX_HOUSES; i++)
  1520. {
  1521. if(IsPlayerInRangeOfPoint(playerid, 30, HouseInfo[i][hInteriorX], HouseInfo[i][hInteriorY], HouseInfo[i][hInteriorZ]) && HouseInfo[i][hIntVW] == GetPlayerVirtualWorld(playerid))
  1522. {
  1523. format(szMessage, sizeof(szMessage), "(Interior) House ID %d | %f from you | Interior: %d", i, GetPlayerDistanceFromPoint(playerid, HouseInfo[i][hInteriorX], HouseInfo[i][hInteriorY], HouseInfo[i][hInteriorZ]), HouseInfo[i][hIntIW]);
  1524. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  1525. }
  1526. if(IsPlayerInRangeOfPoint(playerid, 30, HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ]) && HouseInfo[i][hExtVW] == GetPlayerVirtualWorld(playerid))
  1527. {
  1528. format(szMessage, sizeof(szMessage), "(Exterior) House ID %d | %f from you | Interior: %d", i, GetPlayerDistanceFromPoint(playerid, HouseInfo[i][hExteriorX], HouseInfo[i][hExteriorY], HouseInfo[i][hExteriorZ]), HouseInfo[i][hExtIW]);
  1529. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  1530. }
  1531. }
  1532. }
  1533. }
  1534. else
  1535. {
  1536. SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  1537. }
  1538. return 1;
  1539. }
  1540. CMD:hmove(playerid, params[])
  1541. {
  1542. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use this command.");
  1543. new houseid, giveplayerid, fee, minfee, choice[16];
  1544. if(sscanf(params, "s[16]dudd", choice, houseid, giveplayerid, fee, minfee))
  1545. {
  1546. SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /hmove <Choice> <HouseID> <playerid> <Fine (Percent)> <min. fine>");
  1547. SendClientMessageEx(playerid, COLOR_GREY, "Choice: Exterior | Interior");
  1548. SendClientMessageEx(playerid, COLOR_GREY, "NOTE: Set fine as 0 if you don't want to fine this player.");
  1549. return 1;
  1550. }
  1551. new string[128];
  1552. new Float: Pos[3];
  1553. new totalwealth = PlayerInfo[giveplayerid][pAccount] + GetPlayerCash(giveplayerid);
  1554. if(PlayerInfo[giveplayerid][pPhousekey] != INVALID_HOUSE_ID && HouseInfo[PlayerInfo[giveplayerid][pPhousekey]][hOwnerID] == GetPlayerSQLId(giveplayerid)) totalwealth += HouseInfo[PlayerInfo[giveplayerid][pPhousekey]][hSafeMoney];
  1555. if(PlayerInfo[giveplayerid][pPhousekey2] != INVALID_HOUSE_ID && HouseInfo[PlayerInfo[giveplayerid][pPhousekey2]][hOwnerID] == GetPlayerSQLId(giveplayerid)) totalwealth += HouseInfo[PlayerInfo[giveplayerid][pPhousekey2]][hSafeMoney];
  1556. if(PlayerInfo[giveplayerid][pPhousekey3] != INVALID_HOUSE_ID && HouseInfo[PlayerInfo[giveplayerid][pPhousekey3]][hOwnerID] == GetPlayerSQLId(giveplayerid)) totalwealth += HouseInfo[PlayerInfo[giveplayerid][pPhousekey3]][hSafeMoney];
  1557. if(fee > 0)
  1558. {
  1559. fee = totalwealth / 100 * fee;
  1560. if(PlayerInfo[giveplayerid][pDonateRank] == 3)
  1561. {
  1562. fee = fee / 100 * 95;
  1563. }
  1564. if(PlayerInfo[giveplayerid][pDonateRank] >= 4)
  1565. {
  1566. fee = fee / 100 * 85;
  1567. }
  1568. }
  1569. if(strcmp(choice, "interior", true) == 0)
  1570. {
  1571. GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  1572. format(string, sizeof(string), "%s has edited HouseID %d's Interior. (Before: %f, %f, %f | After: %f, %f, %f)", GetPlayerNameEx(playerid), houseid, HouseInfo[houseid][hInteriorX], HouseInfo[houseid][hInteriorY], HouseInfo[houseid][hInteriorZ], Pos[0], Pos[1], Pos[2]);
  1573. Log("logs/hedit.log", string);
  1574. GetPlayerPos(playerid, HouseInfo[houseid][hInteriorX], HouseInfo[houseid][hInteriorY], HouseInfo[houseid][hInteriorZ]);
  1575. GetPlayerFacingAngle(playerid, HouseInfo[houseid][hInteriorA]);
  1576. HouseInfo[houseid][hIntIW] = GetPlayerInterior( playerid );
  1577. HouseInfo[houseid][hIntVW] = houseid+6000;
  1578. SendClientMessageEx( playerid, COLOR_WHITE, "You have changed the interior!" );
  1579. SaveHouse(houseid);
  1580. if(minfee > fee && minfee > 0)
  1581. {
  1582. GivePlayerCashEx(giveplayerid, TYPE_ONHAND, -minfee);
  1583. format(string, sizeof(string), "AdmCmd: %s(%d) was fined $%s by %s, reason: House Move", GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), number_format(minfee), GetPlayerNameEx(playerid));
  1584. Log("logs/admin.log", string);
  1585. format(string, sizeof(string), "AdmCmd: %s was fined $%s by %s, reason: House Move", GetPlayerNameEx(giveplayerid), number_format(minfee), GetPlayerNameEx(playerid));
  1586. SendClientMessageToAllEx(COLOR_LIGHTRED, string);
  1587. }
  1588. else if(fee > 0)
  1589. {
  1590. GivePlayerCashEx(giveplayerid, TYPE_ONHAND, -fee);
  1591. format(string, sizeof(string), "AdmCmd: %s(%d) was fined $%s by %s, reason: House Move", GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), number_format(fee), GetPlayerNameEx(playerid));
  1592. Log("logs/admin.log", string);
  1593. format(string, sizeof(string), "AdmCmd: %s was fined $%s by %s, reason: House Move", GetPlayerNameEx(giveplayerid), number_format(fee), GetPlayerNameEx(playerid));
  1594. SendClientMessageToAllEx(COLOR_LIGHTRED, string);
  1595. }
  1596. }
  1597. else if(strcmp(choice, "exterior", true) == 0)
  1598. {
  1599. GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  1600. format(string, sizeof(string), "%s has edited HouseID %d's Exterior. (Before: %f, %f, %f | After: %f, %f, %f)", GetPlayerNameEx(playerid), houseid, HouseInfo[houseid][hExteriorX], HouseInfo[houseid][hExteriorY], HouseInfo[houseid][hExteriorZ], Pos[0], Pos[1], Pos[2]);
  1601. Log("logs/hedit.log", string);
  1602. GetPlayerPos(playerid, HouseInfo[houseid][hExteriorX], HouseInfo[houseid][hExteriorY], HouseInfo[houseid][hExteriorZ]);
  1603. GetPlayerFacingAngle(playerid, HouseInfo[houseid][hExteriorA]);
  1604. HouseInfo[houseid][hExtIW] = GetPlayerInterior(playerid);
  1605. HouseInfo[houseid][hExtVW] = GetPlayerVirtualWorld(playerid);
  1606. SendClientMessageEx( playerid, COLOR_WHITE, "You have changed the exterior!" );
  1607. SaveHouse(houseid);
  1608. ReloadHousePickup(houseid);
  1609. if(minfee > fee && minfee > 0)
  1610. {
  1611. GivePlayerCashEx(giveplayerid, TYPE_ONHAND, -minfee);
  1612. format(string, sizeof(string), "AdmCmd: %s(%d) was fined $%s by %s, reason: House Move", GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), number_format(minfee), GetPlayerNameEx(playerid));
  1613. Log("logs/admin.log", string);
  1614. format(string, sizeof(string), "AdmCmd: %s was fined $%s by %s, reason: House Move", GetPlayerNameEx(giveplayerid), number_format(minfee), GetPlayerNameEx(playerid));
  1615. SendClientMessageToAllEx(COLOR_LIGHTRED, string);
  1616. }
  1617. else if(fee > 0)
  1618. {
  1619. GivePlayerCashEx(giveplayerid, TYPE_ONHAND, -fee);
  1620. format(string, sizeof(string), "AdmCmd: %s(%d) was fined $%s by %s, reason: House Move", GetPlayerNameEx(giveplayerid), GetPlayerSQLId(giveplayerid), number_format(fee), GetPlayerNameEx(playerid));
  1621. Log("logs/admin.log", string);
  1622. format(string, sizeof(string), "AdmCmd: %s was fined $%s by %s, reason: House Move", GetPlayerNameEx(giveplayerid), number_format(fee), GetPlayerNameEx(playerid));
  1623. SendClientMessageToAllEx(COLOR_LIGHTRED, string);
  1624. }
  1625. }
  1626. return 1;
  1627. }
  1628. CMD:houselights(playerid, params[]) {
  1629. new i = GetHouseID(playerid);
  1630. if(i == INVALID_HOUSE_ID) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not in a house.");
  1631. if(HouseInfo[i][h_iLights] == 0) {
  1632. HouseInfo[i][h_iLights] = 1;
  1633. SaveHouse(i);
  1634. format(szMiscArray, sizeof(szMiscArray), "* %s hits the light switch, switching the house lights off.", GetPlayerNameEx(playerid));
  1635. ProxChatBubble(playerid, szMiscArray);
  1636. foreach(new p : Player) if(GetPlayerVirtualWorld(p) == HouseInfo[i][hIntVW] && GetPlayerInterior(p) == HouseInfo[i][hIntIW]) TextDrawShowForPlayer(p, g_tHouseLights);
  1637. }
  1638. else {
  1639. HouseInfo[i][h_iLights] = 0;
  1640. SaveHouse(i);
  1641. format(szMiscArray, sizeof(szMiscArray), "* %s hits the light switch, switching the house lights on.", GetPlayerNameEx(playerid));
  1642. ProxChatBubble(playerid, szMiscArray);
  1643. foreach(new p : Player) if(GetPlayerVirtualWorld(p) == HouseInfo[i][hIntVW] && GetPlayerInterior(p) == HouseInfo[i][hIntIW]) TextDrawHideForPlayer(p, g_tHouseLights);
  1644. }
  1645. return 1;
  1646. }
  1647. stock ClearHouse(houseid) {
  1648. HouseInfo[houseid][hOwned] = 0;
  1649. HouseInfo[houseid][hSafeMoney] = 0;
  1650. HouseInfo[houseid][hPot] = 0;
  1651. HouseInfo[houseid][hCrack] = 0;
  1652. HouseInfo[houseid][hMaterials] = 0;
  1653. HouseInfo[houseid][hEcstasy] = 0;
  1654. HouseInfo[houseid][hMeth] = 0;
  1655. HouseInfo[houseid][hHeroin] = 0;
  1656. for(new i = 0; i < 5; i++)
  1657. {
  1658. HouseInfo[houseid][hWeapons][i] = 0;
  1659. }
  1660. HouseInfo[houseid][hGLUpgrade] = 1;
  1661. HouseInfo[houseid][hClosetX] = 0.0;
  1662. HouseInfo[houseid][hClosetY] = 0.0;
  1663. HouseInfo[houseid][hClosetZ] = 0.0;
  1664. DestroyDynamic3DTextLabel(Text3D:HouseInfo[houseid][hClosetTextID]);
  1665. format(HouseInfo[houseid][hSignDesc], 64, "None");
  1666. HouseInfo[houseid][hSign][0] = 0.0;
  1667. HouseInfo[houseid][hSign][1] = 0.0;
  1668. HouseInfo[houseid][hSign][2] = 0.0;
  1669. HouseInfo[houseid][hSign][3] = 0.0;
  1670. HouseInfo[houseid][hSignExpire] = 0;
  1671. if(IsValidDynamicObject(HouseInfo[houseid][hSignObj])) DestroyDynamicObject(HouseInfo[houseid][hSignObj]);
  1672. if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hSignText])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hSignText]);
  1673. }
  1674. stock InRangeOfWhichHouse(playerid, Float: range)
  1675. {
  1676. if (PlayerInfo[playerid][pPhousekey] != INVALID_HOUSE_ID && IsPlayerInRangeOfPoint(playerid,range,HouseInfo[PlayerInfo[playerid][pPhousekey]][hExteriorX], HouseInfo[PlayerInfo[playerid][pPhousekey]][hExteriorY], HouseInfo[PlayerInfo[playerid][pPhousekey]][hExteriorZ]) && GetPlayerInterior(playerid) == HouseInfo[PlayerInfo[playerid][pPhousekey]][hExtIW] && GetPlayerVirtualWorld(playerid) == HouseInfo[PlayerInfo[playerid][pPhousekey]][hExtVW]) return PlayerInfo[playerid][pPhousekey];
  1677. if (PlayerInfo[playerid][pPhousekey2] != INVALID_HOUSE_ID && IsPlayerInRangeOfPoint(playerid,range,HouseInfo[PlayerInfo[playerid][pPhousekey2]][hExteriorX], HouseInfo[PlayerInfo[playerid][pPhousekey2]][hExteriorY], HouseInfo[PlayerInfo[playerid][pPhousekey2]][hExteriorZ]) && GetPlayerInterior(playerid) == HouseInfo[PlayerInfo[playerid][pPhousekey2]][hExtIW] && GetPlayerVirtualWorld(playerid) == HouseInfo[PlayerInfo[playerid][pPhousekey2]][hExtVW]) return PlayerInfo[playerid][pPhousekey2];
  1678. if (PlayerInfo[playerid][pPhousekey3] != INVALID_HOUSE_ID && IsPlayerInRangeOfPoint(playerid,range,HouseInfo[PlayerInfo[playerid][pPhousekey3]][hExteriorX], HouseInfo[PlayerInfo[playerid][pPhousekey3]][hExteriorY], HouseInfo[PlayerInfo[playerid][pPhousekey3]][hExteriorZ]) && GetPlayerInterior(playerid) == HouseInfo[PlayerInfo[playerid][pPhousekey3]][hExtIW] && GetPlayerVirtualWorld(playerid) == HouseInfo[PlayerInfo[playerid][pPhousekey3]][hExtVW]) return PlayerInfo[playerid][pPhousekey3];
  1679. return INVALID_HOUSE_ID;
  1680. }
  1681. forward DeleteHouse(houseid, adminid);
  1682. public DeleteHouse(houseid, adminid)
  1683. {
  1684. HouseInfo[houseid][hOwned] = 0;
  1685. HouseInfo[houseid][hLevel] = 0;
  1686. HouseInfo[houseid][hCustomInterior] = 0;
  1687. HouseInfo[houseid][hOwnerID] = -1;
  1688. format(HouseInfo[houseid][hOwnerName], MAX_PLAYER_NAME, "Nobody");
  1689. HouseInfo[houseid][hExteriorX] = 0.0;
  1690. HouseInfo[houseid][hExteriorY] = 0.0;
  1691. HouseInfo[houseid][hExteriorZ] = 0.0;
  1692. HouseInfo[houseid][hExteriorR] = 0.0;
  1693. HouseInfo[houseid][hExteriorA] = 0;
  1694. HouseInfo[houseid][hInteriorX] = 0.0;
  1695. HouseInfo[houseid][hInteriorY] = 0.0;
  1696. HouseInfo[houseid][hInteriorZ] = 0.0;
  1697. HouseInfo[houseid][hInteriorR] = 0.0;
  1698. HouseInfo[houseid][hInteriorA] = 0;
  1699. HouseInfo[houseid][hExtIW] = 0;
  1700. HouseInfo[houseid][hExtVW] = 0;
  1701. HouseInfo[houseid][hIntIW] = 0;
  1702. HouseInfo[houseid][hIntVW] = 0;
  1703. HouseInfo[houseid][hLock] = 0;
  1704. HouseInfo[houseid][hRentable] = 0;
  1705. HouseInfo[houseid][hRentFee] = 0;
  1706. HouseInfo[houseid][hValue] = 0;
  1707. HouseInfo[houseid][hSafeMoney] = 0;
  1708. HouseInfo[houseid][hPot] = 0;
  1709. HouseInfo[houseid][hCrack] = 0;
  1710. HouseInfo[houseid][hMaterials] = 0;
  1711. HouseInfo[houseid][hWeapons][0] = 0;
  1712. HouseInfo[houseid][hWeapons][1] = 0;
  1713. HouseInfo[houseid][hWeapons][2] = 0;
  1714. HouseInfo[houseid][hWeapons][3] = 0;
  1715. HouseInfo[houseid][hWeapons][4] = 0;
  1716. HouseInfo[houseid][hGLUpgrade] = 0;
  1717. if(IsValidDynamicPickup(HouseInfo[houseid][hPickupID])) DestroyDynamicPickup(HouseInfo[houseid][hPickupID]), HouseInfo[houseid][hPickupID] = -1;
  1718. if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hTextID])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hTextID]), HouseInfo[houseid][hTextID] = Text3D:-1;
  1719. HouseInfo[houseid][hCustomExterior] = 0;
  1720. HouseInfo[houseid][hMailX] = 0.0;
  1721. HouseInfo[houseid][hMailY] = 0.0;
  1722. HouseInfo[houseid][hMailZ] = 0.0;
  1723. HouseInfo[houseid][hMailA] = 0.0;
  1724. if(IsValidDynamicObject(HouseInfo[houseid][hMailObjectId])) DestroyDynamicObject(HouseInfo[houseid][hMailObjectId]), HouseInfo[houseid][hMailObjectId] = -1;
  1725. if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hMailTextID])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hMailTextID]), HouseInfo[houseid][hMailTextID] = Text3D:-1;
  1726. HouseInfo[houseid][hClosetX] = 0.0;
  1727. HouseInfo[houseid][hClosetY] = 0.0;
  1728. HouseInfo[houseid][hClosetZ] = 0.0;
  1729. if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hClosetTextID])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hClosetTextID]), HouseInfo[houseid][hClosetTextID] = Text3D:-1;
  1730. HouseInfo[houseid][hSignDesc][0] = 0;
  1731. HouseInfo[houseid][hSign][0] = 0.0;
  1732. HouseInfo[houseid][hSign][1] = 0.0;
  1733. HouseInfo[houseid][hSign][2] = 0.0;
  1734. HouseInfo[houseid][hSign][3] = 0.0;
  1735. HouseInfo[houseid][hSignExpire] = 0;
  1736. if(IsValidDynamicObject(HouseInfo[houseid][hSignObj])) DestroyDynamicObject(HouseInfo[houseid][hSignObj]), HouseInfo[houseid][hSignObj] = -1;
  1737. if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hSignText])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hSignText]), HouseInfo[houseid][hSignText] = Text3D:-1;
  1738. HouseInfo[houseid][hLastLogin] = 0;
  1739. HouseInfo[houseid][hExpire] = 0;
  1740. HouseInfo[houseid][hInactive] = 0;
  1741. HouseInfo[houseid][hIgnore] = 0;
  1742. HouseInfo[houseid][hCounter] = 0;
  1743. SaveHouse(houseid);
  1744. szMiscArray[0] = 0;
  1745. format(szMiscArray, sizeof(szMiscArray), "%s has deleted house id %d", adminid != INVALID_PLAYER_ID ? GetPlayerNameEx(adminid) : ("(Inactive Player Resource System)"), houseid);
  1746. Log("logs/hedit.log", szMiscArray);
  1747. return 1;
  1748. }
  1749. /*
  1750. CMD:housefix(playerid, params[]) {
  1751. new Float:fPos[3];
  1752. GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2]);
  1753. for(new houseid; houseid < MAX_HOUSES; ++houseid) {
  1754. GetXYInFrontOfPlayer(playerid, fPos[0], fPos[1], houseid+1);
  1755. HouseInfo[houseid][hExteriorX] = fPos[0];
  1756. HouseInfo[houseid][hExteriorY] = fPos[1];
  1757. HouseInfo[houseid][hExteriorZ] = fPos[2];
  1758. HouseInfo[houseid][hExteriorR] = 0.0;
  1759. HouseInfo[houseid][hExteriorA] = 0.0;
  1760. HouseInfo[houseid][hInteriorX] = fPos[0];
  1761. HouseInfo[houseid][hInteriorY] = fPos[1]+1;
  1762. HouseInfo[houseid][hInteriorZ] = fPos[2];
  1763. HouseInfo[houseid][hInteriorR] = 0.0;
  1764. HouseInfo[houseid][hInteriorA] = 0.0;
  1765. HouseInfo[houseid][hIntIW] = GetPlayerInterior(playerid);
  1766. HouseInfo[houseid][hIntVW] = GetPlayerVirtualWorld(playerid);
  1767. HouseInfo[houseid][hExtIW] = GetPlayerInterior(playerid);
  1768. HouseInfo[houseid][hExtVW] = GetPlayerVirtualWorld(playerid);
  1769. SendClientMessageEx(playerid, COLOR_WHITE, "You're streakinnnnn houses!" );
  1770. SaveHouse(houseid);
  1771. ReloadHousePickup(houseid);
  1772. }
  1773. return 1;
  1774. }
  1775. */