christmas.inc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. /*=================
  2. Christmas Event 2017
  3. by Jay Cortez
  4. =================*/
  5. #define CHRISTMAS_FILE "christmas.ini"
  6. #define CHRISTMAS_SOUND "http://k007.kiwi6.com/hotlink/s8lgc8cam9/Christmas_Shadow2.mp3"
  7. #define CHRISTMAS_SONG "http://k007.kiwi6.com/hotlink/ruihyflkl6/Christmas_Shadow.mp3"
  8. #define INVALID_PRESENT_ID -1
  9. #define MAX_PRESENTS 10
  10. #define PRESENTS_TO_FIND 15
  11. new christmasEnabled = 0;
  12. new christmasAuthorized[] = {
  13. 7378
  14. };
  15. new presentTypes[][] = {
  16. {19054, "Red Christmas Present"},
  17. {19055, "Yellow & Red Christmas Present"},
  18. {19056, "Rainbow Christmas Present"},
  19. {19057, "Red & Yellow Christmas Present"},
  20. {19058, "Blue Christmas Present"}
  21. };
  22. new Float:presentLocations[][] = {
  23. {1923.0643,-1762.3568,13.5391},
  24. {2109.9890,-1777.3737,13.3907},
  25. {1705.5219,-1723.8135,13.5469},
  26. {1516.0220,-1722.7667,13.5469},
  27. {1541.5997,-1671.5204,13.5529},
  28. {1903.6632,-1442.9767,13.5117},
  29. {1920.2618,-1375.3816,13.6091},
  30. {1531.3605,-1027.1975,24.0147},
  31. {1353.8766,-1096.8927,24.0971},
  32. {1135.6216,-1413.0117,13.6376},
  33. {369.8156,-1849.8510,7.6719},
  34. {290.6794,-1630.2468,33.3401},
  35. {347.7054,-1514.2289,33.0747},
  36. {708.8488,-1415.4913,13.5358},
  37. {1037.6407,-1843.1703,13.5818},
  38. {1282.5315,-1844.9580,13.5508},
  39. {1355.9678,-1751.0450,13.3735},
  40. {2133.3059,-1497.4581,23.9849},
  41. {2414.8562,-1537.9738,24.0000},
  42. {2713.3225,-1648.8042,13.2279},
  43. {1968.4695,-2174.6074,13.5469},
  44. {1936.4542,-1596.8789,13.5499},
  45. {2410.6375,-1248.8066,23.8125},
  46. {2117.5510,-1732.9569,18.0628},
  47. {2391.9080,-1742.1482,13.5469},
  48. {2487.1521,-1666.0365,13.3438},
  49. {2031.2340,-1416.0886,16.9922},
  50. {2059.5017,-1889.0714,20.0000},
  51. {1778.4739,-1775.4453,52.4688},
  52. {1515.2535,-1360.3254,190.8017},
  53. {899.8443,-1034.9996,95.0234},
  54. {167.7834,-1752.6432,5.2969},
  55. {260.8490,-1278.7782,85.3526},
  56. {1332.1227,-639.5985,114.0349},
  57. {1501.0984,-692.8601,94.7500},
  58. {1492.1064,-691.5677,94.7500},
  59. {1482.3835,-692.0007,94.7500},
  60. {1490.2380,-688.5726,94.7500},
  61. {1496.2780,-692.0362,94.7500},
  62. {1711.0038,-1100.2721,24.0781},
  63. {2765.8777,-387.3180,24.0012},
  64. {2766.7366,745.2954,10.8984},
  65. {2509.4263,1138.4695,14.2705},
  66. {2402.1475,1436.4952,15.8785},
  67. {2003.0099,1544.2897,13.5859},
  68. {1549.8978,1638.7437,10.8203},
  69. {1332.2155,1732.2617,10.8203},
  70. {1352.4668,1456.9900,10.8203},
  71. {1468.9412,1233.1780,10.8203},
  72. {1008.7559,1715.4512,10.7812},
  73. {982.1673,2565.6033,10.7362},
  74. {1050.7916,2914.4824,51.6622},
  75. {526.8539,2889.4993,6.8025},
  76. {297.2083,2597.2588,16.4766},
  77. {406.4179,2444.6936,16.5000},
  78. {-38.2261,2341.3547,24.1347},
  79. {-85.8060,2265.3003,125.1710},
  80. {-531.4526,1819.6948,138.2234},
  81. {-656.6006,1443.8218,13.6172},
  82. {-888.7077,1566.5927,25.9626},
  83. {-1536.8787,1001.0336,7.1875},
  84. {-1598.9923,659.5249,7.1875},
  85. {-1981.5541,266.9110,35.1719},
  86. {-2126.2427,148.9365,41.3019},
  87. {-2314.5317,101.1132,35.3984},
  88. {-2377.8179,-292.0763,59.3936},
  89. {-2126.6611,-275.7707,35.3203},
  90. {-1974.6483,-527.6316,35.3359},
  91. {-1620.1541,-665.3140,14.1440},
  92. {-1308.3027,-559.6769,14.1484},
  93. {-1154.6984,-208.9685,14.1484},
  94. {-1313.3345,102.6179,14.1484},
  95. {-596.4524,68.4913,43.9777},
  96. {-224.5625,-249.6571,1.4219},
  97. {171.7638,-14.3514,1.5781},
  98. {157.5365,-22.1955,1.5781},
  99. {324.5787,-198.7598,1.4920},
  100. {1122.4186,-287.2077,73.8129},
  101. {1559.1276,10.8809,23.9632},
  102. {1625.1815,581.4196,1.7578},
  103. {2155.0894,-107.1400,2.6539},
  104. {2265.7678,-72.5365,31.6016},
  105. {2326.8777,-80.2703,30.4834},
  106. {2541.8303,112.2299,26.4902},
  107. {2662.3743,-296.2203,14.1665},
  108. {1807.0404,-616.0289,77.0387},
  109. {1550.8274,-498.7066,54.6592},
  110. {1386.5234,-1114.2797,58.3991},
  111. {1301.4193,-1225.7799,37.9531},
  112. {-1054.5088, -603.6898, 96.7427},
  113. {-2666.5193, 244.3681, 14.3594},
  114. {-2809.4402, 1306.9690, 7.0988},
  115. {-2642.2285, 1414.5215, 23.8926},
  116. {-2383.6694, 1552.5946, 31.8533},
  117. {-2226.6655, 2348.1104, 4.9922},
  118. {-2444.4158, 2281.2566, 14.8993},
  119. {-2588.8020, 2363.0974, 20.1265},
  120. {-2276.7622, 2657.8733, 73.5156},
  121. {-1936.8396, 2381.2119, 49.5000},
  122. {-1803.7517, 2052.3096, 8.9615},
  123. {-1451.9252, 1868.9146, 32.6328},
  124. {-1056.9927, 1520.1509, 34.1801},
  125. {-7.4227, 1110.3088, 19.8172},
  126. {45.7702, 1213.4840, 18.9785},
  127. {162.4819, 1172.7228, 14.7661},
  128. {593.2874, 1225.0688, 11.7188},
  129. {623.0258, 893.0629, -35.3267},
  130. {1555.3420, 657.4982, 10.6719},
  131. {2603.6555, 728.9846, 10.8203},
  132. {2690.8113, 2786.4495, 59.0212},
  133. {2006.7072, 2911.8855, 51.6622},
  134. {-54.6163, 109.0044, 25.9801},
  135. {-460.3113, -51.1667, 59.9477},
  136. {-965.6066, -335.0024, 36.2742},
  137. {2169.8899, -1999.0215, 35.6163},
  138. {2390.2244, -2251.1938, 20.0573},
  139. {2598.4265, -1531.8612, 13.1181},
  140. {1775.3646, -1317.3688, 120.2004},
  141. {1834.1492, -1281.2981, 131.7344},
  142. {1526.5842, -1359.1451, 329.4609},
  143. {1535.2523, -1348.1117, 329.4544},
  144. {897.1519, -1257.6948, 49.3380},
  145. {1094.0325, -2037.0026, 82.7541},
  146. {2347.3511, -2109.9158, 39.0501},
  147. {2515.3931, -2073.1558, 49.2500},
  148. {1347.9032, -1556.3813, 85.5469},
  149. {387.3426, -2024.7762, 8.3496},
  150. {454.6707, -2271.9153, 12.1031},
  151. {306.4088, -1511.5515, 76.5362}
  152. };
  153. enum presentEnum {
  154. bool:presentUsed = false,
  155. presentModel,
  156. Float:presentX,
  157. Float:presentY,
  158. Float:presentZ,
  159. presentPickup,
  160. Text3D:presentLabel
  161. };
  162. new PresentInfo[MAX_PRESENTS][presentEnum];
  163. new bool:tempPresent[MAX_PLAYERS];
  164. new christmasTrack[MAX_PLAYERS];
  165. Hook:chr_OnGameModeInit() {
  166. loadChristmasEvent();
  167. return 1;
  168. }
  169. Hook:chr_OnGameModeExit() {
  170. saveChristmasEvent();
  171. return 1;
  172. }
  173. Hook:chr_OnPlayerConnect(playerid) {
  174. tempPresent[playerid] = false;
  175. christmasTrack[playerid] = gettime();
  176. return 1;
  177. }
  178. CMD:christmascredits(playerid, params[]) {
  179. if(!christmasEnabled)
  180. return 1;
  181. SendClientMessage(playerid, COLOR_WHITE, "The christmas event 2018 was made by:");
  182. SendClientMessage(playerid, 0xF6FC4DFF, "Not Shadow :P");
  183. return 1;
  184. }
  185. CMD:christmashelp(playerid, params[]) {
  186. if(!christmasEnabled)
  187. return 1;
  188. SendClientMessage(playerid, 0xFF0000, "______________________{4D8906}______________________");
  189. new chrStr[128];
  190. format(chrStr, sizeof(chrStr), "** Find all %i presents for an awesome reward! **", PRESENTS_TO_FIND);
  191. SendClientMessage(playerid, COLOR_WHITE, chrStr);
  192. SendClientMessage(playerid, COLOR_WHITE, "** The presents are hidden all around the map! You can use /trackpresent for a hint! **");
  193. SendClientMessage(playerid, COLOR_WHITE, "Christmas commands: /christmashelp /getpresent /trackpresent /givepresent /christmascredits");
  194. if(isChristmasMod(playerid)) {
  195. SendClientMessage(playerid, COLOR_WHITE, "Christmas mod: /togglechristmas /gotopresent /allowreward /resetchristmas /christmasad");
  196. }
  197. return 1;
  198. }
  199. CMD:claimreward(playerid, params[]) {
  200. if(!christmasEnabled)
  201. return 1;
  202. if(PlayerInfo[playerid][pPresentCount] < PRESENTS_TO_FIND)
  203. return SendClientMessage(playerid, COLOR_GREY, "You have not completed the present hunt.");
  204. if(PlayerInfo[playerid][pPresentCount] == 99)
  205. return SendClientMessage(playerid, COLOR_GREY, "You have already claimed a reward!");
  206. new rewardID;
  207. if(sscanf(params, "i", rewardID)) {
  208. SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/claimreward (reward number)");
  209. ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Available rewards",
  210. "To claim your reward, use /claimreward (reward number)\n\n\
  211. {FFFFFF}[1] 20 Tikis\n\
  212. {FFFFFF}[2] 50g Cocaine & 10 tikis\n\
  213. {FFFFFF}[3] 100 Meth & 5 tikis\n\
  214. {FFFFFF}[4] 20k Materials\n\
  215. {FFFFFF}[5] Random stuff[100g cocaine or 200g cannabis or 100k mats or 500 meth]",
  216. "Close", "");
  217. return 1;
  218. }
  219. if(rewardID < 1 || rewardID > 5)
  220. return SendClientMessage(playerid, COLOR_GREY, "You picked an invalid reward!");
  221. PlayAudioStreamForPlayer(playerid, CHRISTMAS_SONG);
  222. switch(rewardID) {
  223. case 1: {
  224. PlayerInfo[playerid][pTikis] += 20;
  225. SendClientMessage(playerid, COLOR_PURPLE, "Reward: 20 tikis.");
  226. }
  227. case 2: {
  228. PlayerInfo[playerid][pTikis] += 10;
  229. PlayerInfo[playerid][pCocaine] += 50;
  230. SendClientMessage(playerid, COLOR_PURPLE, "Reward: 50g Cocaine and 10 tikis.");
  231. }
  232. case 3: {
  233. PlayerInfo[playerid][pTikis] += 5;
  234. PlayerInfo[playerid][pMeth] += 100;
  235. SendClientMessage(playerid, COLOR_PURPLE, "Reward: 100 Meth and 5 tikis.");
  236. }
  237. case 4: {
  238. PlayerInfo[playerid][pMats] += 20000;
  239. SendClientMessage(playerid, COLOR_PURPLE, "Reward: 20,000 Materials.");
  240. }
  241. case 5: {
  242. new randomWep = random(4);
  243. switch(randomWep) {
  244. case 0: {
  245. PlayerInfo[playerid][pCocaine] += 100;
  246. SendClientMessage(playerid, COLOR_PURPLE, "Reward: 100g Cocaine");
  247. }
  248. case 1: {
  249. PlayerInfo[playerid][pCannabis] += 200;
  250. SendClientMessage(playerid, COLOR_PURPLE, "Reward: 200g Cannabis");
  251. }
  252. case 2: {
  253. PlayerInfo[playerid][pMats] += 100000;
  254. SendClientMessage(playerid, COLOR_PURPLE, "Reward: 100,000 Materials");
  255. }
  256. case 3: {
  257. PlayerInfo[playerid][pMeth] += 500;
  258. SendClientMessage(playerid, COLOR_PURPLE, "Reward: 500 Meth");
  259. }
  260. }
  261. }
  262. }
  263. SendClientMessage(playerid, COLOR_PURPLE, "Thanks for participating in the Christmas Event 2017. :)");
  264. SendClientMessage(playerid, COLOR_PURPLE, "Created by Not Shadow :P");
  265. PlayerInfo[playerid][pPresentCount] = 99;
  266. ShowMerryChristmas(playerid, 1);
  267. return 1;
  268. }
  269. CMD:trackpresent(playerid, params[]) {
  270. if(!christmasEnabled)
  271. return 1;
  272. if(gettime() - christmasTrack[playerid] < 120)
  273. return SendClientMessage(playerid, COLOR_GREY, "You can use this once every two minutes.");
  274. new presID = random(MAX_PRESENTS), presLoc[MAX_ZONE_NAME];
  275. Get2DZone(presLoc, MAX_ZONE_NAME, PresentInfo[presID][presentX], PresentInfo[presID][presentY], PresentInfo[presID][presentZ]);
  276. new Float:presDist = GetPlayerDistanceFromPoint(playerid, PresentInfo[presID][presentX], PresentInfo[presID][presentY], PresentInfo[presID][presentZ]);
  277. new giftStr[128];
  278. format(giftStr, sizeof(giftStr), "A present was spotted in %s! (%im distance from you)", presLoc, floatround(presDist, floatround_ceil));
  279. SendClientMessage(playerid, COLOR_GREY, giftStr);
  280. christmasTrack[playerid] = gettime();
  281. return 1;
  282. }
  283. CMD:getpresent(playerid, params[]) {
  284. if(!christmasEnabled)
  285. return 1;
  286. if(tempPresent[playerid])
  287. return SendClientMessage(playerid, COLOR_GREY, "You are already holding a present. (/givepresent)");
  288. if(PlayerInfo[playerid][pPresentCount] >= PRESENTS_TO_FIND && PlayerInfo[playerid][pPresentCount] != 99)
  289. return SendClientMessage(playerid, COLOR_GREY, "Claim your reward first! /claimreward");
  290. new nearbyPres = getNearbyPresent(playerid, 3.0);
  291. if(nearbyPres == INVALID_PRESENT_ID)
  292. return SendClientMessage(playerid, COLOR_GREY, "You aren't near any present.");
  293. randomizePresent(nearbyPres);
  294. // Visual/sound
  295. OnePlayAnim(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
  296. PlayAudioStreamForPlayer(playerid, CHRISTMAS_SOUND);
  297. // Chat
  298. SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You have found a present!");
  299. if(PlayerInfo[playerid][pPresentCount] <= PRESENTS_TO_FIND) {
  300. PlayerInfo[playerid][pPresentCount]++;
  301. new chrStr[128];
  302. format(chrStr, sizeof(chrStr), " [%i/%i] presents found. (/christmashelp)", PlayerInfo[playerid][pPresentCount], PRESENTS_TO_FIND);
  303. SendClientMessage(playerid, COLOR_LIGHTBLUE, chrStr);
  304. if(PlayerInfo[playerid][pPresentCount] == PRESENTS_TO_FIND) {
  305. SendClientMessage(playerid, COLOR_LIGHTBLUE, "You can now claim your Christmas reward! /claimreward");
  306. }
  307. }
  308. else {
  309. tempPresent[playerid] = true;
  310. SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You have already claimed your reward, you can now do other players a favor!");
  311. SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You can gift this present to players who have not claimed their reward yet! (/givepresent)");
  312. }
  313. return 1;
  314. }
  315. CMD:givepresent(playerid, params[]) {
  316. if(!christmasEnabled)
  317. return 1;
  318. if(PlayerInfo[playerid][pPresentCount] <= PRESENTS_TO_FIND)
  319. return SendClientMessage(playerid, COLOR_GREY, "You can only do this after claiming your reward. (/claimreward)");
  320. if(!tempPresent[playerid])
  321. return SendClientMessage(playerid, COLOR_GREY, "You don't have any present on you.");
  322. new targetPl;
  323. if(sscanf(params, "u", targetPl))
  324. return SendClientMessage(playerid, COLOR_GREY, "Usage: /givepresent (player)");
  325. if(!IsPlayerConnected(targetPl))
  326. return SendClientMessage(playerid, COLOR_GREY, "Unknown player!");
  327. if(targetPl == playerid)
  328. return cmd_ame(playerid, "gives themselves a present.");
  329. if(!IsPlayerInRangeOfPlayer(2.0, playerid, targetPl))
  330. return SendClientMessage(playerid, COLOR_GREY, "You are not near this player.");
  331. if(PlayerInfo[targetPl][pPresentCount] >= PRESENTS_TO_FIND)
  332. return SendClientMessage(playerid, COLOR_GREY, "This player doesn't need your gift.");
  333. if(IsPlayerInAnyVehicle(playerid) || IsPlayerInAnyVehicle(targetPl))
  334. return SendClientMessage(playerid, COLOR_GREY, "You and the player should not be in a vehicle.");
  335. SetPlayerFacingPlayer(playerid, targetPl);
  336. SetPlayerFacingPlayer(targetPl, playerid);
  337. OnePlayAnim(playerid, "KISSING", "gift_give", 4.0, 0, 0, 0, 0, 0);
  338. SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You have gifted that player a present! +$15,000 for karma!");
  339. SendClientMessage(targetPl, COLOR_LIGHTBLUE, "* You have received a present from a player!");
  340. new giftStr[128];
  341. format(giftStr, sizeof(giftStr), "* %s hides something behind their back before they reveal a gift, hands it over to %s.", PlayerICName(playerid), PlayerICName(targetPl));
  342. ProxDetector(30.0, playerid, giftStr, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  343. tempPresent[playerid] = false;
  344. PlayerInfo[playerid][pPresentCount] = 99;
  345. PlayerInfo[targetPl][pPresentCount]++;
  346. if(PlayerInfo[targetPl][pPresentCount] == PRESENTS_TO_FIND) {
  347. SendClientMessage(targetPl, COLOR_LIGHTBLUE, "* You have completed the Christmas event, thanks to the gift! /claimreward");
  348. }
  349. return 1;
  350. }
  351. CMD:christmasad(playerid, params[]) {
  352. if(!isChristmasMod(playerid))
  353. return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to do this.");
  354. SendClientMessageToAll(TEAM_GROVE_COLOR, "Advertisement [Ph: 555] Ho ho ho! Merry Christmas! Have you found all presents yet?");
  355. SendClientMessageToAll(TEAM_GROVE_COLOR, "(( /christmashelp ))");
  356. return 1;
  357. }
  358. CMD:togglechristmas(playerid, params[]) {
  359. if(!isChristmasMod(playerid))
  360. return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to do this.");
  361. if(christmasEnabled) {
  362. christmasEnabled = 0;
  363. destroyAllPresents();
  364. SendClientMessage(playerid, COLOR_LIGHTBLUE, "Christmas event disabled!");
  365. }
  366. else {
  367. christmasEnabled = 1;
  368. randomizeAllPresents();
  369. SendClientMessage(playerid, COLOR_LIGHTBLUE, "Christmas event enabled!");
  370. }
  371. return 1;
  372. }
  373. CMD:allowreward(playerid, params[]) {
  374. if(!isChristmasMod(playerid))
  375. return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to do this.");
  376. if(!christmasEnabled)
  377. return SendClientMessage(playerid, COLOR_GREY, "Christmas event is disabled. (/togglechristmas)");
  378. new targetPl;
  379. if(sscanf(params, "u", targetPl))
  380. return SendClientMessage(playerid, COLOR_GREY, "Usage: /allowreward (player)");
  381. if(!IsPlayerConnected(targetPl))
  382. return SendClientMessage(playerid, COLOR_GREY, "Unknown player.");
  383. PlayerInfo[targetPl][pPresentCount] = PRESENTS_TO_FIND;
  384. SendClientMessage(playerid, COLOR_LIGHTBLUE, "That player can now /claimreward.");
  385. SendClientMessage(targetPl, COLOR_LIGHTBLUE, "A christmas mod has refunded your reward. (/claimreward)");
  386. return 1;
  387. }
  388. CMD:resetchristmas(playerid, params[]) {
  389. if(!isChristmasMod(playerid))
  390. return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to do this.");
  391. if(!christmasEnabled)
  392. return SendClientMessage(playerid, COLOR_GREY, "Christmas event is disabled. (/togglechristmas)");
  393. new targetPl;
  394. if(sscanf(params, "u", targetPl))
  395. return SendClientMessage(playerid, COLOR_GREY, "Usage: /resetchristmas (player)");
  396. if(!IsPlayerConnected(targetPl))
  397. return SendClientMessage(playerid, COLOR_GREY, "Unknown player.");
  398. PlayerInfo[targetPl][pPresentCount] = 0;
  399. SendClientMessage(playerid, COLOR_LIGHTBLUE, "The christmas event progress of this player has been reset!");
  400. return 1;
  401. }
  402. CMD:gotopresent(playerid, params[]) {
  403. if(!isChristmasMod(playerid))
  404. return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to do this.");
  405. if(!christmasEnabled)
  406. return SendClientMessage(playerid, COLOR_GREY, "Christmas event is disabled. (/togglechristmas)");
  407. new presID;
  408. if(sscanf(params, "i", presID))
  409. return SendClientMessage(playerid, COLOR_GREY, "Usage: /gotopresent (id)");
  410. if(presID < 0 || presID > MAX_PRESENTS - 1)
  411. return SendClientMessage(playerid, COLOR_GREY, "Invalid present ID!");
  412. if(!PresentInfo[presID][presentUsed])
  413. return SendClientMessage(playerid, COLOR_GREY, "This present ID is not occupied at the moment.");
  414. SetPlayerPos(playerid, PresentInfo[presID][presentX], PresentInfo[presID][presentY], PresentInfo[presID][presentZ]);
  415. new chrStr[128];
  416. format(chrStr, sizeof(chrStr), "Teleported to present: [%i]", presID);
  417. SendClientMessage(playerid, -1, chrStr);
  418. return 1;
  419. }
  420. forward ShowMerryChristmas(playerid, stage);
  421. public ShowMerryChristmas(playerid, stage) {
  422. switch(stage) {
  423. case 1:
  424. GameTextForPlayer(playerid, "~g~M", 1000, 4);
  425. case 2:
  426. GameTextForPlayer(playerid, "~g~M~r~E", 1000, 4);
  427. case 3:
  428. GameTextForPlayer(playerid, "~g~M~r~E~g~R", 1000, 4);
  429. case 4:
  430. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R", 1000, 4);
  431. case 5:
  432. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y", 1000, 4);
  433. case 6:
  434. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y ~r~C", 1000, 4);
  435. case 7:
  436. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y ~r~C~g~H", 1000, 4);
  437. case 8:
  438. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y ~r~C~g~H~r~R", 1000, 4);
  439. case 9:
  440. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y ~r~C~g~H~r~R~g~I", 1000, 4);
  441. case 10:
  442. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y ~r~C~g~H~r~R~g~I~r~S", 1000, 4);
  443. case 11:
  444. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y ~r~C~g~H~r~R~g~I~r~S~g~T", 1000, 4);
  445. case 12:
  446. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y ~r~C~g~H~r~R~g~I~r~S~g~T~r~M", 1000, 4);
  447. case 13:
  448. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y ~r~C~g~H~r~R~g~I~r~S~g~T~r~M~g~A", 1000, 4);
  449. case 14:
  450. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y ~r~C~g~H~r~R~g~I~r~S~g~T~r~M~g~A~r~S", 1000, 4);
  451. case 15:
  452. GameTextForPlayer(playerid, "", 1000, 4);
  453. case 16:
  454. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y ~r~C~g~H~r~R~g~I~r~S~g~T~r~M~g~A~r~S", 1000, 4);
  455. case 17:
  456. GameTextForPlayer(playerid, "", 1000, 4);
  457. case 18:
  458. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y ~r~C~g~H~r~R~g~I~r~S~g~T~r~M~g~A~r~S", 1000, 4);
  459. case 19:
  460. GameTextForPlayer(playerid, "", 1000, 4);
  461. case 20:
  462. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y ~r~C~g~H~r~R~g~I~r~S~g~T~r~M~g~A~r~S", 1000, 4);
  463. case 21:
  464. GameTextForPlayer(playerid, "~g~M~r~E~g~R~r~R~g~Y ~r~C~g~H~r~R~g~I~r~S~g~T~r~M~g~A~r~S~n~~w~from Shadow!", 3000, 4);
  465. }
  466. if(stage < 21) {
  467. SetTimerEx("ShowMerryChristmas", 500, false, "ii", playerid, stage + 1);
  468. }
  469. return 1;
  470. }
  471. getNearbyPresent(playerid, Float:range) {
  472. if(GetPlayerVirtualWorld(playerid) != 0 || GetPlayerInterior(playerid) != 0)
  473. return INVALID_PRESENT_ID;
  474. for(new i = 0; i < MAX_PRESENTS; i++) {
  475. if(PresentInfo[i][presentUsed]) {
  476. if(IsPlayerInRangeOfPoint(playerid, range, PresentInfo[i][presentX], PresentInfo[i][presentY], PresentInfo[i][presentZ]))
  477. return i;
  478. }
  479. }
  480. return INVALID_PRESENT_ID;
  481. }
  482. loadChristmasEvent() {
  483. if(fexist(CHRISTMAS_FILE)) {
  484. christmasEnabled = dini_Int(CHRISTMAS_FILE, "christmasEnabled");
  485. }
  486. if(christmasEnabled) randomizeAllPresents();
  487. return 1;
  488. }
  489. saveChristmasEvent() {
  490. if(!fexist(CHRISTMAS_FILE))
  491. dini_Create(CHRISTMAS_FILE);
  492. dini_IntSet(CHRISTMAS_FILE, "christmasEnabled", christmasEnabled);
  493. return 1;
  494. }
  495. isChristmasMod(playerid) {
  496. for(new i = 0; i < sizeof(christmasAuthorized); i++) {
  497. if(PlayerInfo[playerid][pID] == christmasAuthorized[i])
  498. return 1;
  499. }
  500. return 0;
  501. }
  502. randomizeAllPresents() {
  503. for(new i = 0; i < MAX_PRESENTS; i++) {
  504. randomizePresent(i);
  505. }
  506. return 1;
  507. }
  508. destroyAllPresents() {
  509. for(new i = 0; i < MAX_PRESENTS; i++) {
  510. destroyPresent(i);
  511. }
  512. return 1;
  513. }
  514. destroyPresent(presentID) {
  515. PresentInfo[presentID][presentUsed] = false;
  516. DestroyDynamicPickup(PresentInfo[presentID][presentPickup]);
  517. DestroyDynamic3DTextLabel(PresentInfo[presentID][presentLabel]);
  518. return 1;
  519. }
  520. randomizePresent(presentID) {
  521. if(PresentInfo[presentID][presentUsed]) {
  522. destroyPresent(presentID);
  523. }
  524. PresentInfo[presentID][presentUsed] = true;
  525. // Get a random present type
  526. new pickedType = random(sizeof(presentTypes));
  527. // Set the location
  528. new pickedLocation = random(sizeof(presentLocations));
  529. while(locationHasPresent(pickedLocation)) {
  530. pickedLocation = random(sizeof(presentLocations));
  531. }
  532. PresentInfo[presentID][presentX] = presentLocations[pickedLocation][0];
  533. PresentInfo[presentID][presentY] = presentLocations[pickedLocation][1];
  534. PresentInfo[presentID][presentZ] = presentLocations[pickedLocation][2];
  535. // Set the model and create pickup
  536. PresentInfo[presentID][presentModel] = presentTypes[pickedType][0];
  537. PresentInfo[presentID][presentPickup] = CreateDynamicPickup(PresentInfo[presentID][presentModel], 1, PresentInfo[presentID][presentX], PresentInfo[presentID][presentY], PresentInfo[presentID][presentZ]);
  538. // Create the label
  539. new presentStr[300];
  540. format(presentStr, sizeof(presentStr), "%s\n{FFFFFF}(( /getpresent ))", presentTypes[pickedType][1]);
  541. PresentInfo[presentID][presentLabel] = CreateDynamic3DTextLabel(presentStr, 0x00EEFFFF, PresentInfo[presentID][presentX], PresentInfo[presentID][presentY], PresentInfo[presentID][presentZ], 20.0);
  542. return presentID;
  543. }
  544. locationHasPresent(locationID) {
  545. for(new i = 0; i < MAX_PRESENTS; i++) {
  546. if(PresentInfo[i][presentUsed]) {
  547. if(
  548. PresentInfo[i][presentX] == presentLocations[locationID][0] &&
  549. PresentInfo[i][presentY] == presentLocations[locationID][1] &&
  550. PresentInfo[i][presentZ] == presentLocations[locationID][2]
  551. ) return 1;
  552. }
  553. }
  554. return 0;
  555. }