1
0

fishing_job.inc 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991
  1. /*
  2. file: jobs/fishing_job.inc
  3. description: The fishing job for SARP.
  4. author: Unknown
  5. improved by: Jay Cortez
  6. date created: 29th March 2018
  7. */
  8. forward FishingAnimation(playerid);
  9. forward Fishing(playerid);
  10. forward Catching(playerid, weight);
  11. forward FishCost(fish);
  12. forward UpdateTextDraw(playerid);
  13. // Fish names
  14. new FishNamesNumber = 17;
  15. new FishNames[17][0] =
  16. {
  17. {"Jacket"},
  18. {"Amberjack"},
  19. {"Grouper"},
  20. {"Red Snapper"},
  21. {"Trout"},
  22. {"Blue Marlin"},
  23. {"Mackeral"},
  24. {"Sea Bass"},
  25. {"Pike"},
  26. {"Sail Fish"},
  27. {"Tuna"},
  28. {"Eel"},
  29. {"Dolphin"},
  30. {"Shark"},
  31. {"Turtle"},
  32. {"Catfish"},
  33. {"Swordfish"}
  34. };
  35. // Command to display fishing related help
  36. CMD:fishhelp(playerid, params[])
  37. {
  38. DisplayDialogForPlayer(playerid, 106);
  39. return 1;
  40. }
  41. // Command to open the fishing store dialog
  42. CMD:store(playerid, params[]) {
  43. if(!IsPlayerInRangeOfPoint(playerid, 3, 369.20, -2065.96, 979.80))
  44. return SendClientMessage(playerid, COLOR_GREY, "You are not at the fishing store counter.");
  45. DisplayDialogForPlayer(playerid, 102);
  46. return 1;
  47. }
  48. // Command to take out/put away fishing rod
  49. CMD:userod(playerid, params[]) {
  50. if(!PlayerInfo[playerid][pFishRod])
  51. return SendClientMessage(playerid, COLOR_GREY, "You do not own a fishing rod.");
  52. if(!PlayerInfo[playerid][pBait])
  53. return SendClientMessage(playerid, COLOR_GREY, "You do not have any bait on you.");
  54. if(playerHoldingTazer[playerid])
  55. return SendClientMessage(playerid, COLOR_GREY, "You must put your tazer away first.");
  56. new fishStr[128];
  57. if(!PlayerHasRod[playerid])
  58. {
  59. PlayerHasRod[playerid] = 1;
  60. SetPlayerAttachedObject(playerid, INDEX_7, 18632, 6, 0.06, 0.04, 0.0, 180.0, 0.0, 0.0);
  61. SetPlayerArmedWeapon(playerid, 0);
  62. format(fishStr, sizeof(fishStr), "* %s takes out their fishing rod.", PlayerICName(playerid));
  63. ProxDetector(30.0, playerid, fishStr, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  64. showNewbieTipMessage(playerid, 10);
  65. }
  66. else
  67. {
  68. if(IsFishing[playerid] == 1)
  69. return SendClientMessage(playerid, COLOR_GREY, "You can't put your fishing rod away while you're fishing.");
  70. PlayerHasRod[playerid] = 0;
  71. RemovePlayerAttachedObject(playerid, INDEX_7);
  72. format(fishStr, sizeof(fishStr), "* %s puts away their fishing rod.", PlayerICName(playerid));
  73. ProxDetector(30.0, playerid, fishStr, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  74. }
  75. return 1;
  76. }
  77. // Command to see a list of fish the player currently has
  78. CMD:listfish(playerid, params[]) {
  79. new fishStr[128];
  80. SendClientMessage(playerid, COLOR_WHITE, "Your current fishes:");
  81. if(Fishes[playerid][pWeight1]) {
  82. format(fishStr, sizeof(fishStr), "** (1) Fish: %s (%i LBS).", Fishes[playerid][pFish1], Fishes[playerid][pWeight1]);
  83. SendClientMessage(playerid, COLOR_GREY, fishStr);
  84. }
  85. else SendClientMessage(playerid, COLOR_GREY, "** (1) Empty.");
  86. if(Fishes[playerid][pWeight2]) {
  87. format(fishStr, sizeof(fishStr), "** (2) Fish: %s (%i LBS).", Fishes[playerid][pFish2], Fishes[playerid][pWeight2]);
  88. SendClientMessage(playerid, COLOR_GREY, fishStr);
  89. }
  90. else SendClientMessage(playerid, COLOR_GREY, "** (2) Empty.");
  91. if(Fishes[playerid][pWeight3]) {
  92. format(fishStr, sizeof(fishStr), "** (3) Fish: %s (%i LBS).", Fishes[playerid][pFish3], Fishes[playerid][pWeight3]);
  93. SendClientMessage(playerid, COLOR_GREY, fishStr);
  94. }
  95. else SendClientMessage(playerid, COLOR_GREY, "** (3) Empty.");
  96. if(Fishes[playerid][pWeight4]) {
  97. format(fishStr, sizeof(fishStr), "** (4) Fish: %s (%i LBS).", Fishes[playerid][pFish4], Fishes[playerid][pWeight4]);
  98. SendClientMessage(playerid, COLOR_GREY, fishStr);
  99. }
  100. else SendClientMessage(playerid, COLOR_GREY, "** (4) Empty.");
  101. if(Fishes[playerid][pWeight5]) {
  102. format(fishStr, sizeof(fishStr), "** (5) Fish: %s (%i LBS).", Fishes[playerid][pFish5], Fishes[playerid][pWeight5]);
  103. SendClientMessage(playerid, COLOR_GREY, fishStr);
  104. }
  105. else SendClientMessage(playerid, COLOR_GREY, "** (5) Empty.");
  106. // Action
  107. new actionStr[128];
  108. format(actionStr, sizeof(actionStr), "* %s takes a look at their fishes.", PlayerICName(playerid));
  109. SetPlayerChatBubble(playerid, actionStr, COLOR_PURPLE, 20.0, 15000);
  110. return 1;
  111. }
  112. // Command to sell fish in a 24/7
  113. CMD:sellfish(playerid, params[]) {
  114. // This should be made more dynamic
  115. if(!IsPlayerInRangeOfPoint(playerid, 100, -30.875, -88.9609, 1004.53))
  116. return SendClientMessage(playerid, COLOR_GREY, "You are not in a 24/7.");
  117. new fishid;
  118. if(sscanf(params, "i", fishid))
  119. return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /sellfish [number]");
  120. if(fishid < 1 || fishid > 5)
  121. return SendClientMessage(playerid, COLOR_GREY, "Fish can't be below 1 or above 5.");
  122. // Get the name of the fish and the weight
  123. new fishName[50], fishWeight, fishFid;
  124. switch(fishid) {
  125. case 1: {
  126. format(fishName, sizeof(fishName), "%s", Fishes[playerid][pFish1]);
  127. fishWeight = Fishes[playerid][pWeight1];
  128. fishFid = Fishes[playerid][pFid1];
  129. }
  130. case 2: {
  131. format(fishName, sizeof(fishName), "%s", Fishes[playerid][pFish2]);
  132. fishWeight = Fishes[playerid][pWeight2];
  133. fishFid = Fishes[playerid][pFid2];
  134. }
  135. case 3: {
  136. format(fishName, sizeof(fishName), "%s", Fishes[playerid][pFish3]);
  137. fishWeight = Fishes[playerid][pWeight3];
  138. fishFid = Fishes[playerid][pFid3];
  139. }
  140. case 4: {
  141. format(fishName, sizeof(fishName), "%s", Fishes[playerid][pFish4]);
  142. fishWeight = Fishes[playerid][pWeight4];
  143. fishFid = Fishes[playerid][pFid4];
  144. }
  145. case 5: {
  146. format(fishName, sizeof(fishName), "%s", Fishes[playerid][pFish5]);
  147. fishWeight = Fishes[playerid][pWeight5];
  148. fishFid = Fishes[playerid][pFid5];
  149. }
  150. }
  151. if(!fishWeight)
  152. return SendClientMessage(playerid, COLOR_GREY, "You don't have a fish in that slot.");
  153. if(fishWeight < 20)
  154. return SendClientMessage(playerid, COLOR_GREY, "We are only interested in fish weighting 20 LBS or more.");
  155. // Calculate the price
  156. new fishPrice = FishCost(fishFid) * fishWeight;
  157. // Send a message
  158. new fishStr[128];
  159. format(fishStr, sizeof(fishStr), "* You have sold your %s (%i LBS) for $%i.", fishName, fishWeight, fishPrice);
  160. SendClientMessage(playerid, COLOR_LIGHTBLUE, fishStr);
  161. // Give money and get rid of the fish
  162. GiveMoney(playerid, fishPrice);
  163. ClearFishID(playerid, fishid);
  164. Fishes[playerid][pLastFish] = 0;
  165. return 1;
  166. }
  167. // Command to throw all fishes back into the sea
  168. CMD:throwbackall(playerid, params[]) {
  169. if(
  170. !Fishes[playerid][pWeight1] &&
  171. !Fishes[playerid][pWeight2] &&
  172. !Fishes[playerid][pWeight3] &&
  173. !Fishes[playerid][pWeight4] &&
  174. !Fishes[playerid][pWeight5]
  175. ) return SendClientMessage(playerid, COLOR_GREY, "You are not carrying any fish.");
  176. ClearFishes(playerid);
  177. Fishes[playerid][pLastFish] = 0;
  178. SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You have thrown back all of your fish.");
  179. return 1;
  180. }
  181. // Command to throw last fish back into the sea
  182. CMD:throwback(playerid, params[]) {
  183. if(!Fishes[playerid][pLastFish])
  184. return SendClientMessage(playerid, COLOR_GREY, "You don't have any fish to throw back.");
  185. ClearFishID(playerid, Fishes[playerid][pLastFish]);
  186. Fishes[playerid][pLastFish] = 0;
  187. SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You have thrown back your last fish.");
  188. return 1;
  189. }
  190. // Command to release (throw away) a fish
  191. CMD:releasefish(playerid, params[]) {
  192. new fishid;
  193. if(sscanf(params, "i", fishid))
  194. return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /releasefish [number]");
  195. if(fishid < 1 || fishid > 5)
  196. return SendClientMessage(playerid, COLOR_GREY, "Fish can't be below 1 or above 5.");
  197. // Get the name of the fish and the weight
  198. new fishName[50], fishWeight;
  199. switch(fishid) {
  200. case 1: {
  201. format(fishName, sizeof(fishName), "%s", Fishes[playerid][pFish1]);
  202. fishWeight = Fishes[playerid][pWeight1];
  203. }
  204. case 2: {
  205. format(fishName, sizeof(fishName), "%s", Fishes[playerid][pFish2]);
  206. fishWeight = Fishes[playerid][pWeight2];
  207. }
  208. case 3: {
  209. format(fishName, sizeof(fishName), "%s", Fishes[playerid][pFish3]);
  210. fishWeight = Fishes[playerid][pWeight3];
  211. }
  212. case 4: {
  213. format(fishName, sizeof(fishName), "%s", Fishes[playerid][pFish4]);
  214. fishWeight = Fishes[playerid][pWeight4];
  215. }
  216. case 5: {
  217. format(fishName, sizeof(fishName), "%s", Fishes[playerid][pFish5]);
  218. fishWeight = Fishes[playerid][pWeight5];
  219. }
  220. }
  221. if(!fishWeight)
  222. return SendClientMessage(playerid, COLOR_GREY, "You don't have a fish in that slot.");
  223. // Send a message
  224. new fishStr[128];
  225. format(fishStr, sizeof(fishStr), "* You have released the %s (%i LBS).", fishName, fishWeight);
  226. SendClientMessage(playerid, COLOR_LIGHTBLUE, fishStr);
  227. // Get rid of the fish
  228. ClearFishID(playerid, fishid);
  229. Fishes[playerid][pLastFish] = 0;
  230. return 1;
  231. }
  232. // OnPlayerKeyStateChange hook for fishing related code
  233. Hook:fish_OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
  234. if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
  235. {
  236. if(PRESSED(KEY_FIRE))
  237. {
  238. // Player is fishing
  239. if(TextDrawTimer[playerid])
  240. {
  241. LineTension[playerid] += 5;
  242. FishDist[playerid] -= 1;
  243. }
  244. }
  245. else if(PRESSED(KEY_AIM))
  246. {
  247. if(PlayerHasRod[playerid])
  248. {
  249. if(CatchingTimer[playerid]) return 1;
  250. new fishStr[128];
  251. if(!IsFishing[playerid])
  252. {
  253. if(IsNotAtFishPlace(playerid)) return SendClientMessage(playerid, COLOR_GRAD1, "You are not at the fishing pier or at the wharf in blueberry.");
  254. if(PlayerInfo[playerid][pLine] == 0) return SendClientMessage(playerid, COLOR_GREY, "You don't own a fishing line.");
  255. format(fishStr, sizeof(fishStr), "* %s throws their fishing line out to sea.", PlayerICName(playerid));
  256. ProxDetector(30.0, playerid, fishStr, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  257. //TogglePlayerControllable(playerid, false);
  258. //SetPlayerFacingAngle(playerid, 180.0);
  259. OnePlayAnim(playerid, "CAMERA", "piccrch_in", 4.0, 0, 0, 0, 0, 0);
  260. IsFishing[playerid] = 1;
  261. FishingTimer[playerid] = SetTimerEx("Fishing", 7 *1000, 1, "i", playerid);
  262. SetTimerEx("FishingAnimation", 1000, 0, "i", playerid);
  263. }
  264. else
  265. {
  266. format(fishStr, sizeof(fishStr), "* %s reels in their fishing line.", PlayerICName(playerid));
  267. ProxDetector(30.0, playerid, fishStr, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  268. //TogglePlayerControllable(playerid, true);
  269. IsFishing[playerid] = 0;
  270. OnePlayAnim(playerid, "BD_FIRE", "wash_up", 4.0, 0, 0, 0, 0, 0);
  271. if(CatchingTimer[playerid])
  272. {
  273. KillTimer(CatchingTimer[playerid]);
  274. CatchingTimer[playerid] = 0;
  275. }
  276. if(FishingTimer[playerid])
  277. {
  278. KillTimer(FishingTimer[playerid]);
  279. FishingTimer[playerid] = 0;
  280. }
  281. }
  282. return 1;
  283. }
  284. }
  285. }
  286. return 1;
  287. }
  288. // This function calculates fish price based on the type of fish
  289. stock FishCost(fish)
  290. {
  291. switch(fish)
  292. {
  293. case 0: return 10;
  294. case 1: return 10;
  295. case 2: return 30;
  296. case 3: return 30;
  297. case 4: return 25;
  298. case 5: return 50;
  299. case 6: return 20;
  300. case 7: return 65;
  301. case 8: return 80;
  302. case 9: return 120;
  303. case 10: return 60;
  304. case 11: return 90;
  305. case 12: return 70;
  306. case 13: return 150;
  307. case 14: return 12;
  308. case 15: return 90;
  309. case 16: return 70;
  310. case 17: return 70;
  311. default: return 10;
  312. }
  313. return 0;
  314. }
  315. // This function clears all the player's fishes
  316. stock ClearFishes(playerid)
  317. {
  318. if(!IsPlayerConnected(playerid))
  319. return false;
  320. Fishes[playerid][pFid1] = 0;
  321. Fishes[playerid][pFid2] = 0;
  322. Fishes[playerid][pFid3] = 0;
  323. Fishes[playerid][pFid4] = 0;
  324. Fishes[playerid][pFid5] = 0;
  325. Fishes[playerid][pWeight1] = 0;
  326. Fishes[playerid][pWeight2] = 0;
  327. Fishes[playerid][pWeight3] = 0;
  328. Fishes[playerid][pWeight4] = 0;
  329. Fishes[playerid][pWeight5] = 0;
  330. return true;
  331. }
  332. // This functions clears a fish slot of the player
  333. stock ClearFishID(playerid, fishSlot)
  334. {
  335. if(!IsPlayerConnected(playerid))
  336. return false;
  337. switch(fishSlot)
  338. {
  339. case 1:
  340. {
  341. Fishes[playerid][pWeight1] = 0;
  342. Fishes[playerid][pFid1] = 0;
  343. }
  344. case 2:
  345. {
  346. Fishes[playerid][pWeight2] = 0;
  347. Fishes[playerid][pFid2] = 0;
  348. }
  349. case 3:
  350. {
  351. Fishes[playerid][pWeight3] = 0;
  352. Fishes[playerid][pFid3] = 0;
  353. }
  354. case 4:
  355. {
  356. Fishes[playerid][pWeight4] = 0;
  357. Fishes[playerid][pFid4] = 0;
  358. }
  359. case 5:
  360. {
  361. Fishes[playerid][pWeight5] = 0;
  362. Fishes[playerid][pFid5] = 0;
  363. }
  364. }
  365. return true;
  366. }
  367. // OnPlayerDisconnect hook for fishing related code
  368. Hook:fish_OnPlayerDisconnect(playerid, reason) {
  369. if(FishingTimer[playerid])
  370. KillTimer(FishingTimer[playerid]);
  371. if(PlayerHasRod[playerid])
  372. RemovePlayerAttachedObject(playerid, INDEX_3);
  373. if(CatchingTimer[playerid])
  374. KillTimer(CatchingTimer[playerid]);
  375. }
  376. // Called every 5 minutes
  377. fish_OnFiveMinuteSync(playerid) {
  378. if(PlayerInfo[playerid][pFishes] > 4) //reset fishing timer
  379. {
  380. if(FishCount[playerid] > 2)
  381. {
  382. PlayerInfo[playerid][pFishes] = 0;
  383. }
  384. else
  385. {
  386. FishCount[playerid] += 1;
  387. }
  388. }
  389. }
  390. // Gets the rod name from an integer
  391. GetFishingRodName(rodID) {
  392. new rod[20];
  393. switch(rodID)
  394. {
  395. case 0: rod = "None";
  396. case 1: rod = "Old Rod";
  397. case 2: rod = "Beginners Rod";
  398. case 3: rod = "Fishermans Rod";
  399. case 4: rod = "Elite Rod";
  400. }
  401. return rod;
  402. }
  403. // Gets the bait name from an integer
  404. GetFishingBaitName(baitID) {
  405. new bait[20];
  406. switch(baitID)
  407. {
  408. case 0: bait = "None";
  409. case 1: bait = "Weak Bait";
  410. case 2: bait = "Regular Bait";
  411. case 3: bait = "Strong Bait";
  412. case 4: bait = "Elite Bait";
  413. }
  414. return bait;
  415. }
  416. // Gets the fishing line name from an integer
  417. GetFishingLineName(lineID) {
  418. new line[20];
  419. switch(lineID)
  420. {
  421. case 0: line = "None";
  422. case 1: line = "Regular Line";
  423. }
  424. return line;
  425. }
  426. // Performs the fishing animation
  427. public FishingAnimation(playerid)
  428. {
  429. if(IsPlayerConnected(playerid))
  430. {
  431. if(IsFishing[playerid])
  432. ApplyAnimationEx(playerid, "CAMERA", "camstnd_idleloop", 4.1, 1, 0, 0, 0, 0);
  433. }
  434. return 1;
  435. }
  436. // Fishing timer
  437. public Fishing(playerid)
  438. {
  439. new fishStr[128];
  440. if(IsPlayerConnected(playerid))
  441. {
  442. if(IsFishing[playerid] == 1)
  443. {
  444. if(IsNotAtFishPlace(playerid))
  445. {
  446. ClearAnimations(playerid);
  447. KillTimer(FishingTimer[playerid]);
  448. TogglePlayerControllable(playerid, true);
  449. return SendClientMessage(playerid, COLOR_GRAD1, "You are no longer fishing.");
  450. }
  451. if(PlayerInfo[playerid][pFishes] > 5)
  452. {
  453. return SendClientMessage(playerid, COLOR_GREY, "You caught too many fish recently, please wait.");
  454. }
  455. if(Fishes[playerid][pWeight1] > 0 && Fishes[playerid][pWeight2] > 0 && Fishes[playerid][pWeight3] > 0 && Fishes[playerid][pWeight4] > 0 && Fishes[playerid][pWeight5] > 0)
  456. {
  457. return SendClientMessage(playerid, COLOR_GREY, "You can't carry more than 5 fish, sell or release them first.");
  458. }
  459. if(!IsNotAtFishPlace(playerid))
  460. {
  461. new Rod, Bait, Level;
  462. ApplyAnimationEx(playerid, "CAMERA", "camstnd_idleloop", 4.1, 1, 0, 0, 0, 0);
  463. Level = PlayerInfo[playerid][pFishSkill];
  464. if(Level >= 0 && Level <= 50)
  465. {
  466. Caught[playerid] = random(35) -7;
  467. }
  468. else if(Level >= 51 && Level <= 100)
  469. {
  470. Caught[playerid] = random(55) -20;
  471. }
  472. else if(Level >= 101 && Level <= 200)
  473. {
  474. Caught[playerid] = random(105) -50;
  475. }
  476. else if(Level >= 201 && Level <= 400)
  477. {
  478. Caught[playerid] = random(165) -60;
  479. }
  480. else if(Level >= 401)
  481. {
  482. Caught[playerid] = random(185) -70;
  483. }
  484. //
  485. Rod = PlayerInfo[playerid][pFishRod];
  486. switch(Rod)
  487. {
  488. case 1:
  489. {
  490. Caught[playerid] += random(5) -5;
  491. }
  492. case 2:
  493. {
  494. Caught[playerid] += random(10) -5;
  495. }
  496. case 3:
  497. {
  498. Caught[playerid] += random(15) -5;
  499. }
  500. case 4:
  501. {
  502. Caught[playerid] += random(20) -5;
  503. }
  504. }
  505. //
  506. Bait = PlayerInfo[playerid][pBait];
  507. if(Bait > 0)
  508. {
  509. switch(Bait)
  510. {
  511. case 1:
  512. {
  513. Caught[playerid] += random(2);
  514. }
  515. case 2:
  516. {
  517. Caught[playerid] += random(4);
  518. }
  519. case 3:
  520. {
  521. Caught[playerid] += random(10);
  522. }
  523. case 4:
  524. {
  525. Caught[playerid] += random(20);
  526. }
  527. }
  528. }
  529. //
  530. switch(Caught[playerid])
  531. {
  532. case -200..0:
  533. return SendClientMessage(playerid, COLOR_GREY, "Nothing..");
  534. case 1:
  535. return SendClientMessage(playerid, COLOR_GREY, "You reeled in a jacket and threw it away.");
  536. case 2:
  537. return SendClientMessage(playerid, COLOR_GREY, "You reeled in some pants and threw them away.");
  538. case 3:
  539. {
  540. Condom[playerid] ++;
  541. return SendClientMessage(playerid, COLOR_LIGHTBLUE, "You reeled in a used condom and decided to keep it.");
  542. }
  543. case 4:
  544. {
  545. PlayerInfo[playerid][pScrew] ++;
  546. return SendClientMessage(playerid, COLOR_LIGHTBLUE, "You reeled in a rusty screwdriver and decided to keep it.");
  547. }
  548. case 5:
  549. return SendClientMessage(playerid, COLOR_GREY, "You reeled in a pair of old trousers and threw them away.");
  550. case 6:
  551. {
  552. new mrand = random(2000);
  553. format(fishStr, sizeof(fishStr), "You reeled in a bag of money containing $%d, looked around and decided to keep it.", mrand);
  554. SendClientMessage(playerid, COLOR_LIGHTBLUE, fishStr);
  555. GiveMoney(playerid, mrand);
  556. return 1;
  557. }
  558. }
  559. CatchingTimer[playerid] = SetTimerEx("Catching", 600, 1, "ii", playerid, Caught[playerid]);
  560. TextDrawTimer[playerid] = SetTimerEx("UpdateTextDraw", 100, 1, "i", playerid);
  561. TextDrawShowForPlayer(playerid, Text:FishingOutline);
  562. TextDrawShowForPlayer(playerid, Text:FishingBackground);
  563. TextDrawTextSize(FishingBar, 549.000000, 0.000000);
  564. TextDrawShowForPlayer(playerid, Text:FishingBar);
  565. FishDist[playerid] = 30 +random(30);
  566. LineTension[playerid] = 60;
  567. SendClientMessage(playerid, COLOR_GREY, "Line tugs, reel it in quickly! (Left mouse button)");
  568. showNewbieTipMessage(playerid, 11); //fishing bar
  569. if(PlayerInfo[playerid][pBaitAmount] == 1)
  570. {
  571. SendClientMessage(playerid, COLOR_GREY, "You have used up all your bait.");
  572. }
  573. PlayerInfo[playerid][pBaitAmount]--;
  574. if(PlayerInfo[playerid][pBaitAmount] <= 0)
  575. {
  576. PlayerInfo[playerid][pBaitAmount] = 0;
  577. }
  578. if(FishingTimer[playerid])
  579. {
  580. KillTimer(FishingTimer[playerid]);
  581. FishingTimer[playerid] = 0;
  582. }
  583. }
  584. else
  585. {
  586. ClearAnimations(playerid);
  587. if(FishingTimer[playerid])
  588. {
  589. KillTimer(FishingTimer[playerid]);
  590. FishingTimer[playerid] = 0;
  591. }
  592. TogglePlayerControllable(playerid, true);
  593. return SendClientMessage(playerid, COLOR_GRAD1, "* You are no longer fishing.");
  594. }
  595. }
  596. }
  597. return 1;
  598. }
  599. // Catching fish timer
  600. public Catching(playerid, weight)
  601. {
  602. new fishStr[128];
  603. if(IsPlayerConnected(playerid))
  604. {
  605. if(!IsNotAtFishPlace(playerid))
  606. {
  607. LineTension[playerid] = LineTension[playerid] -5;
  608. if(LineTension[playerid] <= 0)
  609. {
  610. if(TextDrawTimer[playerid])
  611. {
  612. KillTimer(TextDrawTimer[playerid]);
  613. TextDrawTimer[playerid] = 0;
  614. }
  615. if(CatchingTimer[playerid])
  616. {
  617. KillTimer(CatchingTimer[playerid]);
  618. CatchingTimer[playerid] = 0;
  619. }
  620. if(FishingTimer[playerid])
  621. {
  622. KillTimer(FishingTimer[playerid]);
  623. FishingTimer[playerid] = 0;
  624. }
  625. KillTimer(FishingTimer[playerid]);
  626. TogglePlayerControllable(playerid, true);
  627. LineTension[playerid] = 0;
  628. IsFishing[playerid] = 0;
  629. TextDrawHideForPlayer(playerid, Text:FishingBar);
  630. TextDrawHideForPlayer(playerid, Text:FishingBackground);
  631. TextDrawHideForPlayer(playerid, Text:FishingOutline);
  632. ClearAnimations(playerid);
  633. return SendClientMessage(playerid, COLOR_GREY, "The fish got away..");
  634. }
  635. if(LineTension[playerid] >= 98)
  636. {
  637. if(TextDrawTimer[playerid])
  638. {
  639. KillTimer(TextDrawTimer[playerid]);
  640. TextDrawTimer[playerid] = 0;
  641. }
  642. if(CatchingTimer[playerid])
  643. {
  644. KillTimer(CatchingTimer[playerid]);
  645. CatchingTimer[playerid] = 0;
  646. }
  647. if(FishingTimer[playerid])
  648. {
  649. KillTimer(FishingTimer[playerid]);
  650. FishingTimer[playerid] = 0;
  651. }
  652. ClearAnimations(playerid);
  653. IsFishing[playerid] = 0;
  654. TogglePlayerControllable(playerid, true);
  655. LineTension[playerid] = 0;
  656. TextDrawHideForPlayer(playerid, Text:FishingBar);
  657. TextDrawHideForPlayer(playerid, Text:FishingBackground);
  658. TextDrawHideForPlayer(playerid, Text:FishingOutline);
  659. PlayerInfo[playerid][pLine] = 0;
  660. return SendClientMessage(playerid, COLOR_GREY, "Line snapped.");
  661. }
  662. if(FishDist[playerid] <= 0)
  663. {
  664. if(TextDrawTimer[playerid])
  665. {
  666. KillTimer(TextDrawTimer[playerid]);
  667. TextDrawTimer[playerid] = 0;
  668. }
  669. if(CatchingTimer[playerid])
  670. {
  671. KillTimer(CatchingTimer[playerid]);
  672. CatchingTimer[playerid] = 0;
  673. }
  674. LineTension[playerid] = 0;
  675. TextDrawHideForPlayer(playerid, Text:FishingBar);
  676. TextDrawHideForPlayer(playerid, Text:FishingBackground);
  677. TextDrawHideForPlayer(playerid, Text:FishingOutline);
  678. PlayerInfo[playerid][pFishes] += 1;
  679. PlayerInfo[playerid][pFishSkill] += 1;
  680. new fstring[MAX_PLAYER_NAME], rand;
  681. rand = random(FishNamesNumber);
  682. format(fstring, sizeof(fstring), "%s", FishNames[rand]);
  683. if(Fishes[playerid][pWeight1] == 0)
  684. {
  685. strmid(Fishes[playerid][pFish1], fstring, 0, strlen(fstring), 255);
  686. Fishes[playerid][pWeight1] = Caught[playerid];
  687. format(fishStr, sizeof(fishStr), "You have caught a %s, which weighs %d pounds.", Fishes[playerid][pFish1], Caught[playerid]);
  688. SendClientMessage(playerid, COLOR_LIGHTBLUE, fishStr);
  689. Fishes[playerid][pLastFish] = 1;
  690. Fishes[playerid][pFid1] = rand;
  691. }
  692. else if(Fishes[playerid][pWeight2] == 0)
  693. {
  694. strmid(Fishes[playerid][pFish2], fstring, 0, strlen(fstring), 255);
  695. Fishes[playerid][pWeight2] = Caught[playerid];
  696. format(fishStr, sizeof(fishStr), "You have caught a %s, which weighs %d pounds.", Fishes[playerid][pFish2], Caught[playerid]);
  697. SendClientMessage(playerid, COLOR_LIGHTBLUE, fishStr);
  698. Fishes[playerid][pLastFish] = 2;
  699. Fishes[playerid][pFid2] = rand;
  700. }
  701. else if(Fishes[playerid][pWeight3] == 0)
  702. {
  703. strmid(Fishes[playerid][pFish3], fstring, 0, strlen(fstring), 255);
  704. Fishes[playerid][pWeight3] = Caught[playerid];
  705. format(fishStr, sizeof(fishStr), "You have caught a %s, which weighs %d pounds.", Fishes[playerid][pFish3], Caught[playerid]);
  706. SendClientMessage(playerid, COLOR_LIGHTBLUE, fishStr);
  707. Fishes[playerid][pLastFish] = 3;
  708. Fishes[playerid][pFid3] = rand;
  709. }
  710. else if(Fishes[playerid][pWeight4] == 0)
  711. {
  712. strmid(Fishes[playerid][pFish4], fstring, 0, strlen(fstring), 255);
  713. Fishes[playerid][pWeight4] = Caught[playerid];
  714. format(fishStr, sizeof(fishStr), "You have caught a %s, which weighs %d pounds.", Fishes[playerid][pFish4], Caught[playerid]);
  715. SendClientMessage(playerid, COLOR_LIGHTBLUE, fishStr);
  716. Fishes[playerid][pLastFish] = 4;
  717. Fishes[playerid][pFid4] = rand;
  718. }
  719. else if(Fishes[playerid][pWeight5] == 0)
  720. {
  721. strmid(Fishes[playerid][pFish5], fstring, 0, strlen(fstring), 255);
  722. Fishes[playerid][pWeight5] = Caught[playerid];
  723. format(fishStr, sizeof(fishStr), "You have caught a %s, which weighs %d pounds.", Fishes[playerid][pFish5], Caught[playerid]);
  724. SendClientMessage(playerid, COLOR_LIGHTBLUE, fishStr);
  725. Fishes[playerid][pLastFish] = 5;
  726. Fishes[playerid][pFid5] = rand;
  727. }
  728. //
  729. if(Caught[playerid] > PlayerInfo[playerid][pBiggestFish])
  730. {
  731. format(fishStr, sizeof(fishStr), "You beat your old record of %d pounds! Your new biggest fish is %d pounds.", PlayerInfo[playerid][pBiggestFish], Caught[playerid]);
  732. SendClientMessage(playerid, COLOR_LIGHTBLUE, fishStr);
  733. PlayerInfo[playerid][pBiggestFish] = Caught[playerid];
  734. OnePlayAnim(playerid, "CASINO", "manwind", 4.0, 0, 0, 0, 0, 0);
  735. }
  736. //
  737. if(PlayerInfo[playerid][pFishSkill] == 50)
  738. {
  739. SendClientMessage(playerid, COLOR_YELLOW, "* Your Fishing Skill is now Level 2, you can now catch Heavier Fish.");
  740. }
  741. else if(PlayerInfo[playerid][pFishSkill] == 250)
  742. {
  743. SendClientMessage(playerid, COLOR_YELLOW, "* Your Fishing Skill is now Level 3, you can now catch Heavier Fish.");
  744. }
  745. else if(PlayerInfo[playerid][pFishSkill] == 500)
  746. {
  747. SendClientMessage(playerid, COLOR_YELLOW, "* Your Fishing Skill is now Level 4, you can now catch Heavier Fish.");
  748. }
  749. else if(PlayerInfo[playerid][pFishSkill] == 1000)
  750. {
  751. SendClientMessage(playerid, COLOR_YELLOW, "* Your Fishing Skill is now Level 5, you can now catch Heavier Fish.");
  752. }
  753. //
  754. FishingTimer[playerid] = SetTimerEx("Fishing", 7 *1000, 1, "i", playerid);
  755. ApplyAnimationEx(playerid, "CAMERA", "camstnd_idleloop", 4.1, 1, 0, 0, 0, 0);
  756. showNewbieTipMessage(playerid, 12); //sellfish
  757. }
  758. }
  759. else
  760. {
  761. TextDrawHideForPlayer(playerid, Text:FishingBar);
  762. TextDrawHideForPlayer(playerid, Text:FishingBackground);
  763. TextDrawHideForPlayer(playerid, Text:FishingOutline);
  764. TogglePlayerControllable(playerid, true);
  765. IsFishing[playerid] = 0;
  766. LineTension[playerid] = 0;
  767. KillTimer(TextDrawTimer[playerid]);
  768. TextDrawTimer[playerid] = 0;
  769. KillTimer(CatchingTimer[playerid]);
  770. CatchingTimer[playerid] = 0;
  771. KillTimer(FishingTimer[playerid]);
  772. FishingTimer[playerid] = 0;
  773. return SendClientMessage(playerid, COLOR_GREY, "You are no longer fishing.");
  774. }
  775. }
  776. return 0;
  777. }
  778. // Update the fish textdraw
  779. public UpdateTextDraw(playerid)
  780. {
  781. if(IsPlayerConnected(playerid))
  782. {
  783. TextDrawHideForPlayer(playerid, Text:FishingBar);
  784. if(LineTension[playerid] >= 0 && LineTension[playerid] <= 2)
  785. {
  786. TextDrawTextSize(FishingBar, 549.000000, 0.000000);
  787. }
  788. else if(LineTension[playerid] >= 3 && LineTension[playerid] <= 5)
  789. {
  790. TextDrawTextSize(FishingBar, 550.000000, 0.000000);
  791. }
  792. else if(LineTension[playerid] >= 6 && LineTension[playerid] <= 8)
  793. {
  794. TextDrawTextSize(FishingBar, 552.000000, 0.000000);
  795. }
  796. else if(LineTension[playerid] >= 9 && LineTension[playerid] <= 11)
  797. {
  798. TextDrawTextSize(FishingBar, 553.000000, 0.000000);
  799. }
  800. else if(LineTension[playerid] >= 12 && LineTension[playerid] <= 14)
  801. {
  802. TextDrawTextSize(FishingBar, 554.000000, 0.000000);
  803. }
  804. else if(LineTension[playerid] >= 15 && LineTension[playerid] <= 17)
  805. {
  806. TextDrawTextSize(FishingBar, 556.000000, 0.000000);
  807. }
  808. else if(LineTension[playerid] >= 18 && LineTension[playerid] <= 20)
  809. {
  810. TextDrawTextSize(FishingBar, 557.000000, 0.000000);
  811. }
  812. else if(LineTension[playerid] >= 21 && LineTension[playerid] <= 23)
  813. {
  814. TextDrawTextSize(FishingBar, 559.000000, 0.000000);
  815. }
  816. else if(LineTension[playerid] >= 24 && LineTension[playerid] <= 26)
  817. {
  818. TextDrawTextSize(FishingBar, 560.000000, 0.000000);
  819. }
  820. else if(LineTension[playerid] >= 27 && LineTension[playerid] <= 29)
  821. {
  822. TextDrawTextSize(FishingBar, 562.000000, 0.000000);
  823. }
  824. else if(LineTension[playerid] >= 30 && LineTension[playerid] <= 32)
  825. {
  826. TextDrawTextSize(FishingBar, 563.000000, 0.000000);
  827. }
  828. else if(LineTension[playerid] >= 33 && LineTension[playerid] <= 35)
  829. {
  830. TextDrawTextSize(FishingBar, 565.000000, 0.000000);
  831. }
  832. else if(LineTension[playerid] >= 36 && LineTension[playerid] <= 38)
  833. {
  834. TextDrawTextSize(FishingBar, 566.000000, 0.000000);
  835. }
  836. else if(LineTension[playerid] >= 39 && LineTension[playerid] <= 41)
  837. {
  838. TextDrawTextSize(FishingBar, 568.000000, 0.000000);
  839. }
  840. else if(LineTension[playerid] >= 42 && LineTension[playerid] <= 44)
  841. {
  842. TextDrawTextSize(FishingBar, 569.000000, 0.000000);
  843. }
  844. else if(LineTension[playerid] >= 45 && LineTension[playerid] <= 47)
  845. {
  846. TextDrawTextSize(FishingBar, 571.000000, 0.000000);
  847. }
  848. else if(LineTension[playerid] >= 48 && LineTension[playerid] <= 50)
  849. {
  850. TextDrawTextSize(FishingBar, 572.000000, 0.000000);
  851. }
  852. else if(LineTension[playerid] >= 51 && LineTension[playerid] <= 53)
  853. {
  854. TextDrawTextSize(FishingBar, 574.000000, 0.000000);
  855. }
  856. else if(LineTension[playerid] >= 54 && LineTension[playerid] <= 56)
  857. {
  858. TextDrawTextSize(FishingBar, 576.000000, 0.000000);
  859. }
  860. else if(LineTension[playerid] >= 57 && LineTension[playerid] <= 59)
  861. {
  862. TextDrawTextSize(FishingBar, 578.000000, 0.000000);
  863. }
  864. else if(LineTension[playerid] >= 60 && LineTension[playerid] <= 62)
  865. {
  866. TextDrawTextSize(FishingBar, 580.000000, 0.000000);
  867. }
  868. else if(LineTension[playerid] >= 63 && LineTension[playerid] <= 65)
  869. {
  870. TextDrawTextSize(FishingBar, 582.000000, 0.000000);
  871. }
  872. else if(LineTension[playerid] >= 66 && LineTension[playerid] <= 68)
  873. {
  874. TextDrawTextSize(FishingBar, 584.000000, 0.000000);
  875. }
  876. else if(LineTension[playerid] >= 69 && LineTension[playerid] <= 71)
  877. {
  878. TextDrawTextSize(FishingBar, 586.000000, 0.000000);
  879. }
  880. else if(LineTension[playerid] >= 72 && LineTension[playerid] <= 74)
  881. {
  882. TextDrawTextSize(FishingBar, 587.000000, 0.000000);
  883. }
  884. else if(LineTension[playerid] >= 75 && LineTension[playerid] <= 77)
  885. {
  886. TextDrawTextSize(FishingBar, 588.000000, 0.000000);
  887. }
  888. else if(LineTension[playerid] >= 78 && LineTension[playerid] <= 80)
  889. {
  890. TextDrawTextSize(FishingBar, 590.000000, 0.000000);
  891. }
  892. else if(LineTension[playerid] >= 81 && LineTension[playerid] <= 83)
  893. {
  894. TextDrawTextSize(FishingBar, 592.000000, 0.000000);
  895. }
  896. else if(LineTension[playerid] >= 84 && LineTension[playerid] <= 86)
  897. {
  898. TextDrawTextSize(FishingBar, 594.000000, 0.000000);
  899. }
  900. else if(LineTension[playerid] >= 87 && LineTension[playerid] <= 89)
  901. {
  902. TextDrawTextSize(FishingBar, 596.000000, 0.000000);
  903. }
  904. else if(LineTension[playerid] >= 90 && LineTension[playerid] <= 92)
  905. {
  906. TextDrawTextSize(FishingBar, 598.000000, 0.000000);
  907. }
  908. else if(LineTension[playerid] >= 93 && LineTension[playerid] <= 95)
  909. {
  910. TextDrawTextSize(FishingBar, 600.000000, 0.000000);
  911. }
  912. else if(LineTension[playerid] >= 96 && LineTension[playerid] <= 98)
  913. {
  914. TextDrawTextSize(FishingBar, 602.000000, 0.000000);
  915. }
  916. else if(LineTension[playerid] >= 99 && LineTension[playerid] <= 100)
  917. {
  918. TextDrawTextSize(FishingBar, 604.000000, 0.000000);
  919. }
  920. TextDrawShowForPlayer(playerid, Text:FishingBar);
  921. }
  922. return 1;
  923. }