From 7afebb1403b1b64fd58531084bf0e0e155c0f074 Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Tue, 1 Jul 2025 13:13:53 +0200 Subject: [PATCH] Update client.lua --- .../[civ]/wasabi_fishing/client/client.lua | 57 ++++--------------- 1 file changed, 11 insertions(+), 46 deletions(-) diff --git a/resources/[jobs]/[civ]/wasabi_fishing/client/client.lua b/resources/[jobs]/[civ]/wasabi_fishing/client/client.lua index f32f5b244..bf6dc2db5 100644 --- a/resources/[jobs]/[civ]/wasabi_fishing/client/client.lua +++ b/resources/[jobs]/[civ]/wasabi_fishing/client/client.lua @@ -51,8 +51,8 @@ if Config.sellShop.enabled then end) end --- Function to select bait using ox_lib menu -local function SelectBait() +-- Function to check for available baits and select the best one +local function GetBestAvailableBait() local availableBaits = {} -- Check all bait types @@ -67,48 +67,13 @@ local function SelectBait() return nil end - -- If only one bait type is available, use it directly - if #availableBaits == 1 then - return availableBaits[1] - end + -- Sort baits by catch bonus (highest first) + table.sort(availableBaits, function(a, b) + return (a.catchBonus or 0) > (b.catchBonus or 0) + end) - -- Create menu options for bait selection - local options = {} - for i, bait in ipairs(availableBaits) do - table.insert(options, { - title = bait.label, - description = 'Catch Bonus: +' .. bait.catchBonus .. '% | Loss Chance: ' .. bait.loseChance .. '%', - icon = 'fish', - onSelect = function() - -- This will be handled by the menu's onClose callback - end - }) - end - - -- Create a variable to store the selected bait - local selectedIndex = 1 - - -- Register the menu - lib.registerMenu({ - id = 'bait_selection_menu', - title = 'Select Fishing Bait', - position = 'top-right', - options = options, - onClose = function(selected) - selectedIndex = selected or 1 - end - }) - - -- Show the menu - lib.showMenu('bait_selection_menu') - - -- Wait for menu to close - while lib.getOpenMenu() == 'bait_selection_menu' do - Wait(100) - end - - -- Return the selected bait - return availableBaits[selectedIndex] + -- Return the best bait + return availableBaits[1] end -- Function to handle the fishing process @@ -175,8 +140,8 @@ local function StartFishingProcess(selectedBait, waterLoc) -- Check if we still have this bait local hasBait = lib.callback.await('wasabi_fishing:checkItem', 100, selectedBait.itemName) if not hasBait then - -- 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', 'New Bait', 'Using ' .. selectedBait.label .. ' as bait', 'inform') @@ -239,7 +204,7 @@ 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