1
0
Fork 0
forked from Simnation/Main

Update client.lua

This commit is contained in:
Nordi98 2025-07-01 13:13:53 +02:00
parent 1c8dba5cbf
commit 7afebb1403

View file

@ -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