treasure.pwn 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Treasure 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. FoundTreasure(playerid)
  34. {
  35. new szMessage[128];
  36. switch(PlayerInfo[playerid][pTreasureSkill])
  37. {
  38. case 1..149:
  39. {
  40. new FoundAnything = Random(1, 100);
  41. if(FoundAnything >= 1 && FoundAnything <= 50)
  42. {
  43. new ItemFound = Random(1, 10);
  44. if(ItemFound >= 1 && ItemFound <= 2)
  45. {
  46. SetPVarInt(playerid, "junkmetal", GetPVarInt(playerid, "junkmetal")+1);
  47. SaveTreasureInventory(playerid);
  48. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds junk metal.", GetPlayerNameEx(playerid));
  49. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  50. }
  51. else if(ItemFound >= 3 && ItemFound <= 4)
  52. {
  53. SetPVarInt(playerid, "newcoin", GetPVarInt(playerid, "newcoin")+1);
  54. SaveTreasureInventory(playerid);
  55. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a new coin.", GetPlayerNameEx(playerid));
  56. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  57. }
  58. else if(ItemFound >= 5 && ItemFound <= 6)
  59. {
  60. SetPVarInt(playerid, "oldcoin", GetPVarInt(playerid, "oldcoin")+1);
  61. SaveTreasureInventory(playerid);
  62. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a old coin.", GetPlayerNameEx(playerid));
  63. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  64. }
  65. else if(ItemFound >= 7 && ItemFound <= 8)
  66. {
  67. SetPVarInt(playerid, "brokenwatch", GetPVarInt(playerid, "brokenwatch")+1);
  68. SaveTreasureInventory(playerid);
  69. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a broken watch.", GetPlayerNameEx(playerid));
  70. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  71. }
  72. else if(ItemFound >= 9 && ItemFound <= 10)
  73. {
  74. SetPVarInt(playerid, "oldkey", GetPVarInt(playerid, "oldkey")+1);
  75. SaveTreasureInventory(playerid);
  76. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a old key.", GetPlayerNameEx(playerid));
  77. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  78. }
  79. }
  80. else
  81. {
  82. SendClientMessageEx(playerid, COLOR_WHITE, "You did not discover anything.");
  83. format(szMessage, 128, "%s's metal detector has seemed to malfunctioned", GetPlayerNameEx(playerid));
  84. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  85. }
  86. }
  87. case 150..299:
  88. {
  89. new FoundAnything = Random(1, 100);
  90. if(FoundAnything >= 1 && FoundAnything <= 75)
  91. {
  92. new ItemFound = Random(1, 10);
  93. if(ItemFound >= 1 && ItemFound <= 2)
  94. {
  95. SetPVarInt(playerid, "junkmetal", GetPVarInt(playerid, "junkmetal")+1);
  96. SaveTreasureInventory(playerid);
  97. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds junk metal.", GetPlayerNameEx(playerid));
  98. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  99. }
  100. else if(ItemFound == 3 && ItemFound <= 4)
  101. {
  102. SetPVarInt(playerid, "newcoin", GetPVarInt(playerid, "newcoin")+1);
  103. SaveTreasureInventory(playerid);
  104. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a new coin.", GetPlayerNameEx(playerid));
  105. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  106. }
  107. else if(ItemFound == 5 && ItemFound <= 6)
  108. {
  109. SetPVarInt(playerid, "oldcoin", GetPVarInt(playerid, "oldcoin")+1);
  110. SaveTreasureInventory(playerid);
  111. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a old coin.", GetPlayerNameEx(playerid));
  112. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  113. }
  114. else if(ItemFound == 7)
  115. {
  116. SetPVarInt(playerid, "brokenwatch", GetPVarInt(playerid, "brokenwatch")+1);
  117. SaveTreasureInventory(playerid);
  118. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a broken watch.", GetPlayerNameEx(playerid));
  119. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  120. }
  121. else if(ItemFound == 8 || ItemFound == 9)
  122. {
  123. SetPVarInt(playerid, "oldkey", GetPVarInt(playerid, "oldkey")+1);
  124. SaveTreasureInventory(playerid);
  125. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a old key.", GetPlayerNameEx(playerid));
  126. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  127. }
  128. else if(ItemFound == 10)
  129. {
  130. new VeryRare = Random(1, 90);
  131. if(VeryRare >= 1 && VeryRare <= 30)
  132. {
  133. SetPVarInt(playerid, "goldwatch", GetPVarInt(playerid, "goldwatch")+1);
  134. SaveTreasureInventory(playerid);
  135. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a gold watch!", GetPlayerNameEx(playerid));
  136. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  137. }
  138. else if(VeryRare >= 31 && VeryRare <= 60)
  139. {
  140. SetPVarInt(playerid, "silvernugget", GetPVarInt(playerid, "silvernugget")+1);
  141. SaveTreasureInventory(playerid);
  142. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a silver nugget!", GetPlayerNameEx(playerid));
  143. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  144. }
  145. else if(VeryRare >= 61 && VeryRare <= 90)
  146. {
  147. SetPVarInt(playerid, "goldnugget", GetPVarInt(playerid, "goldnugget")+1);
  148. SaveTreasureInventory(playerid);
  149. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a gold nugget!", GetPlayerNameEx(playerid));
  150. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  151. }
  152. }
  153. }
  154. else
  155. {
  156. SendClientMessageEx(playerid, COLOR_WHITE, "You did not discover anything.");
  157. format(szMessage, 128, "%s's metal detector has seemed to malfunctioned", GetPlayerNameEx(playerid));
  158. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  159. }
  160. }
  161. case 300..499:
  162. {
  163. new FoundAnything = Random(1, 125);
  164. if(FoundAnything >= 1 && FoundAnything <= 75)
  165. {
  166. new ItemFound = Random(1, 10);
  167. if(ItemFound >= 1 && ItemFound <= 2)
  168. {
  169. SetPVarInt(playerid, "junkmetal", GetPVarInt(playerid, "junkmetal")+1);
  170. SaveTreasureInventory(playerid);
  171. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds junk metal.", GetPlayerNameEx(playerid));
  172. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  173. }
  174. else if(ItemFound == 3 && ItemFound <= 4)
  175. {
  176. SetPVarInt(playerid, "newcoin", GetPVarInt(playerid, "newcoin")+1);
  177. SaveTreasureInventory(playerid);
  178. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a new coin.", GetPlayerNameEx(playerid));
  179. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  180. }
  181. else if(ItemFound == 5 && ItemFound <= 6)
  182. {
  183. SetPVarInt(playerid, "oldcoin", GetPVarInt(playerid, "oldcoin")+1);
  184. SaveTreasureInventory(playerid);
  185. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a old coin.", GetPlayerNameEx(playerid));
  186. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  187. }
  188. else if(ItemFound == 7)
  189. {
  190. SetPVarInt(playerid, "brokenwatch", GetPVarInt(playerid, "brokenwatch")+1);
  191. SaveTreasureInventory(playerid);
  192. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a broken watch.", GetPlayerNameEx(playerid));
  193. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  194. }
  195. else if(ItemFound == 8 || ItemFound == 9)
  196. {
  197. SetPVarInt(playerid, "oldkey", GetPVarInt(playerid, "oldkey")+1);
  198. SaveTreasureInventory(playerid);
  199. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a old key.", GetPlayerNameEx(playerid));
  200. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  201. }
  202. else if(ItemFound == 10)
  203. {
  204. new VeryRare = Random(1, 90);
  205. if(VeryRare >= 1 && VeryRare <= 30)
  206. {
  207. SetPVarInt(playerid, "goldwatch", GetPVarInt(playerid, "goldwatch")+1);
  208. SaveTreasureInventory(playerid);
  209. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a gold watch!", GetPlayerNameEx(playerid));
  210. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  211. }
  212. else if(VeryRare >= 31 && VeryRare <= 60)
  213. {
  214. SetPVarInt(playerid, "silvernugget", GetPVarInt(playerid, "silvernugget")+1);
  215. SaveTreasureInventory(playerid);
  216. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a silver nugget!", GetPlayerNameEx(playerid));
  217. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  218. }
  219. else if(VeryRare >= 61 && VeryRare <= 90)
  220. {
  221. SetPVarInt(playerid, "goldnugget", GetPVarInt(playerid, "goldnugget")+1);
  222. SaveTreasureInventory(playerid);
  223. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a gold nugget!", GetPlayerNameEx(playerid));
  224. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  225. }
  226. }
  227. }
  228. else
  229. {
  230. SendClientMessageEx(playerid, COLOR_WHITE, "You did not discover anything.");
  231. format(szMessage, 128, "%s's metal detector has seemed to malfunctioned", GetPlayerNameEx(playerid));
  232. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  233. }
  234. }
  235. case 500..9999:
  236. {
  237. new FoundAnything = Random(1, 125);
  238. if(FoundAnything >= 1 && FoundAnything <= 75)
  239. {
  240. new ItemFound = Random(1, 10);
  241. if(ItemFound >= 1 && ItemFound <= 2)
  242. {
  243. SetPVarInt(playerid, "junkmetal", GetPVarInt(playerid, "junkmetal")+1);
  244. SaveTreasureInventory(playerid);
  245. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds junk metal.", GetPlayerNameEx(playerid));
  246. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  247. }
  248. else if(ItemFound == 3 && ItemFound <= 4)
  249. {
  250. SetPVarInt(playerid, "newcoin", GetPVarInt(playerid, "newcoin")+1);
  251. SaveTreasureInventory(playerid);
  252. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a new coin.", GetPlayerNameEx(playerid));
  253. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  254. }
  255. else if(ItemFound == 5 && ItemFound <= 6)
  256. {
  257. SetPVarInt(playerid, "oldcoin", GetPVarInt(playerid, "oldcoin")+1);
  258. SaveTreasureInventory(playerid);
  259. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a old coin.", GetPlayerNameEx(playerid));
  260. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  261. }
  262. else if(ItemFound == 7)
  263. {
  264. SetPVarInt(playerid, "brokenwatch", GetPVarInt(playerid, "brokenwatch")+1);
  265. SaveTreasureInventory(playerid);
  266. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a broken watch.", GetPlayerNameEx(playerid));
  267. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  268. }
  269. else if(ItemFound == 8)
  270. {
  271. SetPVarInt(playerid, "oldkey", GetPVarInt(playerid, "oldkey")+1);
  272. SaveTreasureInventory(playerid);
  273. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a old key.", GetPlayerNameEx(playerid));
  274. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  275. }
  276. else if(ItemFound == 9 || ItemFound == 10)
  277. {
  278. new VeryRare = Random(1, 100);
  279. if(VeryRare >= 1 && VeryRare <= 35)
  280. {
  281. SetPVarInt(playerid, "goldwatch", GetPVarInt(playerid, "goldwatch")+1);
  282. SaveTreasureInventory(playerid);
  283. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a gold watch!", GetPlayerNameEx(playerid));
  284. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  285. }
  286. else if(VeryRare >= 36 && VeryRare <= 65)
  287. {
  288. SetPVarInt(playerid, "silvernugget", GetPVarInt(playerid, "silvernugget")+1);
  289. SaveTreasureInventory(playerid);
  290. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a silver nugget!", GetPlayerNameEx(playerid));
  291. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  292. }
  293. else if(VeryRare >= 66 && VeryRare <= 99)
  294. {
  295. SetPVarInt(playerid, "goldnugget", GetPVarInt(playerid, "goldnugget")+1);
  296. SaveTreasureInventory(playerid);
  297. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a gold nugget!", GetPlayerNameEx(playerid));
  298. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  299. }
  300. else if(VeryRare == 100)
  301. {
  302. SetPVarInt(playerid, "treasure", GetPVarInt(playerid, "treasure")+1);
  303. SaveTreasureInventory(playerid);
  304. format(szMessage, 128, "%s's sweeps the ground with a metal detector and finds a hidden treasure!", GetPlayerNameEx(playerid));
  305. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  306. format(szMessage, 128, "{AA3333}AdmWarning{FFFF00}: %s has just found hidden treasure ($1,000,000)", GetPlayerNameEx(playerid));
  307. ABroadCast(COLOR_YELLOW, szMessage, 2);
  308. }
  309. }
  310. }
  311. else
  312. {
  313. SendClientMessageEx(playerid, COLOR_WHITE, "You did not discover anything.");
  314. format(szMessage, 128, "%s's metal detector has seemed to malfunctioned", GetPlayerNameEx(playerid));
  315. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  316. }
  317. }
  318. }
  319. return 1;
  320. }
  321. CMD:search(playerid, params[])
  322. {
  323. if(PlayerInfo[playerid][pJob] != 22 && PlayerInfo[playerid][pJob2] != 22 && PlayerInfo[playerid][pJob3] != 22) {
  324. return SendClientMessageEx(playerid, COLOR_GREY, "You are not a treasure hunter.");
  325. }
  326. else if(PlayerInfo[playerid][pMetalDetector] == 0) {
  327. return SendClientMessageEx(playerid, COLOR_GREY, "You don't have a metal detector. You can recieve one from a craftsman.");
  328. }
  329. else if(IsPlayerInAnyVehicle(playerid)) {
  330. return SendClientMessageEx(playerid, COLOR_GREY, "You are not allowed to metal detect while in a vehicle. " );
  331. }
  332. else if(gettime()-GetPVarInt(playerid, "LastScan") < GetPVarInt(playerid, "ScanReload")) {
  333. return SendClientMessageEx(playerid, COLOR_GRAD2, "Your metal detector is still charging.");
  334. }
  335. else if(!GetPVarType(playerid, "HiddenTreasure")) { // New Treasure
  336. SetPVarInt(playerid, "HiddenTreasure", random(sizeof(HiddenTreasure)));
  337. }
  338. new
  339. szMessage[128],
  340. Float:distance = GetPlayerDistanceFromPoint(playerid, HiddenTreasure[GetPVarInt(playerid, "HiddenTreasure")][0], HiddenTreasure[GetPVarInt(playerid, "HiddenTreasure")][1], HiddenTreasure[GetPVarInt(playerid, "HiddenTreasure")][2]);
  341. if(IsPlayerInArea(playerid, 402.2964, 737.5547, -1923.9410, -1752.8732) && distance > 3)
  342. {
  343. PlayerInfo[playerid][pMetalDetector]--;
  344. if(PlayerInfo[playerid][pMetalDetector] == 1) {
  345. SendClientMessageEx(playerid, COLOR_WHITE, "INFO: You only have 1 metal detector charge left.");
  346. }
  347. SetPlayerCheckpoint(playerid,HiddenTreasure[GetPVarInt(playerid, "HiddenTreasure")][0], HiddenTreasure[GetPVarInt(playerid, "HiddenTreasure")][1], HiddenTreasure[GetPVarInt(playerid, "HiddenTreasure")][2], 3);
  348. SetTimerEx("DisableCheckPoint", 2000, 0, "i", playerid);
  349. format(szMessage, 128, "You are %f meters away from the treasure. ", distance);
  350. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  351. format(szMessage, 128, "%s sweeps the ground with a metal detector.", GetPlayerNameEx(playerid));
  352. ProxDetector(30.0, playerid, szMessage, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  353. if(PlayerInfo[playerid][pTreasureSkill] >=0 && PlayerInfo[playerid][pTreasureSkill] <= 24) SetPVarInt(playerid, "ScanReload", 20);
  354. else if(PlayerInfo[playerid][pTreasureSkill] >=25 && PlayerInfo[playerid][pTreasureSkill] <= 299) SetPVarInt(playerid, "ScanReload", 15);
  355. else if(PlayerInfo[playerid][pTreasureSkill] >=300 && PlayerInfo[playerid][pTreasureSkill] <= 599) SetPVarInt(playerid, "ScanReload", 10);
  356. else if(PlayerInfo[playerid][pTreasureSkill] >=600) SetPVarInt(playerid, "ScanReload", 5);
  357. SetPVarInt(playerid, "LastScan", gettime());
  358. }
  359. else if(distance <= 3) // Finds Treasure
  360. {
  361. FoundTreasure(playerid);
  362. PlayerInfo[playerid][pMetalDetector]--;
  363. /*if(PlayerInfo[playerid][pDoubleEXP] > 0)
  364. {
  365. format(szMessage, 128, "You have gained 2 treasure hunting skill points instead of 1. You have %d hours left on the Double EXP token.", PlayerInfo[playerid][pDoubleEXP]);
  366. SendClientMessageEx(playerid, COLOR_YELLOW, szMessage);
  367. PlayerInfo[playerid][pTreasureSkill] += 2;
  368. }
  369. else ++PlayerInfo[playerid][pTreasureSkill];*/
  370. ++PlayerInfo[playerid][pTreasureSkill];
  371. DeletePVar(playerid, "HiddenTreasure");
  372. if(PlayerInfo[playerid][pMetalDetector] == 1) {
  373. SendClientMessageEx(playerid, COLOR_WHITE, "INFO: You only have 1 metal detector charge left.");
  374. }
  375. if(PlayerInfo[playerid][pTreasureSkill] == 25) {
  376. SendClientMessageEx(playerid, COLOR_WHITE, "* Your Treasure Hunting Skill is now Level 2, the time it takes for your metal detector to charge is now 15 seconds!");
  377. }
  378. if(PlayerInfo[playerid][pTreasureSkill] == 150) {
  379. SendClientMessageEx(playerid, COLOR_WHITE, "* Your Treasure Hunting Skill is now Level 3, your chance to find a rare is now 10%!");
  380. }
  381. if(PlayerInfo[playerid][pTreasureSkill] == 300) {
  382. SendClientMessageEx(playerid, COLOR_WHITE, "* Your Treasure Hunting Skill is now Level 4, the time it takes for your metal detector to charge is now 10 seconds!");
  383. }
  384. if(PlayerInfo[playerid][pTreasureSkill] == 600) {
  385. SendClientMessageEx(playerid, COLOR_WHITE, "* Your Treasure Hunting Skill is now Level 5, your chance to find a rare is now 20%!");
  386. }
  387. }
  388. else {
  389. SendClientMessageEx(playerid, COLOR_GREY, "You are not at a beach.");
  390. }
  391. return 1;
  392. }
  393. CMD:selltreasure(playerid, params[])
  394. {
  395. new choice[32], amount;
  396. if(sscanf(params, "s[32]d", choice, amount))
  397. {
  398. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /selltreasure [name] [amount]");
  399. SendClientMessageEx(playerid, COLOR_GREY, "Available names: junkmetal ($150), newcoin ($50), oldcoin ($100), brokenwatch ($5), oldkey ($20), goldwatch ($50000)");
  400. SendClientMessageEx(playerid, COLOR_GREY, "Available names: goldnugget ($100000), silvernugget ($25000), treasurechest ($1000000)");
  401. return 1;
  402. }
  403. else if(!IsPlayerInRangeOfPoint(playerid, 3 , 164.9517, -1779.5931, 4.3000)) {
  404. return SendClientMessageEx(playerid, COLOR_GREY, "You are not at a treasure sell point.");
  405. }
  406. else if(amount < 0) {
  407. return SendClientMessageEx(playerid, COLOR_GREY, "You can't sell negative of an item.");
  408. }
  409. new szMessage[128];
  410. if(strcmp(choice, "junkmetal", true) == 0) {
  411. if(amount <= GetPVarInt(playerid, "junkmetal") && amount > 0) {
  412. format(szMessage, 128, "You have sold %d junk metals for $%d.", amount, amount*150);
  413. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  414. GivePlayerCash(playerid, amount*150);
  415. SetPVarInt(playerid, "junkmetal", GetPVarInt(playerid, "junkmetal")-amount);
  416. SaveTreasureInventory(playerid);
  417. }
  418. else {
  419. SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough of that item to sell.");
  420. }
  421. }
  422. else if(strcmp(choice, "newcoin", true) == 0) {
  423. if(amount <= GetPVarInt(playerid, "newcoin") && amount > 0) {
  424. format(szMessage, 128, "You have sold %d new coins for $%d.", amount, amount*50);
  425. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  426. GivePlayerCash(playerid, amount*50);
  427. SetPVarInt(playerid, "newcoin", GetPVarInt(playerid, "newcoin")-amount);
  428. SaveTreasureInventory(playerid);
  429. }
  430. else {
  431. SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough of that item to sell.");
  432. }
  433. }
  434. else if(strcmp(choice, "oldcoin", true) == 0) {
  435. if(amount <= GetPVarInt(playerid, "oldcoin") && amount > 0) {
  436. format(szMessage, 128, "You have sold %d old coins for $%d.", amount, amount*100);
  437. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  438. GivePlayerCash(playerid, amount*100);
  439. SetPVarInt(playerid, "oldcoin", GetPVarInt(playerid, "oldcoin")-amount);
  440. SaveTreasureInventory(playerid);
  441. }
  442. else {
  443. SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough of that item to sell.");
  444. }
  445. }
  446. else if(strcmp(choice, "brokenwatch", true) == 0) {
  447. if(amount <= GetPVarInt(playerid, "brokenwatch") && amount > 0) {
  448. format(szMessage, 128, "You have sold %d broken watchs for $%d.", amount, amount*5);
  449. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  450. GivePlayerCash(playerid, amount*5);
  451. SetPVarInt(playerid, "brokenwatch", GetPVarInt(playerid, "brokenwatch")-amount);
  452. SaveTreasureInventory(playerid);
  453. }
  454. else {
  455. SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough of that item to sell.");
  456. }
  457. }
  458. else if(strcmp(choice, "oldkey", true) == 0) {
  459. if(amount <= GetPVarInt(playerid, "oldkey") && amount > 0) {
  460. format(szMessage, 128, "You have sold %d old keys for $%d.", amount, amount*20);
  461. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  462. GivePlayerCash(playerid, amount*20);
  463. SetPVarInt(playerid, "oldkey", GetPVarInt(playerid, "oldkey")-amount);
  464. SaveTreasureInventory(playerid);
  465. }
  466. else {
  467. SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough of that item to sell.");
  468. }
  469. }
  470. else if(strcmp(choice, "goldwatch", true) == 0) {
  471. if(amount <= GetPVarInt(playerid, "goldwatch") && amount > 0) {
  472. format(szMessage, 128, "You have sold %d gold watchs for $%d.", amount, amount*50000);
  473. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  474. GivePlayerCash(playerid, amount*50000);
  475. SetPVarInt(playerid, "goldwatch", GetPVarInt(playerid, "goldwatch")-amount);
  476. SaveTreasureInventory(playerid);
  477. }
  478. else {
  479. SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough of that item to sell.");
  480. }
  481. }
  482. else if(strcmp(choice, "goldnugget", true) == 0) {
  483. if(amount <= GetPVarInt(playerid, "goldnugget") && amount > 0) {
  484. format(szMessage, 128, "You have sold %d gold nuggets for $%d.", amount, amount*100000);
  485. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  486. GivePlayerCash(playerid, amount*100000);
  487. SetPVarInt(playerid, "goldnugget", GetPVarInt(playerid, "goldnugget")-amount);
  488. SaveTreasureInventory(playerid);
  489. }
  490. else {
  491. SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough of that item to sell.");
  492. }
  493. }
  494. else if(strcmp(choice, "silvernugget", true) == 0) {
  495. if(amount <= GetPVarInt(playerid, "silvernugget") && amount > 0) {
  496. format(szMessage, 128, "You have sold %d silver nuggets for $%d.", amount, amount*25000);
  497. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  498. GivePlayerCash(playerid, amount*25000);
  499. SetPVarInt(playerid, "silvernugget", GetPVarInt(playerid, "silvernugget")-amount);
  500. SaveTreasureInventory(playerid);
  501. }
  502. else {
  503. SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough of that item to sell.");
  504. }
  505. }
  506. else if(strcmp(choice, "treasurechest", true) == 0) {
  507. if(amount <= GetPVarInt(playerid, "treasurechest") && amount > 0) {
  508. format(szMessage, 128, "You have sold %d treasure chests for $%d.", amount, amount*1000000);
  509. SendClientMessageEx(playerid, COLOR_WHITE, szMessage);
  510. GivePlayerCash(playerid, amount*1000000);
  511. SetPVarInt(playerid, "treasure", GetPVarInt(playerid, "treasure")-amount);
  512. SaveTreasureInventory(playerid);
  513. }
  514. else {
  515. SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough of that item to sell.");
  516. }
  517. }
  518. return 1;
  519. }