Advertisement
Matrix1

Ribi System :D

May 10th, 2014
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.75 KB | None | 0 0
  1. enum EFishInfo {
  2. EFishName[32],
  3. EFishGunID, //if its not 0, give them this gun when they get it
  4. EFishValue, //value for selling, multplied by weight
  5. EFishMinWeight,
  6. EFishMaxWeight,
  7. };
  8.  
  9. new FishInfo[][EFishInfo] = {
  10. {"Salmon",0,500,1,15},
  11. {"Tuna",0,700,1,15},
  12. {"Crab",0,200,1,5},
  13. {"Trout",0,250,1,15},
  14. {"Sea Bass",0,550,1,8},
  15. {"Shark",0,150,1,15},
  16. {"Turtle",0,50,1,25},
  17. {"Dolphin",0,250,1,25},
  18. {"Cat Fish",0,350,1,5},
  19. {"Blue Marlin",0,450,1,5},
  20. //junk
  21. {"Can",0,0,0,0},
  22. {"Pants",0,0,0,0},
  23. {"Shoes",0,0,0,0},
  24. {"Garbage",0,0,0,0},
  25. {"Baby Diaper",0,0,0,0},
  26. {"Tire",0,0,0,0},
  27. //{"Human Finger",0,0,0,0},
  28. //{"Severed Penis",0,0,0,0},
  29. //{"Dead Baby",0,0,0,0},
  30. {"Car Battery",0,0,0,0},
  31. {"Horse Hoove",0,0,0,0},
  32. {"Log",0,0,0,0},
  33. //guns
  34. {"AK47",30,0,0,0},
  35. {"Desert Eagle",24,0,0,0},
  36. {"M4",31,0,0,0},
  37. {"Shotgun",25,0,0,0},
  38. {"MP5",29,0,0,0},
  39. {"Nite Stick",3,0,0,0}
  40. };
  41.  
  42. #define MAX_HOLDABLE_FISH 5
  43. #define FISH_CMD_TIME 60
  44.  
  45. new PlayerFishing[MAX_PLAYERS];
  46. new FishTimer[MAX_PLAYERS];
  47. new CanCastPoll[MAX_PLAYERS];
  48.  
  49. enum EHoldFishInfo {
  50. EHoldingFishIdx,
  51. EHoldingFishWeight,
  52. EHoldingFightCaughtTime,
  53. }
  54. new HoldingFish[MAX_PLAYERS][MAX_HOLDABLE_FISH][EHoldFishInfo];
  55.  
  56. fishOnGameModeInit() {
  57.  
  58. CreateDynamicPickup(1239, 16, 362.2244,-2088.7981,7.8359);
  59. CreateDynamic3DTextLabel("(( /fish ))", 0x2BB00AA, 362.2244,-2088.7981,7.8359+1, 50.0);
  60.  
  61. CreateDynamicPickup(1239, 16, 354.5382,-2088.7979,7.8359);
  62. CreateDynamic3DTextLabel("(( /fish ))", 0x2BB00AA, 354.5382,-2088.7979,7.8359+1, 50.0);
  63.  
  64. CreateDynamicPickup(1239, 16, 369.8107,-2088.7927,7.8359);
  65. CreateDynamic3DTextLabel("(( /fish ))", 0x2BB00AA, 369.8107,-2088.7927,7.8359+1, 50.0);
  66.  
  67. CreateDynamicPickup(1239, 16, 367.3637,-2088.7925,7.8359);
  68. CreateDynamic3DTextLabel("(( /fish ))", 0x2BB00AA, 367.3637,-2088.7925,7.8359+1, 50.0);
  69.  
  70. CreateDynamicPickup(1239, 16, 383.4157,-2088.7849,7.8359);
  71. CreateDynamic3DTextLabel("(( /fish ))", 0x2BB00AA, 383.4157,-2088.7849,7.8359+1, 50.0);
  72.  
  73. CreateDynamicPickup(1239, 16, 374.9598,-2088.7979,7.8359);
  74. CreateDynamic3DTextLabel("(( /fish ))", 0x2BB00AA, 374.9598,-2088.7979,7.8359+1, 50.0);
  75.  
  76. CreateDynamicPickup(1239, 16, 396.2197,-2088.6692,7.8359);
  77. CreateDynamic3DTextLabel("(( /fish ))", 0x2BB00AA, 396.2197,-2088.6692,7.8359+1, 50.0);
  78.  
  79. CreateDynamicPickup(1239, 16, 391.1094,-2088.7976,7.8359);
  80. CreateDynamic3DTextLabel("(( /fish ))", 0x2BB00AA, 391.1094,-2088.7976,7.8359+1, 50.0);
  81.  
  82. CreateDynamicPickup(1239, 16, 398.7553,-2088.7490,7.8359);
  83. CreateDynamic3DTextLabel("(( /fish ))", 0x2BB00AA, 398.7553,-2088.7490,7.8359+1, 50.0);
  84.  
  85. CreateDynamicPickup(1239, 16, 403.8266,-2088.7598,7.8359);
  86. CreateDynamic3DTextLabel("(( /fish ))", 0x2BB00AA, 403.8266,-2088.7598,7.8359+1, 50.0);
  87.  
  88.  
  89.  
  90.  
  91. }
  92. fishOnPlayerLogin(playerid) {
  93. for(new i=0;i<MAX_HOLDABLE_FISH;i++) {
  94. HoldingFish[playerid][i][EHoldingFishIdx] = -1;
  95. HoldingFish[playerid][i][EHoldingFishWeight] = 0;
  96. HoldingFish[playerid][i][EHoldingFightCaughtTime] = 0;
  97.  
  98. }
  99. PlayerFishing[playerid] = 0;
  100. }
  101. tryHoldFish(playerid, fish, weight) {
  102. for(new i=0;i<MAX_HOLDABLE_FISH;i++) {
  103. if(HoldingFish[playerid][i][EHoldingFishIdx] == -1) {
  104. HoldingFish[playerid][i][EHoldingFishIdx] = fish;
  105. HoldingFish[playerid][i][EHoldingFishWeight] = weight;
  106. HoldingFish[playerid][i][EHoldingFightCaughtTime] = gettime();
  107. return 1;
  108. }
  109.  
  110. }
  111. return 0;
  112. }
  113. forward RandomFish(playerid);
  114. public RandomFish(playerid) {
  115. new shouldCatchFish = RandomEx(0, 5);
  116. new msg[128];
  117. new foundfish = 0;
  118. if(shouldCatchFish <= 2) {
  119. new idx = RandomEx(0,sizeof(FishInfo));
  120. new weight = RandomEx(FishInfo[idx][EFishMinWeight],FishInfo[idx][EFishMaxWeight]);
  121. new shouldGetGun = RandomEx(0,100)==5;
  122. if(FishInfo[idx][EFishGunID] != 0 && shouldGetGun == 1) {
  123. foundfish = 1;
  124. format(msg, sizeof(msg), "~g~Congratulations!, ~w~You found a ~r~%s~w~!",FishInfo[idx][EFishName]);
  125. ShowScriptMessage(playerid, msg, 3000);
  126. format(msg, sizeof(msg), "{%s}Congratulations!, {%s}You found a {%s}%s{%s}!",getColourString(COLOR_GREEN),getColourString(COLOR_WHITE),getColourString(COLOR_GREEN),FishInfo[idx][EFishName],getColourString(COLOR_WHITE));
  127. SendClientMessage(playerid, COLOR_GREEN, msg);
  128. new gun, ammo, slot = GetWeaponSlot(FishInfo[idx][EFishGunID]);
  129. GetPlayerWeaponDataEx(playerid, slot, gun, ammo);
  130. if(gun != 0 && gun != FishInfo[idx][EFishGunID]) {
  131. SendClientMessage(playerid, X11_TOMATO_2, "The weapon has been discarded since you are holding a weapon in its slot!");
  132. //return 1;
  133. } else {
  134. GivePlayerWeaponEx(playerid, FishInfo[idx][EFishGunID], -1);
  135. }
  136.  
  137. //return 1;
  138. } else if(FishInfo[idx][EFishMaxWeight] == 0 && FishInfo[idx][EFishGunID] == 0) {
  139. foundfish = 1;
  140. format(msg, sizeof(msg), "~r~Sorry!, ~w~You found a ~g~%s~w~, try again!",FishInfo[idx][EFishName]);
  141. ShowScriptMessage(playerid, msg, 3000);
  142. format(msg, sizeof(msg), "{%s}Sorry!, {%s}You found a {%s}%s{%s}, try again!",getColourString(COLOR_RED),getColourString(COLOR_WHITE),getColourString(COLOR_GREEN),FishInfo[idx][EFishName],getColourString(COLOR_WHITE));
  143. SendClientMessage(playerid, COLOR_GREEN, msg);
  144. //return 1;
  145. } else if(FishInfo[idx][EFishGunID] == 0) {
  146. foundfish = 1;
  147. format(msg, sizeof(msg), "~g~Congratulations!, ~w~You found a ~r~%s~w~, weighing %d pounds!",FishInfo[idx][EFishName],weight);
  148. ShowScriptMessage(playerid, msg, 6000);
  149. format(msg, sizeof(msg), "{%s}Congratulations!, {%s}You found a {%s}%s{%s}, weighing %d pounds!",getColourString(COLOR_GREEN),getColourString(COLOR_WHITE),getColourString(COLOR_RED),FishInfo[idx][EFishName],getColourString(COLOR_WHITE),weight);
  150. SendClientMessage(playerid, COLOR_GREEN, msg);
  151. if(!tryHoldFish(playerid, idx, weight)) {
  152. SendClientMessage(playerid, X11_TOMATO_2, "You are holding too many fish already!");
  153. HintMessage(playerid, COLOR_LIGHTGREEN, "Use /dropfish to drop a fish");
  154. //return 0;
  155. }
  156. }
  157. if(foundfish == 1) {
  158. format(msg, sizeof(msg), "* %s reels a %s in with %s fishing poll.",GetPlayerNameEx(playerid, ENameType_RPName),FishInfo[idx][EFishName],getPossiveAdjective(playerid));
  159. ProxMessage(30.0, playerid, msg, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  160. return 1;
  161. }
  162. }
  163. format(msg, sizeof(msg), "* %s reels nothing in with %s fishing poll.",GetPlayerNameEx(playerid, ENameType_RPName),getPossiveAdjective(playerid));
  164. ProxMessage(30.0, playerid, msg, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  165. ShowScriptMessage(playerid, "~r~Sorry! ~w~You didn't find anything, try again!", 6000);
  166. return 0;
  167. }
  168. YCMD:dropfish(playerid, params[], help) {
  169. if(help) {
  170. SendClientMessage(playerid, X11_WHITE, "Destroys a fish on hand");
  171. return 1;
  172. }
  173. new msg[128],fishidx;
  174. if(!sscanf(params, "d",fishidx)) {
  175. fishidx--;
  176. if(fishidx < 0 || fishidx > MAX_HOLDABLE_FISH) {
  177. SendClientMessage(playerid, X11_TOMATO_2, "Invalid Fish Index!");
  178. return 1;
  179. }
  180. if(HoldingFish[playerid][fishidx][EHoldingFishIdx] == -1) {
  181. SendClientMessage(playerid, X11_TOMATO_2, "You are not holding a fish in this slot!");
  182. return 1;
  183. }
  184. format(msg, sizeof(msg), "* %s takes a %s out and throws it on the ground.", GetPlayerNameEx(playerid, ENameType_RPName), FishInfo[HoldingFish[playerid][fishidx][EHoldingFishIdx]][EFishName]);
  185. ProxMessage(30.0, playerid, msg, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  186. HoldingFish[playerid][fishidx][EHoldingFishIdx] = -1;
  187. HoldingFish[playerid][fishidx][EHoldingFishWeight] = 0;
  188. HoldingFish[playerid][fishidx][EHoldingFightCaughtTime] = 0;
  189. } else {
  190. SendClientMessage(playerid, X11_WHITE, "USAGE: /dropfish [id]");
  191. SendClientMessage(playerid, X11_WHITE, "Use /myfish to see your fish id");
  192. }
  193. return 1;
  194. }
  195. YCMD:myfish(playerid, params[], help) {
  196. if(help) {
  197. SendClientMessage(playerid, X11_WHITE, "Lists your fish");
  198. return 1;
  199. }
  200. new msg[128];
  201. SendClientMessage(playerid, X11_WHITE, "**** Your fish ****");
  202. for(new i=0;i<MAX_HOLDABLE_FISH;i++) {
  203. if(HoldingFish[playerid][i][EHoldingFishIdx] != -1) {
  204. new fidx = HoldingFish[playerid][i][EHoldingFishIdx];
  205. format(msg, sizeof(msg), "%d. %s - Weight: %d",i+1,FishInfo[fidx][EFishName],HoldingFish[playerid][i][EHoldingFishWeight]);
  206. SendClientMessage(playerid, COLOR_LIGHTBLUE, msg);
  207. }
  208. }
  209. return 1;
  210. }
  211. StartFishing(playerid) {
  212. PlayerFishing[playerid] = 1;
  213. CanCastPoll[playerid] = 1;
  214. FishTimer[playerid] = -1;
  215. ShowScriptMessage(playerid, "~w~Press ~r~~k~~PED_SPRINT~~w~ to cast the fishing poll.", 10000);
  216. }
  217. StopFishing(playerid) {
  218. if(FishTimer[playerid] != -1)
  219. KillTimer(FishTimer[playerid]);
  220. FishTimer[playerid] = -1;
  221. PlayerFishing[playerid] = 0;
  222. HintMessage(playerid, COLOR_LIGHTGREEN, "You can see your fish with /myfish, and sell them at the fish store.");
  223. }
  224. forward FishingReadyTimer(playerid);
  225. public FishingReadyTimer(playerid) {
  226. ShowScriptMessage(playerid, "~w~Press ~r~~k~~PED_SPRINT~~w~ to cast the fishing poll.", 16000);
  227. CanCastPoll[playerid] = 1;
  228. }
  229. GetFishInfoAt(playerid, name[], namesize, slot, &weight, &value) {
  230. if(slot < 0 || slot > MAX_HOLDABLE_FISH) return 0;
  231. if(HoldingFish[playerid][slot][EHoldingFishIdx] != -1) {
  232. new fidx = HoldingFish[playerid][slot][EHoldingFishIdx];
  233. format(name, namesize, "%s",FishInfo[fidx][EFishName]);
  234. weight = HoldingFish[playerid][slot][EHoldingFishWeight];
  235. value = weight * FishInfo[fidx][EFishValue];
  236. value = floatround(value / 2.0);
  237. } else {
  238. value = 0;
  239. weight = 0;
  240. }
  241. return 1;
  242. }
  243. RemoveFishAt(playerid, idx) {
  244. HoldingFish[playerid][idx][EHoldingFishIdx] = -1;
  245. HoldingFish[playerid][idx][EHoldingFishWeight] = 0;
  246. HoldingFish[playerid][idx][EHoldingFightCaughtTime] = 0;
  247. }
  248. YCMD:catchfish(playerid, params[], help) {
  249. RandomFish(playerid);
  250. return 1;
  251. }
  252. fishingOnPlayerDisconnect(playerid, reason) {
  253. #pragma unused reason
  254. if(FishTimer[playerid] != -1) {
  255. KillTimer(FishTimer[playerid]);
  256. FishTimer[playerid] = -1;
  257. }
  258. }
  259. YCMD:fish(playerid, params[], help) {
  260. if(!IsWearingAccessory(playerid, 18632)) {
  261. SendClientMessage(playerid, X11_TOMATO_2, "You are not holding a fishing poll!");
  262. HintMessage(playerid, COLOR_LIGHTGREEN, "You can buy a fishing poll at bincos. Use /accessories to take it out."); //, or the fish store
  263. return 1;
  264. }
  265. if(PlayerFishing[playerid] != 1) {
  266. if(!IsNearFishVehicle(playerid)) {
  267. SendClientMessage(playerid, X11_TOMATO_2, "You are not on a boat, or at the fishing point!");
  268. return 1;
  269. }
  270. if(IsAtFishPlace(playerid)) {
  271. new ELicenseFlags:lflags = ELicenseFlags:GetPVarInt(playerid, "LicenseFlags");
  272. if(~lflags & ELicense_Fishing) {
  273. SendClientMessage(playerid, X11_TOMATO_2, "You can't fish here since you don't have a fishing license");
  274. HintMessage(playerid, COLOR_LIGHTGREEN, "You can illegally fish if you buy a boat.");
  275. return 1;
  276. }
  277. }
  278. new msg[128];
  279. new timenow = gettime();
  280. new time = GetPVarInt(playerid, "LastFishCmd");
  281. if(FISH_CMD_TIME-(timenow-time) > 0) {
  282. format(msg, sizeof(msg), "You must wait %d seconds before you can use this command",FISH_CMD_TIME-(timenow-time));
  283. SendClientMessage(playerid, X11_TOMATO_2, msg);
  284. return 1;
  285. }
  286.  
  287. SetPVarInt(playerid, "LastFishCmd", gettime());
  288. StartFishing(playerid);
  289. } else {
  290. StopFishing(playerid);
  291. }
  292. return 1;
  293. }
  294. IsAtFishPlace(playerid)
  295. {
  296. //FuncLog("IsAtFishPlace");
  297. if(IsPlayerConnected(playerid))
  298. {
  299. if(IsPlayerInRangeOfPoint(playerid,1.0,403.8266,-2088.7598,7.8359) || IsPlayerInRangeOfPoint(playerid, 1.0,398.7553,-2088.7490,7.8359))
  300. {//Fishplace at the bigwheel
  301. return 1;
  302. }
  303. else if(IsPlayerInRangeOfPoint(playerid, 1.0,396.2197,-2088.6692,7.8359) || IsPlayerInRangeOfPoint(playerid, 1.0,391.1094,-2088.7976,7.8359))
  304. {//Fishplace at the bigwheel
  305. return 1;
  306. }
  307. else if(IsPlayerInRangeOfPoint(playerid, 1.0, 383.4157,-2088.7849,7.8359) || IsPlayerInRangeOfPoint(playerid, 1.0,374.9598,-2088.7979,7.8359))
  308. {//Fishplace at the bigwheel
  309. return 1;
  310. }
  311. else if(IsPlayerInRangeOfPoint(playerid, 1.0,369.8107,-2088.7927,7.8359) || IsPlayerInRangeOfPoint(playerid, 1.0,367.3637,-2088.7925,7.8359))
  312. {//Fishplace at the bigwheel
  313. return 1;
  314. }
  315. else if(IsPlayerInRangeOfPoint(playerid, 1.0,362.2244,-2088.7981,7.8359) || IsPlayerInRangeOfPoint(playerid, 1.0,354.5382,-2088.7979,7.8359))
  316. {//Fishplace at the bigwheel
  317. return 1;
  318. }
  319. }
  320. return 0;
  321. }
  322. IsNearFishVehicle(playerid) {
  323. new carid = GetClosestVehicle(playerid);
  324. new model;
  325. model = GetVehicleModel(carid);
  326. if(IsAtFishPlace(playerid) || DistanceBetweenPlayerAndVeh(playerid, carid) < 10.0 && IsABoat(model))
  327. {
  328. return 1;
  329. } else {
  330. carid = GetPlayerSurfingVehicleID(playerid);
  331. model = GetVehicleModel(carid);
  332. if(carid != INVALID_VEHICLE_ID) {
  333. if(DistanceBetweenPlayerAndVeh(playerid, carid) < 10.0 && IsABoat(model)) {
  334. return 1;
  335. }
  336. }
  337. }
  338. return 0;
  339.  
  340. }
  341. fishOnPlayerKeyState(playerid, oldkeys, newkeys) {
  342. #pragma unused oldkeys
  343. if(newkeys & KEY_SPRINT) {
  344. if(PlayerFishing[playerid] == 1) {
  345. if(!IsNearFishVehicle(playerid)) {
  346. SendClientMessage(playerid, X11_TOMATO_2, "Since you left the fishing point, you stopped fishing.");
  347. StopFishing(playerid);
  348. return 0;
  349. }
  350. if(FishTimer[playerid] == -1) {
  351. FishTimer[playerid] = SetTimerEx("FishingReadyTimer", 15000, true, "i", playerid);
  352. }
  353. if(CanCastPoll[playerid] == 1) {
  354. SetTimerEx("RandomFish", 3000, false, "d", playerid);
  355. ApplyAnimation(playerid,"SWORD","sword_block",50.0,0,1,0,1,1);
  356. ShowScriptMessage(playerid, "Casting poll... Lets see if you catch anything!", 8000);
  357. CanCastPoll[playerid] = 0;
  358. } else {
  359. ShowScriptMessage(playerid, "You must wait 15 seconds before you can cast again", 10000);
  360. }
  361. }
  362. }
  363. return 0;
  364. }
  365. YCMD:eatfish(playerid, params[], help) {
  366. if(help) {
  367. SendClientMessage(playerid, X11_WHITE, "Eat your fish");
  368. return 1;
  369. }
  370. new index, msg[128];
  371. if(!sscanf(params, "d", index)) {
  372. index--;
  373. if(index < 0 || index > MAX_HOLDABLE_FISH) {
  374. SendClientMessage(playerid, X11_TOMATO_2, "Invalid fish index, use /myfish");
  375. return 1;
  376. }
  377. new fish = HoldingFish[playerid][index][EHoldingFishIdx];
  378. if(fish != -1) {
  379. format(msg, sizeof(msg), "* %s eats a %s.", GetPlayerNameEx(playerid, ENameType_RPName), FishInfo[fish][EFishName]);
  380. ProxMessage(30.0, playerid, msg, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  381. new boost = HoldingFish[playerid][index][EHoldingFishWeight]*2;
  382. boost = GetHungerLevel(playerid)+boost;
  383. if(boost > 100) boost = 100;
  384. SetPlayerHunger(playerid, boost);
  385. RemoveFishAt(playerid, index);
  386. return 1;
  387. } else {
  388. SendClientMessage(playerid, X11_TOMATO_2, "You are not holding a fish at this slot!");
  389. }
  390. } else {
  391. SendClientMessage(playerid, X11_WHITE, "USAGE: /eatfish [fishidx]");
  392. }
  393. return 1;
  394. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement