ed
This commit is contained in:
parent
30c73f0bfb
commit
75db08b9a1
3 changed files with 204 additions and 238 deletions
|
|
@ -6,7 +6,7 @@ local fishing = false
|
|||
if Config.sellShop.enabled then
|
||||
CreateThread(function()
|
||||
local ped, textUI
|
||||
--CreateBlip(Config.sellShop.coords, 356, 1, Strings.sell_shop_blip, 0.80)
|
||||
CreateBlip(Config.sellShop.coords, 356, 1, Strings.sell_shop_blip, 0.80)
|
||||
local point = lib.points.new({
|
||||
coords = Config.sellShop.coords,
|
||||
distance = 30
|
||||
|
|
@ -51,9 +51,8 @@ if Config.sellShop.enabled then
|
|||
end)
|
||||
end
|
||||
|
||||
-- Function to select bait from available options
|
||||
-- Function to select bait from available options
|
||||
local function SelectBait()
|
||||
-- Function to check for available baits and select the best one
|
||||
local function GetBestAvailableBait()
|
||||
local availableBaits = {}
|
||||
|
||||
-- Check all bait types
|
||||
|
|
@ -68,31 +67,15 @@ local function SelectBait()
|
|||
return nil
|
||||
end
|
||||
|
||||
-- If only one bait type is available, use it directly
|
||||
if #availableBaits == 1 then
|
||||
return availableBaits[1]
|
||||
end
|
||||
|
||||
-- Create a notification about available baits
|
||||
local baitNames = ""
|
||||
for i, bait in ipairs(availableBaits) do
|
||||
if i > 1 then baitNames = baitNames .. ", " end
|
||||
baitNames = baitNames .. bait.label
|
||||
end
|
||||
|
||||
TriggerEvent('wasabi_fishing:notify', 'Available Baits', 'You have: ' .. baitNames, 'inform')
|
||||
|
||||
-- Just use the best bait available (highest catch bonus)
|
||||
-- Sort baits by catch bonus (highest first)
|
||||
table.sort(availableBaits, function(a, b)
|
||||
return a.catchBonus > b.catchBonus
|
||||
return (a.catchBonus or 0) > (b.catchBonus or 0)
|
||||
end)
|
||||
|
||||
TriggerEvent('wasabi_fishing:notify', 'Selected Bait', 'Using ' .. availableBaits[1].label .. ' (best available)', 'inform')
|
||||
-- Return the best bait
|
||||
return availableBaits[1]
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Function to handle the fishing process
|
||||
local function StartFishingProcess(selectedBait, waterLoc)
|
||||
fishing = true
|
||||
|
|
@ -154,16 +137,14 @@ local function StartFishingProcess(selectedBait, waterLoc)
|
|||
TriggerServerEvent('wasabi_fishing:loseBait', selectedBait.itemName)
|
||||
TriggerEvent('wasabi_fishing:notify', Strings.bait_lost, Strings.bait_lost_desc, 'error')
|
||||
|
||||
-- Check if we still have bait
|
||||
-- Check if we still have this bait
|
||||
local hasBait = lib.callback.await('wasabi_fishing:checkItem', 100, selectedBait.itemName)
|
||||
if not hasBait then
|
||||
TriggerEvent('wasabi_fishing:notify', Strings.no_more_bait, Strings.no_more_bait_desc, 'error')
|
||||
|
||||
-- Try to select a new bait
|
||||
local newBait = SelectBait()
|
||||
-- Try to get a new bait
|
||||
local newBait = GetBestAvailableBait()
|
||||
if newBait then
|
||||
selectedBait = newBait
|
||||
TriggerEvent('wasabi_fishing:notify', Strings.new_bait, string.format(Strings.new_bait_desc, selectedBait.label), 'inform')
|
||||
TriggerEvent('wasabi_fishing:notify', 'New Bait', 'Using ' .. selectedBait.label .. ' as bait', 'inform')
|
||||
else
|
||||
TriggerEvent('wasabi_fishing:notify', Strings.no_bait, Strings.no_bait_desc, 'error')
|
||||
fishing = false
|
||||
|
|
@ -186,11 +167,11 @@ local function StartFishingProcess(selectedBait, waterLoc)
|
|||
elseif IsControlJustReleased(0, 194) then
|
||||
-- Cancel fishing with backspace
|
||||
ClearPedTasks(cache.ped)
|
||||
TriggerEvent('wasabi_fishing:notify', Strings.fishing_canceled, Strings.fishing_canceled_desc, 'inform')
|
||||
TriggerEvent('wasabi_fishing:notify', 'Fishing Canceled', 'You stopped fishing', 'inform')
|
||||
break
|
||||
elseif #(GetEntityCoords(cache.ped) - waterLoc) > 30 then
|
||||
-- Too far from water
|
||||
TriggerEvent('wasabi_fishing:notify', Strings.too_far, Strings.too_far_desc, 'error')
|
||||
TriggerEvent('wasabi_fishing:notify', 'Too Far', 'You moved too far from the water', 'error')
|
||||
break
|
||||
end
|
||||
end
|
||||
|
|
@ -211,7 +192,7 @@ RegisterNetEvent('wasabi_fishing:startFishing', function()
|
|||
|
||||
-- Check if already fishing
|
||||
if fishing then
|
||||
TriggerEvent('wasabi_fishing:notify', Strings.already_fishing, Strings.already_fishing_desc, 'error')
|
||||
TriggerEvent('wasabi_fishing:notify', 'Already Fishing', 'You are already fishing', 'error')
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -223,14 +204,14 @@ RegisterNetEvent('wasabi_fishing:startFishing', function()
|
|||
end
|
||||
|
||||
-- Select bait
|
||||
local selectedBait = SelectBait()
|
||||
local selectedBait = GetBestAvailableBait()
|
||||
if not selectedBait then
|
||||
TriggerEvent('wasabi_fishing:notify', Strings.no_bait, Strings.no_bait_desc, 'error')
|
||||
return
|
||||
end
|
||||
|
||||
-- Start fishing process
|
||||
TriggerEvent('wasabi_fishing:notify', Strings.bait_selected, string.format(Strings.bait_selected_desc, selectedBait.label), 'inform')
|
||||
TriggerEvent('wasabi_fishing:notify', 'Bait Selected', 'Using ' .. selectedBait.label .. ' as bait', 'inform')
|
||||
StartFishingProcess(selectedBait, waterLoc)
|
||||
end)
|
||||
|
||||
|
|
@ -239,27 +220,12 @@ RegisterNetEvent('wasabi_fishing:processFish', function(fishItem)
|
|||
-- Check if player has knife
|
||||
local hasKnife = lib.callback.await('wasabi_fishing:checkItem', 100, Config.processing.knifeItem)
|
||||
if not hasKnife then
|
||||
TriggerEvent('wasabi_fishing:notify', Strings.no_knife, Strings.no_knife_desc, 'error')
|
||||
return
|
||||
end
|
||||
|
||||
-- Find processing data for this fish
|
||||
local processData = nil
|
||||
for _, data in pairs(Config.processing.products) do
|
||||
if data.sourceItem == fishItem then
|
||||
processData = data
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not processData then
|
||||
TriggerEvent('wasabi_fishing:notify', Strings.cannot_process, Strings.cannot_process_desc, 'error')
|
||||
TriggerEvent('wasabi_fishing:notify', 'No Knife', 'You need a knife to process fish', 'error')
|
||||
return
|
||||
end
|
||||
|
||||
-- Start processing animation
|
||||
local playerPed = cache.ped
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
lib.requestAnimDict('anim@amb@business@coc@coc_unpack_cut@', 100)
|
||||
TaskPlayAnim(playerPed, 'anim@amb@business@coc@coc_unpack_cut@', 'fullcut_cycle_v6_cokecutter', 8.0, -8.0, -1, 1, 0, false, false, false)
|
||||
|
|
@ -267,7 +233,7 @@ RegisterNetEvent('wasabi_fishing:processFish', function(fishItem)
|
|||
-- Processing progress bar
|
||||
if lib.progressBar({
|
||||
duration = 5000,
|
||||
label = Strings.processing_fish,
|
||||
label = 'Processing Fish',
|
||||
useWhileDead = false,
|
||||
canCancel = true,
|
||||
disable = {
|
||||
|
|
@ -284,7 +250,7 @@ RegisterNetEvent('wasabi_fishing:processFish', function(fishItem)
|
|||
TriggerServerEvent('wasabi_fishing:processItem', fishItem)
|
||||
else
|
||||
-- Cancelled
|
||||
TriggerEvent('wasabi_fishing:notify', Strings.canceled, Strings.canceled_desc, 'error')
|
||||
TriggerEvent('wasabi_fishing:notify', 'Canceled', 'Fish processing canceled', 'error')
|
||||
end
|
||||
|
||||
ClearPedTasks(playerPed)
|
||||
|
|
@ -295,4 +261,3 @@ RegisterNetEvent('wasabi_fishing:interupt', function()
|
|||
fishing = false
|
||||
ClearPedTasks(cache.ped)
|
||||
end)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue