Guest User

Untitled

a guest
Jun 25th, 2012
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 16.75 KB | None | 0 0
  1. //------------------------------------------||
  2. //---------||^^^^^^^^^^^^^^^^^^||-----------||
  3. //---------||  Fishing System  ||-----------||
  4. //---------||       v1.0       ||-----------||
  5. //---------||   By BumbiS*     ||-----------||
  6. //---------||__________________||-----------||
  7. //------------------------------------------||
  8. //---------|| Do NOT remove credits ||------||
  9. //------------------------------------------||
  10. //---------|| Credits ||--------------------||
  11. //------|| BumbiS* for creating this FS ||--||
  12. //-------|| DracoBlue for dcmd ||-----------||
  13. //--------|| Y_Less for randomEx ||---------||
  14. //------------------------------------------||
  15.  
  16. #include <a_samp>
  17. #include <string>
  18. #include <core>
  19.  
  20. //--------|| Here you can basically change prices ||-------||
  21. #define BaitPrice 15
  22. #define FishingToolPrice 150
  23.  
  24. //--------|| dcmd by DracoBlue ||---------------------||
  25. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  26. //--------|| Colors ||--------------------------------||
  27. #define COLOR_GREY 0xAFAFAFAA
  28. #define COLOR_GREEN 0x9EC73DAA
  29. #define COLOR_RED 0xAA3333AA
  30. #define COLOR_YELLOW 0xDABB3EAA
  31. #define COLOR_YELLOW2 0xF5DEB3AA
  32. #define COLOR_GREENYELLOW 0xADFF2FFF
  33. #define COLOR_PURPLE 0xB370FCFF
  34. #define COLOR_WHITE 0xFFFFFFAA
  35. //----------------------------------------------------||
  36.  
  37. new Fishes[MAX_PLAYERS];
  38. new AlreadyFished[MAX_PLAYERS];
  39. new FishingTool[MAX_PLAYERS];
  40. new Worms[MAX_PLAYERS];
  41. new FishWeight[MAX_PLAYERS];
  42. new IsFishing[MAX_PLAYERS];
  43. new fishing;
  44.  
  45. forward IsAtFishPlace(playerid);
  46. forward FishTime(playerid);
  47. forward SendRPMessage(playerid, Float:radius, color, string[]);
  48. forward StopFish(playerid);
  49.  
  50. public OnFilterScriptInit()
  51. {
  52.     print("\n--------------------------------------");
  53.     print(" Fishing System by BumbiS* started");
  54.     print("--------------------------------------\n");
  55.     /////////////////////////////////////////////////
  56.     fishing = AddStaticPickup(1239, 23, 153.9523,-1946.2955,5.1874);
  57.     return 1;
  58. }
  59.  
  60. public OnFilterScriptExit()
  61. {
  62.     return 1;
  63. }
  64.  
  65. public OnPlayerConnect(playerid)
  66. {
  67.     Worms[playerid] = 0; FishingTool[playerid] = 0; AlreadyFished[playerid] = 0;
  68.     Fishes[playerid] = 0; FishWeight[playerid] = 0; IsFishing[playerid] = 0;
  69.     return 1;
  70. }
  71.  
  72. public OnPlayerDisconnect(playerid, reason)
  73. {
  74.     Worms[playerid] = 0; FishingTool[playerid] = 0; AlreadyFished[playerid] = 0;
  75.     Fishes[playerid] = 0; FishWeight[playerid] = 0; IsFishing[playerid] = 0;
  76.     return 1;
  77. }
  78.  
  79. public OnPlayerDeath(playerid, killerid, reason)
  80. {
  81.     Worms[playerid] = 0; FishWeight[playerid] = 0;
  82.     Fishes[playerid] = 0; FishingTool[playerid] = 0;
  83.     return 1;
  84. }
  85. //-----------DCMD Commands--------------------||
  86. dcmd_buytools(playerid, params[])
  87. {
  88.     #pragma unused params
  89.     if(IsPlayerInRangeOfPoint(playerid, 2.5,153.9523,-1946.2955,5.1874))
  90.     {
  91.         new string[128];
  92.         format(string,128,"FishingTools     $%d\nWorms      $%d per one",FishingToolPrice,BaitPrice);
  93.         ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Fishing tools", string,"Purchase","Exit");
  94.         return 1;
  95.     }
  96.     return 1;
  97. }
  98. dcmd_inventory(playerid, params[])
  99. {
  100.     #pragma unused params
  101.     new string[128];
  102.     new string2[128];
  103.     new string3[128];
  104.     SendClientMessage(playerid, COLOR_GREEN, "____|| Your inventory ||___");
  105.     if(FishingTool[playerid]==1)
  106.     {
  107.         format(string,sizeof(string)," -  Fishing Tool");
  108.         SendClientMessage(playerid, COLOR_YELLOW, string);
  109.     }
  110.     if(Worms[playerid]>0)
  111.     {
  112.         format(string2,sizeof(string2)," -  %d Worms", Worms[playerid]);
  113.         SendClientMessage(playerid, COLOR_YELLOW, string2);
  114.     }
  115.     if(Fishes[playerid]>0)
  116.     {
  117.         format(string3,sizeof(string3)," -  %d fishes", Fishes[playerid]);
  118.         SendClientMessage(playerid, COLOR_YELLOW, string3);
  119.     }
  120.     SendClientMessage(playerid, COLOR_GREEN, "___________________________");
  121.     return 1;
  122. }
  123. dcmd_fishhelp(playerid,params[])
  124. {
  125.     #pragma unused params
  126.     SendClientMessage(playerid,COLOR_GREEN,"________|| Fishing Help ||___________");
  127.     SendClientMessage(playerid,COLOR_WHITE,"/inventory /buytools");
  128.     SendClientMessage(playerid,COLOR_WHITE,"/fish");
  129.     SendClientMessage(playerid,COLOR_WHITE,"/releaseallfishes");
  130.     SendClientMessage(playerid,COLOR_WHITE,"/sellfishes");
  131.     SendClientMessage(playerid,COLOR_GREEN,"_____________________________________");
  132.     return 1;
  133. }
  134. dcmd_releaseallfishes(playerid,params[])
  135. {
  136.     #pragma unused params
  137.     if(Fishes[playerid] > 0 && IsAtFishPlace(playerid))
  138.     {
  139.         SendClientMessage(playerid, COLOR_YELLOW2, "You released all fishes back in sea.");
  140.         Fishes[playerid] = 0;
  141.         FishWeight[playerid] = 0;
  142.         return 1;
  143.     }
  144.     else
  145.     {
  146.         SendClientMessage(playerid, COLOR_GREY, "You already don't have fishes or you are not at fishing place(Big Wheel)");
  147.         return 1;
  148.     }
  149. }
  150. dcmd_fish(playerid,params[])
  151. {
  152.     #pragma unused params
  153.     new string[128];
  154.     new name[MAX_PLAYER_NAME];
  155.     if(FishingTool[playerid] == 1)
  156.     {
  157.         if(Worms[playerid] > 0)
  158.         {
  159.             if(IsAtFishPlace(playerid))
  160.             {
  161.                 if(AlreadyFished[playerid] == 0 && IsFishing[playerid] == 0)
  162.                 {
  163.                     if(Fishes[playerid] >= 15)
  164.                     {
  165.                         SendClientMessage(playerid,COLOR_RED,"You have enough fishes and you are tiered of fishing.");
  166.                         SendClientMessage(playerid,COLOR_RED,"You can sell your fishes at Los Santos docks (/sellfish @ CheckPoint)");
  167.                         AlreadyFished[playerid] = 1;
  168.                         SetPlayerCheckpoint(playerid, 2766.6602,-2575.1614,3.0000,3.0);
  169.                         SetTimerEx("StopFish", 1000*60*10, 0, "i",playerid);
  170.                     }
  171.                     else
  172.                     {
  173.                         new random2 = randomEx(4000,14000);
  174.                         IsFishing[playerid] = 1;
  175.                         SetTimerEx("FishTime", random2, 0, "i",playerid);
  176.                         GetPlayerName(playerid,name,sizeof(name));
  177.                         format(string,sizeof(string),"%s swings fishing rod and starts to wait for fish",name);
  178.                         SendRPMessage(playerid, 20.0, COLOR_PURPLE, string);
  179.                         GameTextForPlayer(playerid, "~w~Fishing...",random2,3);
  180.                         TogglePlayerControllable(playerid, false);
  181.                     }
  182.                 }
  183.                 else
  184.                 {
  185.                     SendClientMessage(playerid, COLOR_GREY, "You need to wait some time to fish again.");
  186.                     return 1;
  187.                 }
  188.             }
  189.             else
  190.             {
  191.                 SendClientMessage(playerid, COLOR_GREY, "You are not at fishing place(Big Whell or on water)");
  192.                 return 1;
  193.             }
  194.         }
  195.         else
  196.         {
  197.             SendClientMessage(playerid, COLOR_GREY, "You dont have any Baits, buy them at lighthouse");
  198.         }
  199.     }
  200.     else
  201.     {
  202.         SendClientMessage(playerid, COLOR_GREY, "You don't have fishing tools, buy them at lighthouse");
  203.     }
  204.     return 1;
  205. }
  206. dcmd_sellfish(playerid,params[])
  207. {
  208.     #pragma unused params
  209.     if(Fishes[playerid] >= 1)
  210.     {
  211.         if(IsPlayerInRangeOfPoint(playerid, 3.0,2766.6602,-2575.1614,3.0000))
  212.         {
  213.             new string[128];
  214.             Fishes[playerid] = 0;
  215.             format(string,sizeof(string),"You sold all your fishes for $%d.", FishWeight[playerid]);
  216.             SendClientMessage(playerid, COLOR_YELLOW, string);
  217.             GivePlayerMoney(playerid, FishWeight[playerid]);
  218.             FishWeight[playerid] = 0;
  219.         }
  220.         else
  221.         {
  222.             SendClientMessage(playerid, COLOR_GREY, "You need to be at Los Santos docks.");
  223.             SetPlayerCheckpoint(playerid, 2766.6602,-2575.1614,3.0000,3.0);
  224.         }
  225.     }
  226.     else
  227.     {
  228.         SendClientMessage(playerid, COLOR_GREY, "You dont have any fishes that you can sell.");
  229.         return 1;
  230.     }
  231.     return 1;
  232. }
  233.            
  234. //--------------------------------------------||
  235. public OnPlayerCommandText(playerid, cmdtext[])
  236. {
  237.     dcmd(buytools,8,cmdtext);
  238.     dcmd(inventory,9,cmdtext);
  239.     dcmd(fishhelp,8,cmdtext);
  240.     dcmd(releaseallfishes,16,cmdtext);
  241.     dcmd(fish,4,cmdtext);
  242.     dcmd(sellfish,8,cmdtext);
  243.     return 0;
  244. }
  245. public OnPlayerEnterCheckpoint(playerid)
  246. {
  247.     if(IsPlayerInRangeOfPoint(playerid, 3.0,2766.6602,-2575.1614,3.0000))
  248.     {
  249.         if(Fishes[playerid] >= 1)
  250.         {
  251.             new string[128];
  252.             Fishes[playerid] = 0;
  253.             format(string,sizeof(string),"You sold all your fishes for $%d.", FishWeight[playerid]);
  254.             SendClientMessage(playerid, COLOR_YELLOW, string);
  255.             GivePlayerMoney(playerid, FishWeight[playerid]);
  256.             FishWeight[playerid] = 0;
  257.             DisablePlayerCheckpoint(playerid);
  258.             return 1;
  259.         }
  260.     }
  261.     return 1;
  262. }
  263. public OnPlayerPickUpPickup(playerid, pickupid)
  264. {
  265.     if(pickupid == fishing)
  266.     {
  267.         GameTextForPlayer(playerid, "~w~You can buy here~n~some fishing tools~n~type ~r~/buytools ~w~to buy some", 3500, 3);
  268.     }
  269.     return 1;
  270. }
  271.  
  272. public OnPlayerUpdate(playerid)
  273. {
  274.     return 1;
  275. }
  276.  
  277. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  278. {
  279.     if(dialogid == 1)
  280.     {
  281.         if(listitem == 0)
  282.         {
  283.             if(GetPlayerMoney(playerid) >= FishingToolPrice)
  284.             {
  285.                 SendClientMessage(playerid, COLOR_YELLOW, "Successfully purchased Fishing tool! You can now use /fish");
  286.                 SendClientMessage(playerid, COLOR_YELLOW, ", but you also need some baits");
  287.                 FishingTool[playerid] = 1;
  288.                 GivePlayerMoney(playerid, -FishingToolPrice);
  289.             }
  290.             else
  291.             {
  292.                 SendClientMessage(playerid, COLOR_GREY, "You don't have enough money");
  293.             }
  294.         }
  295.         if(listitem == 1)
  296.         {
  297.             new string[128];
  298.             format(string,sizeof(string),"Enter below how much baits do you want.\n$%d per one",BaitPrice);
  299.             ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Baits",string,"Purchase","Exit");
  300.         }
  301.     }
  302.     if(dialogid == 2 && response)
  303.     {
  304.         new price = BaitPrice;
  305.         new string[128];
  306.         new baits = strval(inputtext);
  307.         if(baits > 0)
  308.         {
  309.             new price1 = price*baits;
  310.             if(GetPlayerMoney(playerid) >= price1)
  311.             {
  312.                 GivePlayerMoney(playerid, -price1);
  313.                 format(string,sizeof(string),"You just purchased %d worms for $%d", baits, price1);
  314.                 SendClientMessage(playerid, COLOR_GREEN, string);
  315.                 Worms[playerid] += baits;
  316.                 return 1;
  317.             }
  318.             else
  319.             {
  320.                 SendClientMessage(playerid, COLOR_GREY, "You don't have that much money.");
  321.             }
  322.         }
  323.         else
  324.         {
  325.             SendClientMessage(playerid, COLOR_GREY, "You can't buy baits less than 0");
  326.         }
  327.     }
  328.     return 1;
  329. }
  330. public IsAtFishPlace(playerid)
  331. {
  332.     if(IsPlayerConnected(playerid))
  333.     {
  334.         if(IsPlayerInRangeOfPoint(playerid,1.0,403.8266,-2088.7598,7.8359) || IsPlayerInRangeOfPoint(playerid,1.0,398.7553,-2088.7490,7.8359))
  335.         {
  336.             return 1;
  337.         }
  338.         else if(IsPlayerInRangeOfPoint(playerid,1.0,396.2197,-2088.6692,7.8359) || IsPlayerInRangeOfPoint(playerid,1.0,391.1094,-2088.7976,7.8359))
  339.         {
  340.             return 1;
  341.         }
  342.         else if(IsPlayerInRangeOfPoint(playerid,1.0,383.4157,-2088.7849,7.8359) || IsPlayerInRangeOfPoint(playerid,1.0,374.9598,-2088.7979,7.8359))
  343.         {
  344.             return 1;
  345.         }
  346.         else if(IsPlayerInRangeOfPoint(playerid,1.0,369.8107,-2088.7927,7.8359) || IsPlayerInRangeOfPoint(playerid,1.0,367.3637,-2088.7925,7.8359))
  347.         {
  348.             return 1;
  349.         }
  350.         else if(IsPlayerInRangeOfPoint(playerid,1.0,362.2244,-2088.7981,7.8359) || IsPlayerInRangeOfPoint(playerid,1.0,354.5382,-2088.7979,7.8359))
  351.         {
  352.             return 1;
  353.         }
  354.         else if(IsPlayerInWater(playerid))
  355.         {
  356.             return 1;
  357.         }
  358.     }
  359.     return 0;
  360. }
  361. public FishTime(playerid)
  362. {
  363.     new string[128];
  364.     if(IsPlayerConnected(playerid))
  365.     {
  366.         new rand = randomEx(1,11);
  367.         new weight = randomEx(50,180);
  368.         new money = randomEx(20, 80);
  369.         if(rand == 1)
  370.         {
  371.             SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out some trash and throwed it back in sea");
  372.             Worms[playerid] -= 1;
  373.             IsFishing[playerid] = 0;
  374.             TogglePlayerControllable(playerid,true);
  375.             return 1;
  376.         }
  377.         else if(rand == 2)
  378.         {
  379.             SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out tuna!");
  380.             Fishes[playerid] += 1;
  381.             Worms[playerid] -= 1;
  382.             IsFishing[playerid] = 0;
  383.             FishWeight[playerid] += weight;
  384.             TogglePlayerControllable(playerid,true);
  385.             return 1;
  386.         }
  387.         else if(rand == 3)
  388.         {
  389.             SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Swordfish!");
  390.             Fishes[playerid] += 1;
  391.             IsFishing[playerid] = 0;
  392.             Worms[playerid] -= 1;
  393.             FishWeight[playerid] += weight;
  394.             TogglePlayerControllable(playerid,true);
  395.             return 1;
  396.         }
  397.         else if(rand == 4)
  398.         {
  399.             SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Blue Marlin!");
  400.             Fishes[playerid] += 1;
  401.             Worms[playerid] -= 1;
  402.             IsFishing[playerid] = 0;
  403.             FishWeight[playerid] += weight;
  404.             TogglePlayerControllable(playerid,true);
  405.             return 1;
  406.         }
  407.         else if(rand == 5)
  408.         {
  409.             SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Shark!");
  410.             Fishes[playerid] += 1;
  411.             Worms[playerid] -= 1;
  412.             IsFishing[playerid] = 0;
  413.             FishWeight[playerid] += weight;
  414.             TogglePlayerControllable(playerid,true);
  415.             return 1;
  416.         }
  417.         else if(rand == 6)
  418.         {
  419.             format(string,sizeof(string),"You just fished out Wallet and in there was $%d!", money);
  420.             SendClientMessage(playerid,COLOR_GREENYELLOW,string);
  421.             GivePlayerMoney(playerid, money);
  422.             Worms[playerid] -= 1;
  423.             TogglePlayerControllable(playerid,true);
  424.             IsFishing[playerid] = 0;
  425.             return 1;
  426.         }
  427.         else if(rand == 7)
  428.         {
  429.             SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Eel!");
  430.             Fishes[playerid] += 1;
  431.             TogglePlayerControllable(playerid,true);
  432.             Worms[playerid] -= 1;
  433.             IsFishing[playerid] = 0;
  434.             FishWeight[playerid] += weight;
  435.             return 1;
  436.         }
  437.         else if(rand == 8)
  438.         {
  439.             SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Sea Bass!");
  440.             Fishes[playerid] += 1;
  441.             Worms[playerid] -= 1;
  442.             TogglePlayerControllable(playerid,true);
  443.             IsFishing[playerid] = 0;
  444.             FishWeight[playerid] += weight;
  445.             return 1;
  446.         }
  447.         else if(rand == 9)
  448.         {
  449.             SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Sail Fish!");
  450.             Fishes[playerid] += 1;
  451.             TogglePlayerControllable(playerid,true);
  452.             Worms[playerid] -= 1;
  453.             IsFishing[playerid] = 0;
  454.             FishWeight[playerid] += weight;
  455.             return 1;
  456.         }
  457.         else if(rand == 10)
  458.         {
  459.             SendClientMessage(playerid,COLOR_GREENYELLOW,"You didnt catch anything.");
  460.             Worms[playerid] -= 1;
  461.             TogglePlayerControllable(playerid,true);
  462.             IsFishing[playerid] = 0;
  463.             return 1;
  464.         }
  465.         else
  466.         {
  467.             SendClientMessage(playerid,COLOR_GREENYELLOW,"You didnt catch anything, but you your worm remained");
  468.             IsFishing[playerid] = 0;
  469.             TogglePlayerControllable(playerid,true);
  470.             return 1;
  471.         }
  472.     }
  473.     return 0;
  474. }
  475.  
  476. //-----------|| Function By Bumbis ||--------------||
  477. public SendRPMessage(playerid, Float:radius, color, string[])
  478. {
  479.     if(IsPlayerConnected(playerid))
  480.     {
  481.         for(new i=0;i<MAX_PLAYERS;i++)
  482.         {
  483.             new Float:x,Float:y,Float:z;
  484.             GetPlayerPos(playerid,x,y,z);
  485.             if(IsPlayerInRangeOfPoint(i, radius, x,y,z))
  486.             {
  487.                 SendClientMessage(i,color,string);
  488.                 return 1;
  489.             }
  490.         }
  491.     }
  492.     return 0;
  493. }
  494. //--------------------------------------------------||
  495.  
  496. //-----------|| By Y_Less ||---------------||
  497. stock randomEx(minnum = cellmin, maxnum = cellmax) return random(maxnum - minnum + 1) + minnum;
  498. //----------|| Unknown creator of this, but thanks ||--||
  499. stock IsPlayerInWater(playerid)
  500. {
  501.     new Float:x,Float:y,Float:pz;
  502.     GetPlayerPos(playerid,x,y,pz);
  503.     if (
  504.     (IsPlayerInArea(playerid, 2032.1371, 1841.2656, 1703.1653, 1467.1099) && pz <= 9.0484) //lv piratenschiff
  505.     || (IsPlayerInArea(playerid, 2109.0725, 2065.8232, 1962.5355, 10.8547) && pz <= 10.0792) //lv visage
  506.     || (IsPlayerInArea(playerid, -492.5810, -1424.7122, 2836.8284, 2001.8235) && pz <= 41.06) //lv staucamm
  507.     || (IsPlayerInArea(playerid, -2675.1492, -2762.1792, -413.3973, -514.3894) && pz <= 4.24) //sf südwesten kleiner teich
  508.     || (IsPlayerInArea(playerid, -453.9256, -825.7167, -1869.9600, -2072.8215) && pz <= 5.72) //sf gammel teich
  509.     || (IsPlayerInArea(playerid, 1281.0251, 1202.2368, -2346.7451, -2414.4492) && pz <= 9.3145) //ls neben dem airport
  510.     || (IsPlayerInArea(playerid, 2012.6154, 1928.9028, -1178.6207, -1221.4043) && pz <= 18.45) //ls mitte teich
  511.     || (IsPlayerInArea(playerid, 2326.4858, 2295.7471, -1400.2797, -1431.1266) && pz <= 22.615) //ls weiter südöstlich
  512.     || (IsPlayerInArea(playerid, 2550.0454, 2513.7588, 1583.3751, 1553.0753) && pz <= 9.4171) //lv pool östlich
  513.     || (IsPlayerInArea(playerid, 1102.3634, 1087.3705, -663.1653, -682.5446) && pz <= 112.45) //ls pool nordwestlich
  514.     || (IsPlayerInArea(playerid, 1287.7906, 1270.4369, -801.3882, -810.0527) && pz <= 87.123) //pool bei maddog's haus oben
  515.     || (pz < 1.5)
  516.     )
  517.     {
  518.         return 1;
  519.     }
  520.     return 0;
  521. }
  522. stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
  523. {
  524. new Float:x, Float:y, Float:z;
  525. GetPlayerPos(playerid, x, y, z);
  526. if (x > minx && x < maxx && y > miny && y < maxy) return 1;
  527. return 0;
  528. }
  529. //----------------------------------------------------||
  530. public StopFish(playerid)
  531. {
  532.     AlreadyFished[playerid] = 0;
  533.     SendClientMessage(playerid, COLOR_GREEN, "Hey, you can fish now!");
  534.     return 1;
  535. }
Advertisement
Add Comment
Please, Sign In to add comment