1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-01 12:59:20 +02:00
parent 75db08b9a1
commit d3792bfc47
3 changed files with 54 additions and 19 deletions

View file

@ -51,8 +51,8 @@ if Config.sellShop.enabled then
end)
end
-- Function to check for available baits and select the best one
local function GetBestAvailableBait()
-- Function to select bait using ox_lib menu
local function SelectBait()
local availableBaits = {}
-- Check all bait types
@ -67,15 +67,50 @@ local function GetBestAvailableBait()
return nil
end
-- Sort baits by catch bonus (highest first)
table.sort(availableBaits, function(a, b)
return (a.catchBonus or 0) > (b.catchBonus or 0)
end)
-- Return the best bait
-- If only one bait type is available, use it directly
if #availableBaits == 1 then
return availableBaits[1]
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
local function StartFishingProcess(selectedBait, waterLoc)
fishing = true
@ -140,8 +175,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 get a new bait
local newBait = GetBestAvailableBait()
-- Try to select a new bait
local newBait = SelectBait()
if newBait then
selectedBait = newBait
TriggerEvent('wasabi_fishing:notify', 'New Bait', 'Using ' .. selectedBait.label .. ' as bait', 'inform')
@ -204,7 +239,7 @@ RegisterNetEvent('wasabi_fishing:startFishing', function()
end
-- Select bait
local selectedBait = GetBestAvailableBait()
local selectedBait = SelectBait()
if not selectedBait then
TriggerEvent('wasabi_fishing:notify', Strings.no_bait, Strings.no_bait_desc, 'error')
return

View file

@ -62,7 +62,7 @@ Config.bait = {
Config.fishingRod = {
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.

View file

@ -2,13 +2,13 @@
--------------- https://discord.gg/wasabiscripts -------------
---------------------------------------------------------------
Strings = {
intro_instruction = 'Press ~INPUT_ATTACK~ to cast line, ~INPUT_FRONTEND_RRIGHT~ to cancel.',
rod_broke = 'Rod Snapped',
rod_broke_desc = 'You pulled to hard and your fishing rod snapped!',
cannot_perform = 'Action Incomplete',
cannot_perform_desc = 'You cannot do this right now.',
failed = 'Failed',
failed_fish = 'You failed to catch fish!',
intro_instruction = 'Drücke ~INPUT_ATTACK~ zu auswerfen, ~INPUT_FRONTEND_RRIGHT~ um abzubrechen.',
rod_broke = 'Deine Angel hat den Geist aufgegeben.',
rod_broke_desc = 'Oha, zu fest gezogen! Die Angel ist kaputt.',
cannot_perform = 'Fast, aber nicht ganz.',
cannot_perform_desc = 'Das geht gerade nicht der Fisch macht Pause.',
failed = 'Oops, das war nix.',
failed_fish = 'Nix gefangen der Fisch war schneller.',
no_water = 'Error 404: Wasser nicht gefunden.',
no_water_desc = 'Deine Angel verheddert sich im trockenen Gras. Bravo.',
no_bait = 'Vielleicht versuchst Du es mal mit Köder.',