Advertisement
Guest User

Untitled

a guest
Feb 24th, 2019
2,082
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.35 KB | None | 0 0
  1.  
  2. print("Advanced fishing started successfully")
  3. print("Advanced Fishing developed by Kuzaky | Discord: Kuzkay#9999")
  4.  
  5. ESX = nil
  6. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  7.  
  8.  
  9. ESX.RegisterUsableItem('turtlebait', function(source)
  10.  
  11.     local _source = source
  12.     xPlayer = ESX.GetPlayerFromId(_source)
  13.     if xPlayer.getInventoryItem('fishingrod').count > 0 then
  14.         TriggerClientEvent('fishing:setbait', _source, "turtle")
  15.        
  16.         xPlayer.removeInventoryItem('turtlebait', 1)
  17.         TriggerClientEvent('fishing:message', _source, "~g~You attach the turtle bait onto your fishing rod")
  18.     else
  19.         TriggerClientEvent('fishing:message', _source, "~r~You dont have a fishing rod")
  20.     end
  21.    
  22. end)
  23.  
  24. ESX.RegisterUsableItem('fishbait', function(source)
  25.  
  26.     local _source = source
  27.     xPlayer = ESX.GetPlayerFromId(_source)
  28.     if xPlayer.getInventoryItem('fishingrod').count > 0 then
  29.         TriggerClientEvent('fishing:setbait', _source, "fish")
  30.        
  31.         xPlayer.removeInventoryItem('fishbait', 1)
  32.         TriggerClientEvent('fishing:message', _source, "~g~You attach the fish bait onto your fishing rod")
  33.        
  34.     else
  35.         TriggerClientEvent('fishing:message', _source, "~r~You dont have a fishing rod")
  36.     end
  37.    
  38. end)
  39.  
  40. ESX.RegisterUsableItem('turtle', function(source)
  41.  
  42.     local _source = source
  43.     xPlayer = ESX.GetPlayerFromId(_source)
  44.     if xPlayer.getInventoryItem('fishingrod').count > 0 then
  45.         TriggerClientEvent('fishing:setbait', _source, "shark")
  46.        
  47.         xPlayer.removeInventoryItem('turtle', 1)
  48.         TriggerClientEvent('fishing:message', _source, "~g~You attach the turtle meat onto the fishing rod")
  49.     else
  50.         TriggerClientEvent('fishing:message', _source, "~r~You dont have a fishing rod")
  51.     end
  52.    
  53. end)
  54.  
  55. ESX.RegisterUsableItem('fishingrod', function(source)
  56.  
  57.     local _source = source
  58.     TriggerClientEvent('fishing:fishstart', _source)
  59.    
  60.    
  61.  
  62. end)
  63.  
  64.  
  65.                
  66. RegisterNetEvent('fishing:catch')
  67. AddEventHandler('fishing:catch', function(bait)
  68.    
  69.     _source = source
  70.     local weight = 2
  71.     local rnd = math.random(1,100)
  72.     xPlayer = ESX.GetPlayerFromId(_source)
  73.     if bait == "turtle" then
  74.         if rnd >= 78 then
  75.             if rnd >= 94 then
  76.                 TriggerClientEvent('fishing:setbait', _source, "none")
  77.                 TriggerClientEvent('fishing:message', _source, "~r~It was huge and it broke your fishing rod!")
  78.                 TriggerClientEvent('fishing:break', _source)
  79.                 xPlayer.removeInventoryItem('fishingrod', 1)
  80.             else
  81.                 TriggerClientEvent('fishing:setbait', _source, "none")
  82.                 if xPlayer.getInventoryItem('turtle').count > 4 then
  83.                     TriggerClientEvent('fishing:message', _source, "~r~You cant hold more turtles")
  84.                 else
  85.                     TriggerClientEvent('fishing:message', _source, "~g~You caught a turtle\n~r~These are endangered species and are illegal to posses")
  86.                     xPlayer.addInventoryItem('turtle', 1)
  87.                 end
  88.             end
  89.         else
  90.             if rnd >= 75 then
  91.                 if xPlayer.getInventoryItem('fish').count > 100 then
  92.                     TriggerClientEvent('fishing:message', _source, "~r~You cant hold more fish")
  93.                 else
  94.                     weight = math.random(4,9)
  95.                     TriggerClientEvent('fishing:message', _source, "~g~You caught a fish: ~y~~h~" .. weight .. "kg")
  96.                     xPlayer.addInventoryItem('fish', weight)
  97.                 end
  98.                
  99.             else
  100.                 if xPlayer.getInventoryItem('fish').count > 100 then
  101.                     TriggerClientEvent('fishing:message', _source, "~r~You cant hold more fish")
  102.                 else
  103.                     weight = math.random(2,6)
  104.                     TriggerClientEvent('fishing:message', _source, "~g~You caught a fish: ~y~~h~" .. weight .. "kg")
  105.                     xPlayer.addInventoryItem('fish', weight)
  106.                 end
  107.             end
  108.         end
  109.     else
  110.         if bait == "fish" then
  111.             if rnd >= 75 then
  112.                 TriggerClientEvent('fishing:setbait', _source, "none")
  113.                 if xPlayer.getInventoryItem('fish').count > 100 then
  114.                     TriggerClientEvent('fishing:message', _source, "~r~You cant hold more fish")
  115.                 else
  116.                     weight = math.random(4,11)
  117.                     TriggerClientEvent('fishing:message', _source, "~g~You caught a fish: ~y~~h~" .. weight .. "kg")
  118.                     xPlayer.addInventoryItem('fish', weight)
  119.                 end
  120.                
  121.             else
  122.                 if xPlayer.getInventoryItem('fish').count > 100 then
  123.                     TriggerClientEvent('fishing:message', _source, "~r~You cant hold more fish")
  124.                 else
  125.                     weight = math.random(1,6)
  126.                     TriggerClientEvent('fishing:message', _source, "~g~You caught a fish: ~y~~h~" .. weight .. "kg")
  127.                     xPlayer.addInventoryItem('fish', weight)
  128.                 end
  129.             end
  130.         end
  131.         if bait == "none" then
  132.            
  133.             if rnd >= 70 then
  134.             TriggerClientEvent('fishing:message', _source, "~y~You are currently fishing without any equipped bait")
  135.                 if xPlayer.getInventoryItem('fish').count > 100 then
  136.                         TriggerClientEvent('fishing:message', _source, "~r~You cant hold more fish")
  137.                     else
  138.                         weight = math.random(2,4)
  139.                         TriggerClientEvent('fishing:message', _source, "~g~You caught a fish: ~y~~h~" .. weight .. "kg")
  140.                         xPlayer.addInventoryItem('fish', weight)
  141.                     end
  142.                    
  143.                 else
  144.                 TriggerClientEvent('fishing:message', _source, "~y~You are currently fishing without any equipped bait")
  145.                     if xPlayer.getInventoryItem('fish').count > 100 then
  146.                         TriggerClientEvent('fishing:message', _source, "~r~You cant hold more fish")
  147.                     else
  148.                         weight = math.random(1,2)
  149.                         TriggerClientEvent('fishing:message', _source, "~g~You caught a fish: ~y~~h~" .. weight .. "kg")
  150.                         xPlayer.addInventoryItem('fish', weight)
  151.                     end
  152.                 end
  153.         end
  154.         if bait == "shark" then
  155.             if rnd >= 82 then
  156.            
  157.                         if rnd >= 91 then
  158.                             TriggerClientEvent('fishing:setbait', _source, "none")
  159.                             TriggerClientEvent('fishing:message', _source, "~r~It was huge and it broke your fishing rod!")
  160.                             TriggerClientEvent('fishing:break', _source)
  161.                             xPlayer.removeInventoryItem('fishingrod', 1)
  162.                         else
  163.                             if xPlayer.getInventoryItem('shark').count > 0  then
  164.                                     TriggerClientEvent('fishing:setbait', _source, "none")
  165.                                     TriggerClientEvent('fishing:message', _source, "~r~You cant hold more sharks")
  166.                             else
  167.                                     TriggerClientEvent('fishing:message', _source, "~g~You caught a shark!\n~r~These are endangered species and are illegal to posses")
  168.                                     TriggerClientEvent('fishing:spawnPed', _source)
  169.                                     xPlayer.addInventoryItem('shark', 1)
  170.                             end
  171.                         end
  172.                             else
  173.                                     if xPlayer.getInventoryItem('fish').count > 100 then
  174.                                         TriggerClientEvent('fishing:message', _source, "~r~You cant hold more fish")
  175.                                     else
  176.                                         weight = math.random(4,8)
  177.                                         TriggerClientEvent('fishing:message', _source, "~g~You caught a fish: ~y~~h~" .. weight .. "kg")
  178.                                         xPlayer.addInventoryItem('fish', weight)
  179.                                     end
  180.                                
  181.                             end
  182.             end
  183.            
  184.         end
  185.    
  186.    
  187. end)
  188.  
  189. RegisterServerEvent("fishing:lowmoney")
  190. AddEventHandler("fishing:lowmoney", function(money)
  191.     local _source = source 
  192.     local xPlayer = ESX.GetPlayerFromId(_source)
  193.     xPlayer.removeMoney(money)
  194. end)
  195.  
  196. RegisterServerEvent('fishing:startSelling')
  197. AddEventHandler('fishing:startSelling', function(item)
  198.  
  199.     local _source = source
  200.    
  201.     local xPlayer  = ESX.GetPlayerFromId(_source)
  202.             if item == "fish" then
  203.                     local FishQuantity = xPlayer.getInventoryItem('fish').count
  204.                         if FishQuantity <= 4 then
  205.                         TriggerClientEvent('esx:showNotification', source, '~r~You dont have enough~s~ fish')          
  206.                     else  
  207.                         xPlayer.removeInventoryItem('fish', 5)
  208.                         local payment = Config.FishPrice.a
  209.                         payment = math.random(Config.FishPrice.a, Config.FishPrice.b)
  210.                         xPlayer.addMoney(payment)
  211.                        
  212.                        
  213.             end
  214.                
  215.  
  216.                
  217.  
  218.                
  219.             end
  220.             if item == "turtle" then
  221.                 local FishQuantity = xPlayer.getInventoryItem('turtle').count
  222.  
  223.                 if FishQuantity <= 0 then
  224.                     TriggerClientEvent('esx:showNotification', source, '~r~You dont have enough~s~ turtles')           
  225.                 else  
  226.                     xPlayer.removeInventoryItem('turtle', 1)
  227.                     local payment = Config.TurtlePrice.a
  228.                     payment = math.random(Config.TurtlePrice.a, Config.TurtlePrice.b)
  229.                     xPlayer.addAccountMoney('black_money', payment)
  230.                    
  231.                    
  232.                 end
  233.             end
  234.             if item == "shark" then
  235.                 local FishQuantity = xPlayer.getInventoryItem('shark').count
  236.  
  237.                 if FishQuantity <= 0 then
  238.                     TriggerClientEvent('esx:showNotification', source, '~r~You dont have enough~s~ sharks')        
  239.                 else  
  240.                     xPlayer.removeInventoryItem('shark', 1)
  241.                     local payment = Config.SharkPrice.a
  242.                     payment = math.random(Config.SharkPrice.a, Config.SharkPrice.b)
  243.                     xPlayer.addAccountMoney('black_money', payment)
  244.                    
  245.                    
  246.                 end
  247.             end
  248.            
  249.    
  250. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement