forked from Simnation/Main
ed
This commit is contained in:
parent
75db08b9a1
commit
d3792bfc47
3 changed files with 54 additions and 19 deletions
|
@ -51,8 +51,8 @@ if Config.sellShop.enabled then
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Function to check for available baits and select the best one
|
-- Function to select bait using ox_lib menu
|
||||||
local function GetBestAvailableBait()
|
local function SelectBait()
|
||||||
local availableBaits = {}
|
local availableBaits = {}
|
||||||
|
|
||||||
-- Check all bait types
|
-- Check all bait types
|
||||||
|
@ -67,15 +67,50 @@ local function GetBestAvailableBait()
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sort baits by catch bonus (highest first)
|
-- If only one bait type is available, use it directly
|
||||||
table.sort(availableBaits, function(a, b)
|
if #availableBaits == 1 then
|
||||||
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
|
||||||
|
@ -140,8 +175,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 get a new bait
|
-- Try to select a new bait
|
||||||
local newBait = GetBestAvailableBait()
|
local newBait = SelectBait()
|
||||||
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')
|
||||||
|
@ -204,7 +239,7 @@ RegisterNetEvent('wasabi_fishing:startFishing', function()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Select bait
|
-- Select bait
|
||||||
local selectedBait = GetBestAvailableBait()
|
local selectedBait = SelectBait()
|
||||||
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
|
||||||
|
|
|
@ -62,7 +62,7 @@ Config.bait = {
|
||||||
|
|
||||||
Config.fishingRod = {
|
Config.fishingRod = {
|
||||||
itemName = 'fishingrod', -- Item name of fishing rod
|
itemName = 'fishingrod', -- Item name of fishing rod
|
||||||
breakChance = 25 --Chance of breaking pole when failing skillbar (Setting to 0 means never break)
|
breakChance = 0 --Chance of breaking pole when failing skillbar (Setting to 0 means never break)
|
||||||
}
|
}
|
||||||
|
|
||||||
Config.timeForBite = { -- Set min and max random range of time it takes for fish to be on the line.
|
Config.timeForBite = { -- Set min and max random range of time it takes for fish to be on the line.
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
--------------- https://discord.gg/wasabiscripts -------------
|
--------------- https://discord.gg/wasabiscripts -------------
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
Strings = {
|
Strings = {
|
||||||
intro_instruction = 'Press ~INPUT_ATTACK~ to cast line, ~INPUT_FRONTEND_RRIGHT~ to cancel.',
|
intro_instruction = 'Drücke ~INPUT_ATTACK~ zu auswerfen, ~INPUT_FRONTEND_RRIGHT~ um abzubrechen.',
|
||||||
rod_broke = 'Rod Snapped',
|
rod_broke = 'Deine Angel hat den Geist aufgegeben.',
|
||||||
rod_broke_desc = 'You pulled to hard and your fishing rod snapped!',
|
rod_broke_desc = 'Oha, zu fest gezogen! Die Angel ist kaputt.',
|
||||||
cannot_perform = 'Action Incomplete',
|
cannot_perform = 'Fast, aber nicht ganz.',
|
||||||
cannot_perform_desc = 'You cannot do this right now.',
|
cannot_perform_desc = 'Das geht gerade nicht – der Fisch macht Pause.',
|
||||||
failed = 'Failed',
|
failed = 'Oops, das war nix.',
|
||||||
failed_fish = 'You failed to catch fish!',
|
failed_fish = 'Nix gefangen – der Fisch war schneller.',
|
||||||
no_water = 'Error 404: Wasser nicht gefunden.',
|
no_water = 'Error 404: Wasser nicht gefunden.',
|
||||||
no_water_desc = 'Deine Angel verheddert sich im trockenen Gras. Bravo.',
|
no_water_desc = 'Deine Angel verheddert sich im trockenen Gras. Bravo.',
|
||||||
no_bait = 'Vielleicht versuchst Du es mal mit Köder.',
|
no_bait = 'Vielleicht versuchst Du es mal mit Köder.',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue