Advertisement
FailerZ

Advance Fish System [AFS]

May 30th, 2015
1,017
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 26.21 KB | None | 0 0
  1. //      /$$$$$$$$            /$$ /$$                     /$$$$$$$$
  2. //      | $$_____/          |__/| $$                    |_____ $$
  3. //      | $$        /$$$$$$  /$$| $$  /$$$$$$   /$$$$$$      /$$/
  4. //      | $$$$$    |____  $$| $$| $$ /$$__  $$ /$$__  $$    /$$/
  5. //      | $$__/     /$$$$$$$| $$| $$| $$$$$$$$| $$  \__/   /$$/
  6. //      | $$       /$$__  $$| $$| $$| $$_____/| $$        /$$/
  7. //      | $$      |  $$$$$$$| $$| $$|  $$$$$$$| $$       /$$$$$$$$
  8. //      |__/       \_______/|__/|__/ \_______/|__/      |________/
  9.  
  10. /*******************************************************************************
  11. *                     Advance Fish System [AFS] - by FailerZ                   *
  12. *                                  Copyright ©                                *
  13. *******************************************************************************/
  14.  
  15.  
  16. //================================ [Includes] ==================================
  17. #include          <a_samp>             //Credits to Kalcor/Kye
  18. #include          <zcmd>               //Credits to Zeex
  19. #include          <sscanf2>            //Credits to Y_Less
  20. #include          <foreach>            //Credits to Y_Less
  21. #include          <YSI\y_ini>          //Credits to Y_Less
  22. #include          <streamer>           //Credits to Incognito
  23. //================================ [Defines] ===================================
  24. //Settings
  25. #define          FISHERMEN_PATH       "AFS/Fishermen/%s.ini"
  26. #define          FSHOP_PATH           "AFS/Fishshop.txt"
  27.  
  28. #define          MAX_FISH_NC          5             //Max fishes a player can carry WITHOUT COOLER (Fish Amount) [Current: 5 fishes]
  29. #define          MAX_FISH_C           15            //Max fishes a player can carry WITH COOLER (Fish Amount) [Current: 15 fishes]
  30. #define          MIN_FISH             5000          //Minimum fish price on sell (Money Value) [Current: 5,000$]
  31. #define          MAX_FISH             10000         //Maximum fish price on sell (Money Value) [Current: 10,000$]
  32. #define          MAX_MONEYBAG         15000         //When a player catch a Moneybag (Money Value) [Current: 15,000$]
  33. #define          AMMO                 75            //When a player catch a Weapon (Ammo Amount) [Current: 75 ammo]
  34. #define          HP_LOST              15.0          //When a player attacked by a Bird (HP Lost) [Current: 15 HP]
  35. #define          COOLER_PRICE         25000         //Fish Cooler price in fish shop (Money Value) [Current: 25,000$]
  36. #define          ICE_TAX              5000          //Ice tax to pay whenever you sell your fishes to the fish shop (Money Value) [Current: 5,000$]
  37. //Colors
  38. #define          COL_GREY             "{8C8C8C}"
  39. #define          COLOR_GREY           0x8C8C8CFF
  40. #define          COL_WHITE            "{FAFAFA}"
  41. #define          COLOR_WHITE          0xFAFAFAFF
  42. #define          COL_ORANGE           "{FF6E00}"
  43. #define          COLOR_ORANGE         0xFF6E00FF
  44. #define          COL_RED              "{FF0005}"
  45. #define          COLOR_RED            0xFF0005FF
  46. #define          COL_BLUE             "{0087FF}"
  47. #define          COLOR_BLUE           0x0087FFFF
  48. #define          COL_GREEN            "{0FFF00}"
  49. #define          COLOR_GREEN          0x0FFF00FF
  50. #define          COL_PURPLE           "{B400FF}"
  51. #define          COLOR_PURPLE         0xB400FFFF
  52. #define          COL_YELLOW           "{F5FF00}"
  53. #define          COLOR_YELLOW         0xF5FF00FF
  54. #define          COL_BEGE             "{FFA97F}"
  55. #define          COLOR_BEGE           0xFFA97F99
  56. //Dialogs
  57. #define          DIALOG_FHELP         666
  58. #define          DIALOG_AFHELP        655
  59. #define          DIALOG_FINV          677
  60. //Easy Codes
  61. #define          SCM                  SendClientMessage
  62. #define          SCMTA                SendClientMessageToAll
  63. #define          function%0(%1)       forward%0(%1); public%0(%1)
  64. #define          PRESSED(%0)          (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  65. #define          TAG                  "{8C8C8C}[AFS]:{FAFAFA}"
  66. //Others
  67. #define          FILTERSCRIPT
  68. //================================= [Script] ===================================
  69. //Variables & Arrays
  70. new FInv[MAX_PLAYERS], bool:FCooler[MAX_PLAYERS], FTimer[MAX_PLAYERS], FATimer[MAX_PLAYERS], bool:IsFishing[MAX_PLAYERS];
  71. new Text:Progress, Text:Catch[MAX_PLAYERS];
  72. new FishShop, bool:FCreated, Float:FPos[3];
  73. //------------------------------------------------------------------------------
  74. //CallBacks & Functions
  75. public OnFilterScriptInit()
  76. {
  77.     print("----------------------------------------");
  78.     print("| Advance Fish System [AFS] by FailerZ |");
  79.     print("|                Loaded                |");
  80.     print("----------------------------------------");
  81.    
  82.     FishShop = CreateDynamicCP(0, 0, -1000, 3.0);
  83.    
  84.     ResetVarsForAll();
  85.    
  86.     Progress = TextDrawCreate(322.000000, 355.760040, "~g~~h~Fishing ~w~In Progress");
  87.     TextDrawLetterSize(Progress, 0.396000, 1.570133);
  88.     TextDrawAlignment(Progress, 2);
  89.     TextDrawColor(Progress, -1);
  90.     TextDrawSetShadow(Progress, 0);
  91.     TextDrawSetOutline(Progress, 1);
  92.     TextDrawBackgroundColor(Progress, 255);
  93.     TextDrawFont(Progress, 2);
  94.     TextDrawSetProportional(Progress, 1);
  95.     TextDrawSetShadow(Progress, 0);
  96.    
  97.     foreach(Player, i)
  98.     {
  99.         Catch[i] = TextDrawCreate(320.399993, 198.213333, "~w~Caught A ~g~~h~SomeThing");
  100.         TextDrawLetterSize(Catch[i], 0.396000, 1.570133);
  101.         TextDrawAlignment(Catch[i], 2);
  102.         TextDrawColor(Catch[i], -1);
  103.         TextDrawSetShadow(Catch[i], 0);
  104.         TextDrawSetOutline(Catch[i], 1);
  105.         TextDrawBackgroundColor(Catch[i], 255);
  106.         TextDrawFont(Catch[i], 2);
  107.         TextDrawSetProportional(Catch[i], 1);
  108.         TextDrawSetShadow(Catch[i], 0);
  109.        
  110.         if(fexist(FisherPath(i)))
  111.         {
  112.             INI_ParseFile(FisherPath(i), "LoadFisher_%s", .bExtra = true, .extra = i);
  113.         }
  114.         else
  115.         {
  116.             new INI:File = INI_Open(FisherPath(i));
  117.             INI_SetTag(File,"data");
  118.             INI_WriteInt(File,"FInv",0);
  119.             INI_WriteBool(File,"FCooler",false);
  120.         }
  121.     }
  122.    
  123.     new File:handle = fopen(FSHOP_PATH, io_read), line[100], Float:RPos[3];
  124.     if(handle)
  125.     {
  126.         while(fread(handle, line))
  127.         {
  128.             if(!sscanf(line, "p<|>fff", RPos[0], RPos[1], RPos[2]))
  129.             {
  130.                 FPos[0] = RPos[0];
  131.                 FPos[1] = RPos[1];
  132.                 FPos[2] = RPos[2];
  133.                 FCreated = true;
  134.                 FishShop = CreateDynamicCP(RPos[0], RPos[1], RPos[2], 3.0);
  135.                 printf("[File] Loaded fish shop at [%f | %f | %f].", RPos[0], RPos[1], RPos[2]);
  136.             }
  137.             else printf("[File] Unable to read from [%s]", FSHOP_PATH);
  138.         }
  139.     }
  140.     else printf("[File] Unable to open [%s]", FSHOP_PATH);
  141.     return 1;
  142. }
  143. //------------------------------------------------------------------------------
  144. public OnFilterScriptExit()
  145. {
  146.     print("----------------------------------------");
  147.     print("| Advance Fish System [AFS] by FailerZ |");
  148.     print("|               UnLoaded               |");
  149.     print("----------------------------------------");
  150.    
  151.     foreach(Player, i)
  152.     {
  153.         TextDrawDestroy(Catch[i]);
  154.  
  155.         new INI:File = INI_Open(FisherPath(i));
  156.         INI_SetTag(File,"data");
  157.         INI_WriteInt(File, "FInv", FInv[i]);
  158.         INI_WriteBool(File, "FCooler", FCooler[i]);
  159.         INI_Close(File);
  160.     }
  161.    
  162.     ResetVarsForAll();
  163.    
  164.     TextDrawDestroy(Progress);
  165.     return 1;
  166. }
  167. //------------------------------------------------------------------------------
  168. public OnPlayerConnect(playerid)
  169. {
  170.     if(fexist(FisherPath(playerid)))
  171.     {
  172.         INI_ParseFile(FisherPath(playerid), "LoadFisher_%s", .bExtra = true, .extra = playerid);
  173.     }
  174.     else
  175.     {
  176.         new INI:File = INI_Open(FisherPath(playerid));
  177.         INI_SetTag(File,"data");
  178.         INI_WriteInt(File,"FInv",0);
  179.         INI_WriteBool(File,"FCooler",false);
  180.     }
  181.  
  182.     Catch[playerid] = TextDrawCreate(320.399993, 198.213333, "~w~Caught A ~g~~h~SomeThing");
  183.     TextDrawLetterSize(Catch[playerid], 0.396000, 1.570133);
  184.     TextDrawAlignment(Catch[playerid], 2);
  185.     TextDrawColor(Catch[playerid], -1);
  186.     TextDrawSetShadow(Catch[playerid], 0);
  187.     TextDrawSetOutline(Catch[playerid], 1);
  188.     TextDrawBackgroundColor(Catch[playerid], 255);
  189.     TextDrawFont(Catch[playerid], 2);
  190.     TextDrawSetProportional(Catch[playerid], 1);
  191.     TextDrawSetShadow(Catch[playerid], 0);
  192.     return 1;
  193. }
  194. //------------------------------------------------------------------------------
  195. function LoadFisher_data(playerid,name[],value[])
  196. {
  197.     INI_Int("FInv", FInv[playerid]);
  198.     INI_Bool("FCooler", FCooler[playerid]);
  199.     return 1;
  200. }
  201. //------------------------------------------------------------------------------
  202. public OnPlayerDisconnect(playerid, reason)
  203. {
  204.     new INI:File = INI_Open(FisherPath(playerid));
  205.     INI_SetTag(File,"data");
  206.     INI_WriteInt(File, "FInv", FInv[playerid]);
  207.     INI_WriteBool(File, "FCooler", FCooler[playerid]);
  208.     INI_Close(File);
  209.  
  210.     TextDrawDestroy(Catch[playerid]);
  211.     FInv[playerid] = 0;
  212.     IsFishing[playerid] = false;
  213.     KillTimer(FTimer[playerid]);
  214.     KillTimer(FATimer[playerid]);
  215.     FCooler[playerid] = false;
  216.     return 1;
  217. }
  218. //------------------------------------------------------------------------------
  219. public OnPlayerEnterVehicle(playerid, vehicleid)
  220. {
  221.     if(IsVehicleBoat(vehicleid))
  222.     {
  223.         SCM(playerid, -1, ""TAG" You can fish from this boat. "COL_YELLOW"Type "COL_WHITE"/fishhelp | /fhelp "COL_YELLOW"for more information.");
  224.     }
  225.     return 1;
  226. }
  227. //------------------------------------------------------------------------------
  228. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  229. {
  230.     if(PRESSED(KEY_LOOK_BEHIND) && IsPlayerInBoat(playerid))
  231.     {
  232.         new randomtime = randomEx(4000, 8000);
  233.         if(IsFishing[playerid] == true) return SCM(playerid, -1, ""TAG" You are already fishing. "COL_YELLOW"Please wait before fishing again.");
  234.         if(FInv[playerid] >= MAX_FISH_NC && FCooler[playerid] == false) return SCM(playerid, -1, ""TAG" You cannot carry anymore fishes. "COL_YELLOW"Buy a fish cooler or sell your current fishes.");
  235.         if(FInv[playerid] >= MAX_FISH_C && FCooler[playerid] == true) return SCM(playerid, -1, ""TAG" You cannot carry anymore fishes. "COL_YELLOW"Sell your current fishes.");
  236.         FTimer[playerid] = SetTimerEx("Fish", randomtime, false, "i", playerid);
  237.         TextDrawShowForPlayer(playerid, Progress);
  238.         IsFishing[playerid] = true;
  239.     }
  240.     return 1;
  241. }
  242. //------------------------------------------------------------------------------
  243. function Fish(playerid)
  244. {
  245.     new result = random(101);
  246.     TextDrawHideForPlayer(playerid, Progress);
  247.     if(result >= 0 && result <= 50) //Caught A Fish (50%)
  248.     {
  249.         SCM(playerid, -1 , ""TAG" You have caught a fish!");
  250.         TextDrawSetString(Catch[playerid], "~w~Caught A ~g~~h~Fish");
  251.         TextDrawShowForPlayer(playerid, Catch[playerid]);
  252.         FInv[playerid] ++;
  253.     }
  254.    
  255.     if(result > 50 && result <= 75) //Caught Nothing (25%)
  256.     {
  257.         SCM(playerid, -1 , ""TAG" You have failed to catch anything.");
  258.         TextDrawSetString(Catch[playerid], "~w~Caught ~r~Nothing");
  259.         TextDrawShowForPlayer(playerid, Catch[playerid]);
  260.     }
  261.    
  262.     if(result > 75 && result <= 80) //Caught A Moneybag (5%)
  263.     {
  264.         new str[128];
  265.         new rm = random(MAX_MONEYBAG);
  266.         format(str, sizeof(str), ""TAG" You have caught a moneybag and found "COL_YELLOW"%d$ "COL_WHITE"inside of it!", rm);
  267.         SCM(playerid, -1 , str);
  268.         TextDrawSetString(Catch[playerid], "~w~Caught A ~b~~h~Moneybag");
  269.         TextDrawShowForPlayer(playerid, Catch[playerid]);
  270.         GivePlayerMoney(playerid, rm);
  271.     }
  272.    
  273.     if(result > 80 && result <= 90) //Caught A Weapon (10%)
  274.     {
  275.         new rw = random(101);
  276.         if(rw >= 0 && rw <= 40)// (40%)
  277.         {
  278.             SCM(playerid, -1 , ""TAG" You have caught a pistol!");
  279.             TextDrawSetString(Catch[playerid], "~w~Caught A ~y~~h~Weapon");
  280.             TextDrawShowForPlayer(playerid, Catch[playerid]);
  281.             GivePlayerWeapon(playerid, 22, AMMO); //Pistol
  282.         }
  283.        
  284.         if(rw > 40 && rw <= 70)// (30%)
  285.         {
  286.             SCM(playerid, -1 , ""TAG" You have caught a shotgun!");
  287.             TextDrawSetString(Catch[playerid], "~w~Caught A ~y~~h~Weapon");
  288.             TextDrawShowForPlayer(playerid, Catch[playerid]);
  289.             GivePlayerWeapon(playerid, 25, AMMO); //Shotgun
  290.         }
  291.        
  292.         if(rw > 70 && rw <= 90)// (20%)
  293.         {
  294.             SCM(playerid, -1 , ""TAG" You have caught a tec9!");
  295.             TextDrawSetString(Catch[playerid], "~w~Caught A ~y~~h~Weapon");
  296.             TextDrawShowForPlayer(playerid, Catch[playerid]);
  297.             GivePlayerWeapon(playerid, 32, AMMO); //Tec9
  298.         }
  299.        
  300.         if(rw > 90 && rw <= 100)// (10%)
  301.         {
  302.             SCM(playerid, -1 , ""TAG" You have caught a country rifle!");
  303.             TextDrawSetString(Catch[playerid], "~w~Caught A ~y~~h~Weapon");
  304.             TextDrawShowForPlayer(playerid, Catch[playerid]);
  305.             GivePlayerWeapon(playerid, 33, AMMO); //Country Rifle
  306.         }
  307.     }
  308.    
  309.     if(result > 90 && result <= 100) //Bird (10%)
  310.     {
  311.         if(FInv[playerid] <= 0) //Attacked by Bird
  312.         {
  313.             SCM(playerid, -1 , ""TAG" You have been attacked by a bird...");
  314.             TextDrawSetString(Catch[playerid], "~r~Attacked By A ~p~Bird");
  315.             TextDrawShowForPlayer(playerid, Catch[playerid]);
  316.            
  317.             new Float:hp;
  318.             GetPlayerHealth(playerid, hp);
  319.            
  320.             if(hp > HP_LOST)
  321.             {
  322.                 SetPlayerHealth(playerid, hp-HP_LOST);
  323.             }
  324.             else
  325.             {
  326.                 new str[128], fName[MAX_PLAYER_NAME];
  327.                 SetPlayerHealth(playerid, 0);
  328.                 GetPlayerName(playerid, fName, sizeof(fName));
  329.                 format(str, sizeof(str), ""COL_RED"*** Fisherman %s[%d] has been attacked to death by a bird.", fName, playerid);
  330.                 SCMTA(-1, str);
  331.             }
  332.         }
  333.         else //Fish Eaten by Bird
  334.         {
  335.             SCM(playerid, -1 , ""TAG" One of your fishes has been eaten by a bird...");
  336.             TextDrawSetString(Catch[playerid], "~r~Fish Eaten By A ~p~Bird");
  337.             TextDrawShowForPlayer(playerid, Catch[playerid]);
  338.             FInv[playerid] --;
  339.         }
  340.     }
  341.     FATimer[playerid] = SetTimerEx("FishAgain", 2500, false, "i", playerid);
  342.     return 1;
  343. }
  344. //------------------------------------------------------------------------------
  345. function FishAgain(playerid)
  346. {
  347.     TextDrawHideForPlayer(playerid, Catch[playerid]);
  348.     IsFishing[playerid] = false;
  349.     return 1;
  350. }
  351. //------------------------------------------------------------------------------
  352. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  353. {
  354.     if(checkpointid == FishShop && playerid != INVALID_PLAYER_ID && !IsPlayerInAnyVehicle(playerid))
  355.     {
  356.         SCM(playerid, -1, ""TAG" Welcome to Fish Shop. "COL_YELLOW"Check "COL_WHITE"/fishhelp | /fhelp "COL_YELLOW"for commands.");
  357.     }
  358.     return 1;
  359. }
  360. //================================= [Commands] =================================
  361. //Player Commands
  362. //------------------------------------------------------------------------------
  363. CMD:fishhelp(playerid)
  364. {
  365.     new string[1200];
  366.     strcat(string, ""COL_BEGE"Type "COL_WHITE"/fish "COL_BEGE"or Press "COL_WHITE"Number 2 "COL_BEGE"-> Inside a boat to start fishing.\n");
  367.     strcat(string, ""COL_BEGE"Type "COL_WHITE"/fishinventory | /finv "COL_BEGE"-> To open your fish inventory.\n");
  368.     strcat(string, ""COL_BEGE"Type "COL_WHITE"/fishdrop | /fdrop "COL_BEGE"-> To drop one of your fishes.\n");
  369.     strcat(string, ""COL_BEGE"Type "COL_WHITE"/fishdropall | /fdropall "COL_BEGE"-> To drop all of your fishes.\n");
  370.     strcat(string, ""COL_BEGE"Type "COL_WHITE"/fishsellall | /fsellall "COL_BEGE"-> Inside a fish shop to sell all of your fishes.\n");
  371.     strcat(string, ""COL_BEGE"Type "COL_WHITE"/buycooler "COL_BEGE"-> Inside a fish shop to buy a fish cooler.\n");
  372.     strcat(string, ""COL_BEGE"Type "COL_WHITE"/discardcooler | /dcooler "COL_BEGE"-> To discard your cooler "COL_RED"(Warning: You will lose all of the fishes in the cooler 'if you have').\n");
  373.     ShowPlayerDialog(playerid, DIALOG_FHELP, DIALOG_STYLE_MSGBOX, ""COL_GREY"Fish Help", string, "X", "");
  374.     return 1;
  375. }
  376.  
  377. CMD:fhelp(playerid)
  378. {
  379.     return cmd_fishhelp(playerid);
  380. }
  381. //------------------------------------------------------------------------------
  382. CMD:fish(playerid)
  383. {
  384.     if(IsPlayerInBoat(playerid))
  385.     {
  386.         new randomtime = randomEx(4000, 8000);
  387.         if(IsFishing[playerid] == true) return SCM(playerid, -1, ""TAG" You are already fishing. "COL_YELLOW"Please wait before fishing again.");
  388.         if(FInv[playerid] >= MAX_FISH_NC && FCooler[playerid] == false) return SCM(playerid, -1, ""TAG" You cannot carry anymore fishes. "COL_YELLOW"Buy a fish cooler or sell your current fishes.");
  389.         if(FInv[playerid] >= MAX_FISH_C && FCooler[playerid] == true) return SCM(playerid, -1, ""TAG" You cannot carry anymore fishes. "COL_YELLOW"Sell your current fishes.");
  390.         FTimer[playerid] = SetTimerEx("Fish", randomtime, false, "i", playerid);
  391.         TextDrawShowForPlayer(playerid, Progress);
  392.         IsFishing[playerid] = true;
  393.     }
  394.     else return SCM(playerid, -1, ""TAG" You must be in a boat to fish.");
  395.     return 1;
  396. }
  397. //------------------------------------------------------------------------------
  398. CMD:fishinventory(playerid)
  399. {
  400.     new string[100];
  401.     if(FCooler[playerid] == false)
  402.     {
  403.         format(string, sizeof(string), ""COL_BEGE"Fishes: "COL_WHITE"%d/%d\n"COL_BEGE"Fish Cooler: "COL_RED"NO", FInv[playerid], MAX_FISH_NC);
  404.     }
  405.     if(FCooler[playerid] == true)
  406.     {
  407.         format(string, sizeof(string), ""COL_BEGE"Fishes: "COL_WHITE"%d/%d\n"COL_BEGE"Fish Cooler: "COL_GREEN"YES", FInv[playerid], MAX_FISH_C);
  408.     }
  409.     return ShowPlayerDialog(playerid, DIALOG_FINV, DIALOG_STYLE_MSGBOX, ""COL_GREY"Fish Inventory", string, "X", "");
  410. }
  411.  
  412. CMD:finv(playerid)
  413. {
  414.     return cmd_fishinventory(playerid);
  415. }
  416. //------------------------------------------------------------------------------
  417. CMD:fishdrop(playerid)
  418. {
  419.     if(FInv[playerid] > 0)
  420.     {
  421.         FInv[playerid] --;
  422.         SCM(playerid, -1, ""TAG" You have dropped a fish into the water.");
  423.     }
  424.     else return SCM(playerid, -1, ""TAG" You don't own any fishes. "COL_YELLOW"Use /fish to start fishing from a boat.");
  425.     return 1;
  426. }
  427.  
  428. CMD:fdrop(playerid)
  429. {
  430.     return cmd_fishdrop(playerid);
  431. }
  432. //------------------------------------------------------------------------------
  433. CMD:fishdropall(playerid)
  434. {
  435.     if(FInv[playerid] > 0)
  436.     {
  437.         FInv[playerid] = 0;
  438.         SCM(playerid, -1, ""TAG" You have dropped all your fishes into the water.");
  439.     }
  440.     else return SCM(playerid, -1, ""TAG" You don't own any fishes. "COL_YELLOW"Use /fish to start fishing from a boat.");
  441.     return 1;
  442. }
  443.  
  444. CMD:fdropall(playerid)
  445. {
  446.     return cmd_fishdropall(playerid);
  447. }
  448. //------------------------------------------------------------------------------
  449. CMD:fishsellall(playerid)
  450. {
  451.     if(!IsPlayerInDynamicCP(playerid, FishShop)) return SCM(playerid, -1, ""TAG" You cannot sell your fishes here. "COL_YELLOW"You must be in the fish shop.");
  452.     if(IsPlayerInAnyVehicle(playerid)) return SCM(playerid, -1, ""TAG" You must be on foot to sell your fishes.");
  453.     if(FInv[playerid] <= 0) return SCM(playerid, -1, ""TAG" You don't have any fish to sell. "COL_YELLOW"Type /fish to start fishing from a boat.");
  454.    
  455.     new randsell = randomEx(MIN_FISH, MAX_FISH);
  456.     GivePlayerMoney(playerid, randsell*FInv[playerid]);
  457.    
  458.     new cstr[100], sstr[128];
  459.     new TCash = randsell*FInv[playerid];
  460.     format(cstr, sizeof(cstr), "~w~Sold ~y~~h~%d Fishes ~w~for ~g~%d$", FInv[playerid], TCash);
  461.     format(sstr, sizeof(sstr), ""TAG" Sold "COL_YELLOW"%d "COL_WHITE"fishes for "COL_YELLOW"%d$"COL_WHITE". The shop has paid "COL_YELLOW"%d%$ "COL_WHITE"each.", FInv[playerid], TCash, randsell);
  462.     GameTextForPlayer(playerid, cstr, 4000, 3);
  463.     SCM(playerid, -1, sstr);
  464.    
  465.     FInv[playerid] = 0;
  466.    
  467.     if(FCooler[playerid] == true)
  468.     {
  469.         GivePlayerMoney(playerid, -ICE_TAX);
  470.         SCM(playerid, -1, ""TAG" You have paid "COL_YELLOW"5000$ "COL_WHITE"for the fish cooler ice.");
  471.     }
  472.     return 1;
  473. }
  474.  
  475. CMD:fsellall(playerid)
  476. {
  477.     return cmd_fishsellall(playerid);
  478. }
  479. //------------------------------------------------------------------------------
  480. CMD:buycooler(playerid)
  481. {
  482.     if(!IsPlayerInDynamicCP(playerid, FishShop)) return SCM(playerid, -1, ""TAG" You cannot buy a fish cooler here. "COL_YELLOW"You must be in the fish shop.");
  483.     if(IsPlayerInAnyVehicle(playerid)) return SCM(playerid, -1, ""TAG" You must be on foot to buy a fish cooler.");
  484.     if(FCooler[playerid] == true) return SCM(playerid, -1, ""TAG" You already have a fish cooler.");
  485.     if(GetPlayerMoney(playerid) < COOLER_PRICE) return SCM(playerid, -1, ""TAG" You don't have "COL_YELLOW"25000$ "COL_WHITE"to buy a fish cooler");
  486.     GivePlayerMoney(playerid, -COOLER_PRICE);
  487.     FCooler[playerid] = true;
  488.     GameTextForPlayer(playerid, "~w~Bought A ~g~Fish Cooler", 4000, 3);
  489.     SCM(playerid, -1, ""TAG" You have bought a fish cooler for "COL_YELLOW"25000$"COL_WHITE".");
  490.     return 1;
  491. }
  492. //------------------------------------------------------------------------------
  493. CMD:discardcooler(playerid)
  494. {
  495.     new str[128];
  496.     if(FCooler[playerid] == false) return SCM(playerid, -1, ""TAG" You don't have a fish cooler. "COL_YELLOW"Use "COL_WHITE"/buycooler "COL_YELLOW"to buy a one.");
  497.     if(FInv[playerid] > MAX_FISH_NC)
  498.     {
  499.         new flost = FInv[playerid] -= 5;
  500.         format(str, sizeof(str), ""TAG" You have discarded your fish cooler and lost "COL_YELLOW"%d "COL_WHITE"fishes along with it.", flost);
  501.         FInv[playerid] = MAX_FISH_NC;
  502.     }
  503.     else
  504.     {
  505.         format(str, sizeof(str), ""TAG" You have discarded your fish cooler.");
  506.     }
  507.     FCooler[playerid] = false;
  508.    
  509.     SCM(playerid, -1, str);
  510.     return 1;
  511. }
  512.  
  513. CMD:dcooler(playerid)
  514. {
  515.     return cmd_discardcooler(playerid);
  516. }
  517. //------------------------------------------------------------------------------
  518. //Admin Commands
  519. //------------------------------------------------------------------------------
  520. CMD:afishhelp(playerid)
  521. {
  522.     if(!IsPlayerAdmin(playerid)) return SCM(playerid, -1, ""TAG" Only rcon admins able to see admin fish help.");
  523.     new string[1000];
  524.     strcat(string, ""COL_BEGE"Type "COL_WHITE"/createfishshop | /cfshop "COL_BEGE"-> To create a fish shop.\n");
  525.     strcat(string, ""COL_BEGE"Type "COL_WHITE"/destroyfishshop | /dfshop "COL_BEGE"-> To destroy a fish shop.\n");
  526.     strcat(string, ""COL_BEGE"Type "COL_WHITE"/gotofishshop | /gfshop "COL_BEGE"-> To teleport to fish shop.\n");
  527.     ShowPlayerDialog(playerid, DIALOG_AFHELP, DIALOG_STYLE_MSGBOX, ""COL_GREY"Admin Fish Help", string, "X", "");
  528.     return 1;
  529. }
  530.  
  531. CMD:afhelp(playerid)
  532. {
  533.     return cmd_afishhelp(playerid);
  534. }
  535. //------------------------------------------------------------------------------
  536. CMD:createfishshop(playerid)
  537. {
  538.     new Float:Pos[3], str[128];
  539.     if(!IsPlayerAdmin(playerid)) return SCM(playerid, -1, ""TAG" Only rcon admins able to create fish shop.");
  540.     if(IsPlayerInAnyVehicle(playerid)) return SCM(playerid, -1, ""TAG" You must be on foot to create a fish shop.");
  541.     if(FCreated == true) return SCM(playerid, -1, ""TAG" Fish shop already created.");
  542.     GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  543.     FishShop = CreateDynamicCP(Pos[0], Pos[1], Pos[2], 3.0);
  544.     FCreated = true;
  545.     FPos[0] = Pos[0];
  546.     FPos[1] = Pos[1];
  547.     FPos[2] = Pos[2];
  548.     format(str, sizeof(str), ""TAG" Fish shop created! "COL_YELLOW"[Location = 'scriptfiles/%s']", FSHOP_PATH);
  549.     SCM(playerid, -1, str);
  550.    
  551.     new File:handle = fopen(FSHOP_PATH, io_write), filestr[250];
  552.     if(handle)
  553.     {
  554.         format(filestr, sizeof(filestr), "%f|%f|%f", FPos[0], FPos[1], FPos[2]);
  555.         fwrite(handle, filestr);
  556.         fclose(handle);
  557.     }
  558.     return 1;
  559. }
  560.  
  561. CMD:cfshop(playerid)
  562. {
  563.     return cmd_createfishshop(playerid);
  564. }
  565. //------------------------------------------------------------------------------
  566. CMD:destroyfishshop(playerid)
  567. {
  568.     if(!IsPlayerAdmin(playerid)) return SCM(playerid, -1, ""TAG" Only rcon admins able to destroy fish shop.");
  569.     if(!FishShop) return SCM(playerid, -1, ""TAG" Fish shop already destroyed.");
  570.     if(FCreated == false) return SCM(playerid, -1, ""TAG" No fish shop has been created yet. "COL_YELLOW"Type "COL_WHITE"/createfishshop | /cfshop "COL_YELLOW"to create a one.");
  571.     DestroyDynamicCP(FishShop);
  572.     FCreated = false;
  573.     SCM(playerid, -1, ""TAG" Fish shop destroyed!");
  574.    
  575.     new File:handle = fopen(FSHOP_PATH, io_write);
  576.     if(handle)
  577.     {
  578.         fwrite(handle, "");
  579.         fclose(handle);
  580.     }
  581.     return 1;
  582. }
  583.  
  584. CMD:dfshop(playerid)
  585. {
  586.     return cmd_destroyfishshop(playerid);
  587. }
  588. //------------------------------------------------------------------------------
  589. CMD:gotofishshop(playerid)
  590. {
  591.     new str[128];
  592.     if(!IsPlayerAdmin(playerid)) return SCM(playerid, -1, ""TAG" Only rcon admins able to go to fish shop.");
  593.     if(IsPlayerInAnyVehicle(playerid)) return SCM(playerid, -1, ""TAG" You must be on foot to go to fish shop.");
  594.     if(FCreated == false) return SCM(playerid, -1, ""TAG" No fish shop has been created yet. "COL_YELLOW"Type "COL_WHITE"/createfishshop | /cfshop "COL_YELLOW"to create a one.");
  595.     SetPlayerPos(playerid, FPos[0], FPos[1], FPos[2]);
  596.     format(str, sizeof(str), ""TAG" Teleported to fish shop! "COL_YELLOW"[PosX: %f | PosY:%f | PosY:%f]", FPos[0], FPos[1], FPos[2]);
  597.     SCM(playerid, -1, str);
  598.     return 1;
  599. }
  600.  
  601. CMD:gfshop(playerid)
  602. {
  603.     return cmd_gotofishshop(playerid);
  604. }
  605. //------------------------------------------------------------------------------
  606. /*CMD:givemefish(playerid) //>> Test Command <<
  607. {
  608.     if(!IsPlayerAdmin(playerid)) return SCM(playerid, -1, ""TAG" Only rcon admins able to give a fish.");
  609.     SCM(playerid, -1, ""TAG" FISH FTW");
  610.     FInv[playerid] ++;
  611.     return 1;
  612. }*/
  613. //================================= [Stocks] ===================================
  614. stock IsPlayerInBoat(playerid)
  615. {
  616.     if(IsPlayerConnected(playerid) && IsPlayerInAnyVehicle(playerid))
  617.     {
  618.         new vID = GetPlayerVehicleID(playerid);
  619.         new vModel = GetVehicleModel(vID);
  620.         if(vModel == 472 || vModel == 473 || vModel == 493 || vModel == 595 || vModel == 484 || vModel == 430 || vModel == 453 || vModel == 452 || vModel == 446 || vModel == 454)
  621.         {
  622.             return 1;
  623.         }
  624.     }
  625.     return 0;
  626. }
  627. //------------------------------------------------------------------------------
  628. stock IsVehicleBoat(vehicleid)
  629. {
  630.     new vModel = GetVehicleModel(vehicleid);
  631.     if(vModel == 472 || vModel == 473 || vModel == 493 || vModel == 595 || vModel == 484 || vModel == 430 || vModel == 453 || vModel == 452 || vModel == 446 || vModel == 454)
  632.     {
  633.         return 1;
  634.     }
  635.     return 0;
  636. }
  637. //------------------------------------------------------------------------------
  638. stock ResetVarsForAll()
  639. {
  640.     foreach(Player, i)
  641.     {
  642.         FInv[i] = 0;
  643.         IsFishing[i] = false;
  644.         KillTimer(FTimer[i]);
  645.         KillTimer(FATimer[i]);
  646.         TextDrawHideForPlayer(i, Catch[i]);
  647.         FCooler[i] = false;
  648.     }
  649.     FCreated = false;
  650.     FPos[0] = 0.0;
  651.     FPos[1] = 0.0;
  652.     FPos[2] = 0.0;
  653.     TextDrawHideForAll(Progress);
  654.     return 1;
  655. }
  656. //------------------------------------------------------------------------------
  657. /* ** Credits to Y_Less ** */
  658. stock randomEx(min, max)
  659. {
  660.     new rand = random(max-min)+min;
  661.     return rand;
  662. }
  663. //------------------------------------------------------------------------------
  664. stock FisherPath(playerid)
  665. {
  666.     new string[128],playername[MAX_PLAYER_NAME];
  667.     GetPlayerName(playerid,playername,sizeof(playername));
  668.     format(string,sizeof(string),FISHERMEN_PATH,playername);
  669.     return string;
  670. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement