forked from Simnation/Main
Update client.lua
This commit is contained in:
parent
1c8dba5cbf
commit
7afebb1403
1 changed files with 11 additions and 46 deletions
|
@ -51,8 +51,8 @@ if Config.sellShop.enabled then
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Function to select bait using ox_lib menu
|
-- Function to check for available baits and select the best one
|
||||||
local function SelectBait()
|
local function GetBestAvailableBait()
|
||||||
local availableBaits = {}
|
local availableBaits = {}
|
||||||
|
|
||||||
-- Check all bait types
|
-- Check all bait types
|
||||||
|
@ -67,50 +67,15 @@ local function SelectBait()
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- If only one bait type is available, use it directly
|
-- Sort baits by catch bonus (highest first)
|
||||||
if #availableBaits == 1 then
|
table.sort(availableBaits, function(a, b)
|
||||||
|
return (a.catchBonus or 0) > (b.catchBonus or 0)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Return the best bait
|
||||||
return availableBaits[1]
|
return availableBaits[1]
|
||||||
end
|
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]
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Function to handle the fishing process
|
-- Function to handle the fishing process
|
||||||
local function StartFishingProcess(selectedBait, waterLoc)
|
local function StartFishingProcess(selectedBait, waterLoc)
|
||||||
fishing = true
|
fishing = true
|
||||||
|
@ -175,8 +140,8 @@ local function StartFishingProcess(selectedBait, waterLoc)
|
||||||
-- Check if we still have this bait
|
-- Check if we still have this bait
|
||||||
local hasBait = lib.callback.await('wasabi_fishing:checkItem', 100, selectedBait.itemName)
|
local hasBait = lib.callback.await('wasabi_fishing:checkItem', 100, selectedBait.itemName)
|
||||||
if not hasBait then
|
if not hasBait then
|
||||||
-- Try to select a new bait
|
-- Try to get a new bait
|
||||||
local newBait = SelectBait()
|
local newBait = GetBestAvailableBait()
|
||||||
if newBait then
|
if newBait then
|
||||||
selectedBait = newBait
|
selectedBait = newBait
|
||||||
TriggerEvent('wasabi_fishing:notify', 'New Bait', 'Using ' .. selectedBait.label .. ' as bait', 'inform')
|
TriggerEvent('wasabi_fishing:notify', 'New Bait', 'Using ' .. selectedBait.label .. ' as bait', 'inform')
|
||||||
|
@ -239,7 +204,7 @@ RegisterNetEvent('wasabi_fishing:startFishing', function()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Select bait
|
-- Select bait
|
||||||
local selectedBait = SelectBait()
|
local selectedBait = GetBestAvailableBait()
|
||||||
if not selectedBait then
|
if not selectedBait then
|
||||||
TriggerEvent('wasabi_fishing:notify', Strings.no_bait, Strings.no_bait_desc, 'error')
|
TriggerEvent('wasabi_fishing:notify', Strings.no_bait, Strings.no_bait_desc, 'error')
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue