mailsystem.pwn 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Mail 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. #define MAILBOX_RANGE 8.0
  34. stock SaveMailboxes()
  35. {
  36. for(new i = 0; i < MAX_MAILBOXES; i++)
  37. {
  38. SaveMailbox(i);
  39. }
  40. return 1;
  41. }
  42. stock IsAtPostOffice(playerid)
  43. {
  44. return IsPlayerInRangeOfPoint(playerid,100.0,-262.0643, 6.0924, 2000.9038);
  45. }
  46. stock IsNearHouseMailbox(playerid)
  47. {
  48. if (PlayerInfo[playerid][pPhousekey] != INVALID_HOUSE_ID && IsPlayerInRangeOfPoint(playerid,3.0,HouseInfo[PlayerInfo[playerid][pPhousekey]][hMailX], HouseInfo[PlayerInfo[playerid][pPhousekey]][hMailY], HouseInfo[PlayerInfo[playerid][pPhousekey]][hMailZ])) return 1;
  49. if (PlayerInfo[playerid][pPhousekey2] != INVALID_HOUSE_ID && IsPlayerInRangeOfPoint(playerid,3.0,HouseInfo[PlayerInfo[playerid][pPhousekey2]][hMailX], HouseInfo[PlayerInfo[playerid][pPhousekey2]][hMailY], HouseInfo[PlayerInfo[playerid][pPhousekey2]][hMailZ])) return 1;
  50. if (PlayerInfo[playerid][pPhousekey3] != INVALID_HOUSE_ID && IsPlayerInRangeOfPoint(playerid,3.0,HouseInfo[PlayerInfo[playerid][pPhousekey3]][hMailX], HouseInfo[PlayerInfo[playerid][pPhousekey3]][hMailY], HouseInfo[PlayerInfo[playerid][pPhousekey3]][hMailZ])) return 1;
  51. return 0;
  52. }
  53. stock IsNearPublicMailbox(playerid)
  54. {
  55. for(new i = 0; i < sizeof(MailBoxes); i++) if (IsPlayerInRangeOfPoint(playerid, 3.0, MailBoxes[i][mbPosX], MailBoxes[i][mbPosY], MailBoxes[i][mbPosZ])) return 1;
  56. return 0;
  57. }
  58. stock DisplayStampDialog(playerid)
  59. {
  60. ShowPlayerDialogEx(playerid, DIALOG_POSTAMP, DIALOG_STYLE_LIST, "Buy a stamp", "Regular Mail $100\nPriority Mail $250\nPremium Mail $500 (Gold VIP+)\nGovernment Mail Free", "Next", "Cancel");
  61. }
  62. stock RenderHouseMailbox(h)
  63. {
  64. DestroyDynamicObject(HouseInfo[h][hMailObjectId]);
  65. DestroyDynamic3DTextLabel(HouseInfo[h][hMailTextID]);
  66. if (HouseInfo[h][hMailX] != 0.0)
  67. {
  68. HouseInfo[h][hMailObjectId] = CreateDynamicObject((HouseInfo[h][hMailType] == 1) ? 1478 : 3407, HouseInfo[h][hMailX], HouseInfo[h][hMailY], HouseInfo[h][hMailZ], 0, 0, HouseInfo[h][hMailA]);
  69. new string[10];
  70. format(string, sizeof(string), "HID: %d",h);
  71. HouseInfo[h][hMailTextID] = CreateDynamic3DTextLabel(string, 0xFFFFFF88, HouseInfo[h][hMailX], HouseInfo[h][hMailY], HouseInfo[h][hMailZ]+0.5,10.0, .streamdistance = 10.0);
  72. }
  73. }
  74. stock RenderStreetMailbox(id)
  75. {
  76. DestroyDynamicObject(MailBoxes[id][mbObjectId]);
  77. DestroyDynamic3DTextLabel(MailBoxes[id][mbTextId]);
  78. if(MailBoxes[id][mbPosX] != 0.0)
  79. {
  80. new string[128];
  81. MailBoxes[id][mbObjectId] = CreateDynamicObject(1258, MailBoxes[id][mbPosX], MailBoxes[id][mbPosY], MailBoxes[id][mbPosZ], 0.0, 0.0, MailBoxes[id][mbAngle], MailBoxes[id][mbVW], MailBoxes[id][mbInt], .streamdistance = 100.0);
  82. format(string,sizeof(string),"Mailbox (ID: %d)\nType /sendmail to send a letter.", id);
  83. MailBoxes[id][mbTextId] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, MailBoxes[id][mbPosX], MailBoxes[id][mbPosY], MailBoxes[id][mbPosZ] + 0.5, 10.0, .worldid = MailBoxes[id][mbVW], .testlos = 0, .streamdistance = 25.0);
  84. }
  85. }
  86. stock HasMailbox(playerid)
  87. {
  88. if (PlayerInfo[playerid][pPhousekey] != INVALID_HOUSE_ID && HouseInfo[PlayerInfo[playerid][pPhousekey]][hMailX] != 0.0) return 1;
  89. if (PlayerInfo[playerid][pPhousekey2] != INVALID_HOUSE_ID && HouseInfo[PlayerInfo[playerid][pPhousekey2]][hMailX] != 0.0) return 1;
  90. if (PlayerInfo[playerid][pPhousekey3] != INVALID_HOUSE_ID && HouseInfo[PlayerInfo[playerid][pPhousekey3]][hMailX] != 0.0) return 1;
  91. return 0;
  92. }
  93. stock GetFreeMailboxId()
  94. {
  95. for (new i; i < MAX_MAILBOXES; i++) {
  96. if (MailBoxes[i][mbPosX] == 0.0) return i;
  97. }
  98. return -1;
  99. }
  100. stock ClearHouseMailbox(houseid)
  101. {
  102. HouseInfo[houseid][hMailX] = 0.0;
  103. HouseInfo[houseid][hMailY] = 0.0;
  104. HouseInfo[houseid][hMailZ] = 0.0;
  105. HouseInfo[houseid][hMailA] = 0.0;
  106. HouseInfo[houseid][hMailType] = 0;
  107. SaveHouse(houseid);
  108. }
  109. stock ClearStreetMailbox(boxid)
  110. {
  111. MailBoxes[boxid][mbVW] = 0;
  112. MailBoxes[boxid][mbInt] = 0;
  113. MailBoxes[boxid][mbModel] = 0;
  114. MailBoxes[boxid][mbPosX] = 0.0;
  115. MailBoxes[boxid][mbPosY] = 0.0;
  116. MailBoxes[boxid][mbPosZ] = 0.0;
  117. MailBoxes[boxid][mbAngle] = 0.0;
  118. SaveMailbox(boxid);
  119. }
  120. CMD:mailhelp(playerid, params[])
  121. {
  122. SetPVarInt(playerid, "HelpResultCat0", 7);
  123. Help_ListCat(playerid, DIALOG_HELPCATOTHER1);
  124. return 1;
  125. }
  126. CMD:omailhelp(playerid, params[])
  127. {
  128. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Mail System Help");
  129. SendClientMessageEx(playerid, COLOR_GRAD2, "You can purchase writing paper from any 24/7 and send letters to your friends");
  130. SendClientMessageEx(playerid, COLOR_GRAD2, "and colleagues regardless of whether they are online or not. Letters can be sent");
  131. SendClientMessageEx(playerid, COLOR_GRAD2, "from your nearest Street Posting Box, or from your own mail box (at your own house)");
  132. SendClientMessageEx(playerid, COLOR_GRAD2, "and these will be delivered; time depending on which service you have purchased.");
  133. SendClientMessageEx(playerid, COLOR_GRAD3, "Mail System Commands: /sendmail /getmail /placemailbox /movemailbox /destroymailbox /postdirectory");
  134. if(PlayerInfo[playerid][pAdmin] > 3)
  135. {
  136. SendClientMessageEx(playerid, COLOR_WHITE, "Admin Commands");
  137. SendClientMessageEx(playerid, COLOR_GRAD1, "/createmailbox (Creates a street posting box) /removemailbox [id] (Removes a street posting box)");
  138. SendClientMessageEx(playerid, COLOR_GRAD1, "/gotomailbox [id] (Teleports to a street posting box) /adestroymailbox [houseid] (Deletes a players mailbox)");
  139. }
  140. return 1;
  141. }
  142. CMD:sendmail(playerid, params[])
  143. {
  144. if (!IsNearHouseMailbox(playerid) && !IsAtPostOffice(playerid) && !IsNearPublicMailbox(playerid)) {
  145. return SendClientMessageEx(playerid, COLOR_GREY, "You need to be at a post office, near a street mailbox, or your house mailbox.");
  146. }
  147. if (PlayerInfo[playerid][pPaper] < 1) {
  148. return SendClientMessageEx(playerid, COLOR_GREY, "You don't have any papers left. You can buy some at a 24/7.");
  149. }
  150. if(GetPVarInt(playerid, "MailTime") > 0) {
  151. new string[64];
  152. format(string, sizeof(string), "You must wait %d seconds before sending more mail.", GetPVarInt(playerid, "MailTime"));
  153. return SendClientMessageEx(playerid, COLOR_GREY, string);
  154. }
  155. DisplayStampDialog(playerid);
  156. return 1;
  157. }
  158. CMD:getmail(playerid, params[])
  159. {
  160. if (!IsNearHouseMailbox(playerid) && !IsAtPostOffice(playerid)) {
  161. return SendClientMessageEx(playerid, COLOR_GREY, "You need to be near at a post office or near your house mailbox.");
  162. }
  163. DeletePVar(playerid, "UnreadMails");
  164. DisplayMails(playerid);
  165. return 1;
  166. }
  167. CMD:createmailbox(playerid, params[])
  168. {
  169. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) {
  170. return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use this command.");
  171. }
  172. if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING) {
  173. return SendClientMessageEx(playerid, COLOR_GRAD2, "You can not do this while spectating.");
  174. }
  175. new i = GetFreeMailboxId();
  176. if (i == -1) return SendClientMessageEx(playerid, COLOR_GRAD1, "The maximum number of street mailboxes has been reached.");
  177. GetPlayerPos(playerid, MailBoxes[i][mbPosX], MailBoxes[i][mbPosY], MailBoxes[i][mbPosZ]);
  178. GetPlayerFacingAngle(playerid, MailBoxes[i][mbAngle]);
  179. MailBoxes[i][mbPosZ] -= 0.30;
  180. MailBoxes[i][mbInt] = GetPlayerInterior(playerid);
  181. MailBoxes[i][mbVW] = GetPlayerVirtualWorld(playerid);
  182. SaveMailbox(i);
  183. RenderStreetMailbox(i);
  184. new string[128], area[MAX_ZONE_NAME];
  185. format(string,sizeof(string),"You have successfully created a street mailbox with ID %d.", i);
  186. SendClientMessageEx(playerid, COLOR_GRAD2, string);
  187. GetPlayer2DZone(playerid, area, MAX_ZONE_NAME);
  188. format(string, sizeof(string), "Admin %s has placed street mailbox %d at %s", GetPlayerNameEx(playerid), i, area);
  189. Log("logs/mail.log", string);
  190. Streamer_UpdateEx(playerid, MailBoxes[i][mbPosX], MailBoxes[i][mbPosY], MailBoxes[i][mbPosZ]);
  191. return 1;
  192. }
  193. CMD:removemailbox(playerid, params[])
  194. {
  195. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) {
  196. return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use this command.");
  197. }
  198. new id;
  199. if(sscanf(params, "d", id)) {
  200. return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /removemailbox [street mailbox id]");
  201. }
  202. if(id < 0 || id >= MAX_MAILBOXES) {
  203. return SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid street mailbox ID.");
  204. }
  205. if(MailBoxes[id][mbPosX] == 0.0) {
  206. return SendClientMessageEx(playerid, COLOR_GRAD2, "No street mailbox found with that ID.");
  207. }
  208. ClearStreetMailbox(id);
  209. RenderStreetMailbox(id);
  210. new string[128], area[MAX_ZONE_NAME];
  211. format(string,sizeof(string),"You have successfully removed the street mailbox with ID %d.", id);
  212. SendClientMessageEx(playerid, COLOR_GRAD2, string);
  213. GetPlayer2DZone(playerid, area, MAX_ZONE_NAME);
  214. format(string, sizeof(string), "Administrator %s has removed a street mailbox %d, at %s", GetPlayerNameEx(playerid), id, area);
  215. Log("logs/mail.log", string);
  216. return 1;
  217. }
  218. CMD:gotomailbox(playerid, params[])
  219. {
  220. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) {
  221. return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use this command.");
  222. }
  223. new id;
  224. if(sscanf(params, "d", id)) {
  225. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /gotomailbox [street mailbox id]");
  226. return 1;
  227. }
  228. if(id < 0 || id >= MAX_MAILBOXES) {
  229. return SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid street mailbox ID.");
  230. }
  231. if(MailBoxes[id][mbPosX] == 0.0) {
  232. return SendClientMessageEx(playerid, COLOR_GRAD2, "No street mailbox found with that ID.");
  233. }
  234. GameTextForPlayer(playerid, "~w~Teleporting", 5000, 1);
  235. SetPlayerVirtualWorld(playerid, MailBoxes[id][mbVW]);
  236. SetPlayerInterior(playerid, MailBoxes[id][mbInt]);
  237. SetPlayerPos(playerid,MailBoxes[id][mbPosX],MailBoxes[id][mbPosY] - 2.5,MailBoxes[id][mbPosZ]);
  238. PlayerInfo[playerid][pVW] = MailBoxes[id][mbVW];
  239. PlayerInfo[playerid][pInt] = MailBoxes[id][mbInt];
  240. return 1;
  241. }
  242. CMD:placemailbox(playerid, params[])
  243. {
  244. if (PlayerInfo[playerid][pPhousekey] == INVALID_HOUSE_ID && PlayerInfo[playerid][pPhousekey2] == INVALID_HOUSE_ID && PlayerInfo[playerid][pPhousekey3] == INVALID_HOUSE_ID) {
  245. return SendClientMessageEx(playerid, COLOR_GRAD2, "You don't own a house!");
  246. }
  247. if (PlayerInfo[playerid][pMailbox] < 1) {
  248. return SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have a mailbox item!");
  249. }
  250. new style;
  251. if (sscanf(params, "d", style)) {
  252. return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /placemailbox [1 or 2] (1=wooden 2=steel)");
  253. }
  254. if (HasMailbox(playerid)) {
  255. return SendClientMessageEx(playerid, COLOR_GRAD2, "You already have a mailbox placed. You cannot place more.");
  256. }
  257. if (GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) {
  258. return SendClientMessageEx(playerid, COLOR_GRAD2, "You must be on foot to use this command!");
  259. }
  260. new h = InRangeOfWhichHouse(playerid, MAILBOX_RANGE);
  261. if (h == INVALID_HOUSE_ID) {
  262. return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not at your house!");
  263. }
  264. new Float: f_ZOffset;
  265. if (style == 1) f_ZOffset = -0.38; else if (style == 2) f_ZOffset = -0.95;
  266. else return SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid number!");
  267. PlayerInfo[playerid][pMailbox]--;
  268. GetPlayerPos(playerid, HouseInfo[h][hMailX], HouseInfo[h][hMailY], HouseInfo[h][hMailZ]);
  269. GetPlayerFacingAngle(playerid, HouseInfo[h][hMailA]);
  270. HouseInfo[h][hMailZ] += f_ZOffset;
  271. HouseInfo[h][hMailType] = style;
  272. SaveHouse(h);
  273. RenderHouseMailbox(h);
  274. SendClientMessageEx(playerid, COLOR_WHITE, "You have successfully placed your mailbox!");
  275. SendClientMessageEx(playerid, COLOR_GRAD2, "HINT: If you need to change the location of your mailbox, you can type /movemailbox" );
  276. new szLog[128];
  277. format(szLog, sizeof(szLog), "%s(%d) has placed a mailbox for their house (House ID: %d)", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), h);
  278. Log("logs/house.log", szLog);
  279. return 1;
  280. }
  281. CMD:destroymailbox(playerid, params[])
  282. {
  283. if (!HasMailbox(playerid)) {
  284. return SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have a placed mailbox.");
  285. }
  286. new h;
  287. if (PlayerInfo[playerid][pPhousekey] != INVALID_HOUSE_ID && IsPlayerInRangeOfPoint(playerid,3.0,HouseInfo[PlayerInfo[playerid][pPhousekey]][hMailX], HouseInfo[PlayerInfo[playerid][pPhousekey]][hMailY], HouseInfo[PlayerInfo[playerid][pPhousekey]][hMailZ])) h = PlayerInfo[playerid][pPhousekey];
  288. else if (PlayerInfo[playerid][pPhousekey2] != INVALID_HOUSE_ID && IsPlayerInRangeOfPoint(playerid,3.0,HouseInfo[PlayerInfo[playerid][pPhousekey2]][hMailX], HouseInfo[PlayerInfo[playerid][pPhousekey2]][hMailY], HouseInfo[PlayerInfo[playerid][pPhousekey2]][hMailZ])) h = PlayerInfo[playerid][pPhousekey2];
  289. else if (PlayerInfo[playerid][pPhousekey3] != INVALID_HOUSE_ID && IsPlayerInRangeOfPoint(playerid,3.0,HouseInfo[PlayerInfo[playerid][pPhousekey3]][hMailX], HouseInfo[PlayerInfo[playerid][pPhousekey3]][hMailY], HouseInfo[PlayerInfo[playerid][pPhousekey3]][hMailZ])) h = PlayerInfo[playerid][pPhousekey3];
  290. else return SendClientMessageEx(playerid, COLOR_GREY, "You need to be near your mailbox.");
  291. ClearHouseMailbox(h);
  292. RenderHouseMailbox(h);
  293. SendClientMessageEx(playerid, COLOR_WHITE, "You have destroyed your mailbox.");
  294. new szLog[128];
  295. format(szLog, sizeof(szLog), "%s(%d) has destroyed their house mailbox (House ID: %d)", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), h);
  296. Log("logs/house.log", szLog);
  297. return 1;
  298. }
  299. CMD:movemailbox(playerid, params[])
  300. {
  301. if (!HasMailbox(playerid)) {
  302. return SendClientMessageEx(playerid, COLOR_GREY, "You don't have a placed mailbox!");
  303. }
  304. new h = InRangeOfWhichHouse(playerid, MAILBOX_RANGE);
  305. if (h == INVALID_HOUSE_ID || HouseInfo[h][hMailX] == 0.0) {
  306. return SendClientMessageEx(playerid, COLOR_GREY, "You are too far away from your house door for the new location of your mailbox!");
  307. }
  308. GetPlayerPos(playerid, HouseInfo[h][hMailX], HouseInfo[h][hMailY], HouseInfo[h][hMailZ]);
  309. GetPlayerFacingAngle(playerid, HouseInfo[h][hMailA]);
  310. new Float: f_ZOffset;
  311. if (HouseInfo[h][hMailType] == 1) f_ZOffset = -0.38; else if (HouseInfo[h][hMailType] == 2) f_ZOffset = -0.95;
  312. HouseInfo[h][hMailZ] += f_ZOffset;
  313. SaveHouse(h);
  314. RenderHouseMailbox(h);
  315. SendClientMessageEx(playerid, COLOR_WHITE, "You have successfully moved your mailbox to its new position!");
  316. return 1;
  317. }
  318. CMD:adestroymailbox(playerid, params[])
  319. {
  320. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) {
  321. return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use this command.");
  322. }
  323. new houseid;
  324. if(sscanf(params,"d",houseid)) {
  325. return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /adestroymailbox [houseid]");
  326. }
  327. if (houseid < 0 || houseid >= MAX_HOUSES) {
  328. return SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid house ID!");
  329. }
  330. if (HouseInfo[houseid][hMailX] == 0.0) {
  331. return SendClientMessageEx(playerid, COLOR_GRAD2, "That house does not have a mailbox.");
  332. }
  333. ClearHouseMailbox(houseid);
  334. RenderHouseMailbox(houseid);
  335. new string[64];
  336. format(string, sizeof(string), "You have destroyed the mailbox of house %d.", houseid);
  337. SendClientMessageEx(playerid, COLOR_GREY, string);
  338. foreach(new i: Player)
  339. {
  340. if(PlayerInfo[i][pPhousekey] == houseid || PlayerInfo[i][pPhousekey2] == houseid || PlayerInfo[i][pPhousekey3] == houseid) {
  341. format(string, sizeof(string), "Administrator %s has destroyed your mailbox.", GetPlayerNameEx(playerid));
  342. SendClientMessageEx(i, COLOR_GREY, string);
  343. break;
  344. }
  345. }
  346. format(string, sizeof(string), "Administrator %s has destroyed the mailbox of house %d.", GetPlayerNameEx(playerid), houseid);
  347. Log("logs/house.log", string);
  348. return 1;
  349. }
  350. CMD:postdirectory(playerid, params[])
  351. {
  352. if (!IsAtPostOffice(playerid)) {
  353. return SendClientMessageEx(playerid, COLOR_GREY, "You're not at a post office!");
  354. }
  355. if(strcmp(params, "on", true) == 0) {
  356. PlayerInfo[playerid][pMailEnabled] = 1;
  357. SendClientMessage(playerid, COLOR_WHITE, "You have enabled look up in the postal directory.");
  358. }
  359. else if(strcmp(params, "off", true) == 0) {
  360. PlayerInfo[playerid][pMailEnabled] = 0;
  361. SendClientMessage(playerid, COLOR_WHITE, "You have disabled look up in the postal directory.");
  362. }
  363. else {
  364. SendClientMessage(playerid, COLOR_GREY, "USAGE: /postdirectory [on/off]");
  365. }
  366. return 1;
  367. }
  368. CMD:mnear(playerid, params[])
  369. {
  370. if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  371. SendClientMessageEx(playerid, COLOR_RED, "* Listing all mailboxes within 30 meters of you...");
  372. for(new i, szMessage[32]; i < MAX_HOUSES; i++)
  373. {
  374. if(IsPlayerInRangeOfPoint(playerid, 30, HouseInfo[i][hMailX], HouseInfo[i][hMailY], HouseInfo[i][hMailZ]))
  375. {
  376. format(szMessage, sizeof(szMessage), "ID %d | %f from you", i, GetPlayerDistanceFromPoint(playerid, HouseInfo[i][hMailX], HouseInfo[i][hMailY], HouseInfo[i][hMailZ]));
  377. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  378. }
  379. }
  380. return 1;
  381. }