├── ReadMe.md ├── client └── client.lua ├── fxmanifest.lua ├── installation ├── bait.png ├── basic_rod.png ├── fish.png ├── items.md └── shark.png ├── server └── server.lua └── shared └── config.lua /ReadMe.md: -------------------------------------------------------------------------------- 1 | X Fish Anywhere I ESX & QB 2 | 3 | Support: 4 | https://discord.gg/N74Yuq9ARQ 5 | 6 | Preview: 7 | https://youtu.be/41lcSdQ0A0Q 8 | -------------------------------------------------------------------------------- /client/client.lua: -------------------------------------------------------------------------------- 1 | local isFishing = false 2 | local failStreak = 0 3 | local fishingRodProp = nil 4 | 5 | local function IsNearWater() 6 | local ped = PlayerPedId() 7 | local pos = GetEntityCoords(ped) 8 | local _, hit, _, _, _ = TestProbeAgainstWater(pos.x, pos.y, pos.z, pos.x, pos.y, pos.z - 5.0) 9 | return hit and IsPedOnFoot(ped) 10 | end 11 | 12 | local function isWaterThere() 13 | local ped = PlayerPedId() 14 | local headCoords = GetPedBoneCoords(ped, 31086, 0.0, 0.0, 0.0) 15 | local coords = GetOffsetFromEntityInWorldCoords(ped, 0.0, 2.0, -1.5) 16 | local hasWater = TestProbeAgainstWater(headCoords.x, headCoords.y, headCoords.z, coords.x, coords.y, coords.z) 17 | return hasWater 18 | end 19 | 20 | 21 | RegisterNetEvent('xFishAnywhere:notify') 22 | AddEventHandler('xFishAnywhere:notify', function(message, type) 23 | lib.notify({ title = Config.Title, description = message, type = type }) 24 | end) 25 | 26 | local function StartFishing() 27 | if isFishing then 28 | lib.notify({ title = Config.Title, description = Config.AlreadyFishing, type = "error" }) 29 | return 30 | end 31 | 32 | local ped = PlayerPedId() 33 | if not IsNearWater() or not isWaterThere() then 34 | lib.notify({ title = Config.Title, description = Config.StandInFrontOfWater, type = "error" }) 35 | return 36 | end 37 | 38 | lib.requestAnimDict('amb@world_human_stand_fishing@idle_a') 39 | lib.requestAnimDict('mini@tennis') 40 | 41 | isFishing = true 42 | TaskPlayAnim(ped, 'amb@world_human_stand_fishing@idle_a', 'idle_b', 8.0, -1.0, -1, 50, 0, false, false, false) 43 | 44 | fishingRodProp = CreateObject(GetHashKey("prop_fishing_rod_01"), 0.0, 0.0, 0.0, true, true, false) 45 | AttachEntityToEntity(fishingRodProp, ped, GetPedBoneIndex(ped, 57005), 0.1, 0.02, -0.01, 30.0, 40.0, 50.0, true, true, false, true, false, true) 46 | 47 | local success = lib.skillCheck({ Config.Skillcheck1, Config.Skillcheck2, { areaSize = Config.areaSize, speedMultiplier = Config.speedMultiplier }, Config.Skillcheck3 }, { Config.SkillKey1, Config.SkillKey2, Config.SkillKey3, Config.SkillKey4 }) 48 | 49 | ClearPedTasksImmediately(ped) 50 | 51 | if fishingRodProp then 52 | DeleteObject(fishingRodProp) 53 | fishingRodProp = nil 54 | end 55 | isFishing = false 56 | 57 | if success then 58 | failStreak = 0 59 | TriggerServerEvent("xFishAnywhere:catchFish") 60 | lib.notify({ title = Config.Title, description = Config.FishCaught, type = "success" }) 61 | else 62 | failStreak = failStreak + 1 63 | lib.notify({ title = Config.Title, description = "You failed to catch anything!", type = "error" }) 64 | if Config.BreakRodAfterFails and failStreak >= Config.FailAttemptsToBreak then 65 | failStreak = 0 66 | TriggerServerEvent("xFishAnywhere:breakRod") 67 | lib.notify({ title = Config.Title, description = Config.FishingRodBroke, type = "error" }) 68 | end 69 | end 70 | end 71 | 72 | RegisterNetEvent("xFishAnywhere:useRod") 73 | AddEventHandler("xFishAnywhere:useRod", function() 74 | StartFishing() 75 | end) 76 | -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | game 'gta5' 3 | lua54 'yes' 4 | author 'XSCRIPTS' 5 | description 'X Fish Anywhere' 6 | version '2.0' 7 | 8 | shared_scripts { 9 | 'shared/config.lua', 10 | '@ox_lib/init.lua' 11 | } 12 | 13 | client_scripts { 14 | 'client/client.lua' 15 | } 16 | 17 | server_scripts { 18 | 'server/server.lua' 19 | } 20 | -------------------------------------------------------------------------------- /installation/bait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xscriptsdev/xFishAnywhere/2156c4883d23c93211e85284f6a98dcb74f86d8b/installation/bait.png -------------------------------------------------------------------------------- /installation/basic_rod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xscriptsdev/xFishAnywhere/2156c4883d23c93211e85284f6a98dcb74f86d8b/installation/basic_rod.png -------------------------------------------------------------------------------- /installation/fish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xscriptsdev/xFishAnywhere/2156c4883d23c93211e85284f6a98dcb74f86d8b/installation/fish.png -------------------------------------------------------------------------------- /installation/items.md: -------------------------------------------------------------------------------- 1 | ['basic_rod'] = { 2 | label = 'Fishing rod', 3 | stack = false, 4 | weight = 250 5 | }, 6 | 7 | ['bait'] = { 8 | label = 'Bait', 9 | stack = false, 10 | weight = 30 11 | }, 12 | 13 | ["fish"] = { 14 | label = "Fish", 15 | weight = 1, 16 | stack = true, 17 | close = true, 18 | }, 19 | 20 | ['shark'] = { 21 | label = 'Shark', 22 | weight = 7500 23 | }, 24 | -------------------------------------------------------------------------------- /installation/shark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xscriptsdev/xFishAnywhere/2156c4883d23c93211e85284f6a98dcb74f86d8b/installation/shark.png -------------------------------------------------------------------------------- /server/server.lua: -------------------------------------------------------------------------------- 1 | ESX, QBCore = nil, nil 2 | 3 | if GetResourceState("es_extended") == "started" then 4 | ESX = exports["es_extended"]:getSharedObject() 5 | elseif GetResourceState("qb-core") == "started" then 6 | QBCore = exports["qb-core"]:GetCoreObject() 7 | end 8 | 9 | local function HasFishingRod(source) 10 | if ESX then 11 | local xPlayer = ESX.GetPlayerFromId(source) 12 | return xPlayer.getInventoryItem(Config.RequiredItem).count > 0 13 | elseif QBCore then 14 | local Player = QBCore.Functions.GetPlayer(source) 15 | return Player.Functions.GetItemByName(Config.RequiredItem) ~= nil 16 | end 17 | return false 18 | end 19 | 20 | local function RemoveFishingRod(source) 21 | if ESX then 22 | local xPlayer = ESX.GetPlayerFromId(source) 23 | xPlayer.removeInventoryItem(Config.RequiredItem, 1) 24 | elseif QBCore then 25 | local Player = QBCore.Functions.GetPlayer(source) 26 | Player.Functions.RemoveItem(Config.RequiredItem, 1) 27 | TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items[Config.RequiredItem], "remove") 28 | end 29 | end 30 | 31 | local function GiveFishingReward(source) 32 | local reward = Config.FishingRewards[math.random(1, #Config.FishingRewards)] 33 | if ESX then 34 | local xPlayer = ESX.GetPlayerFromId(source) 35 | xPlayer.addInventoryItem(reward, 1) 36 | elseif QBCore then 37 | local Player = QBCore.Functions.GetPlayer(source) 38 | Player.Functions.AddItem(reward, 1) 39 | TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items[reward], "add") 40 | end 41 | 42 | end 43 | 44 | RegisterNetEvent("xFishAnywhere:catchFish") 45 | AddEventHandler("xFishAnywhere:catchFish", function() 46 | local source = source 47 | if not HasFishingRod(source) then 48 | return 49 | end 50 | GiveFishingReward(source) 51 | end) 52 | 53 | RegisterNetEvent("xFishAnywhere:breakRod") 54 | AddEventHandler("xFishAnywhere:breakRod", function() 55 | local source = source 56 | if HasFishingRod(source) then 57 | RemoveFishingRod(source) 58 | end 59 | end) 60 | 61 | if ESX then 62 | ESX.RegisterUsableItem(Config.RequiredItem, function(source) 63 | local xPlayer = ESX.GetPlayerFromId(source) 64 | local bait = xPlayer.getInventoryItem(Config.RequiredBait) 65 | 66 | if bait and bait.count > 0 then 67 | xPlayer.removeInventoryItem(Config.RequiredBait, 1) 68 | TriggerClientEvent("xFishAnywhere:useRod", source) 69 | else 70 | TriggerClientEvent('xFishAnywhere:notify', source, Config.YouNeedBait, 'error') 71 | end 72 | end) 73 | elseif QBCore then 74 | QBCore.Functions.CreateUseableItem(Config.RequiredItem, function(source) 75 | local Player = QBCore.Functions.GetPlayer(source) 76 | local bait = Player.Functions.GetItemByName(Config.RequiredBait) 77 | 78 | if bait and bait.amount > 0 then 79 | Player.Functions.RemoveItem(Config.RequiredBait, 1) 80 | TriggerClientEvent("inventory:client:ItemBox", source, QBCore.Shared.Items[Config.RequiredBait], "remove") 81 | TriggerClientEvent("xFishAnywhere:useRod", source) 82 | else 83 | TriggerClientEvent('QBCore:Notify', source, 'You need fishing bait to fish!', 'error') 84 | end 85 | end) 86 | end 87 | -------------------------------------------------------------------------------- /shared/config.lua: -------------------------------------------------------------------------------- 1 | 2 | --██╗░░██╗  ░██████╗░█████╗░██████╗░██╗██████╗░████████╗░██████╗ 3 | --╚██╗██╔╝  ██╔════╝██╔══██╗██╔══██╗██║██╔══██╗╚══██╔══╝██╔════╝ 4 | --░╚███╔╝░  ╚█████╗░██║░░╚═╝██████╔╝██║██████╔╝░░░██║░░░╚█████╗░ 5 | --░██╔██╗░  ░╚═══██╗██║░░██╗██╔══██╗██║██╔═══╝░░░░██║░░░░╚═══██╗ 6 | --██╔╝╚██╗  ██████╔╝╚█████╔╝██║░░██║██║██║░░░░░░░░██║░░░██████╔╝ 7 | --╚═╝░░╚═╝  ╚═════╝░░╚════╝░╚═╝░░╚═╝╚═╝╚═╝░░░░░░░░╚═╝░░░╚═════╝░ 8 | -- Support: https://discord.gg/N74Yuq9ARQ 9 | 10 | Config = {} 11 | 12 | Config.RequiredItem = "basic_rod" -- Here you can put your own item for fishing rod or use this one 13 | 14 | Config.RequiredBait = "bait" -- Bait item 15 | 16 | Config.FishingRewards = { "fish", "shark" } -- you can put more if u need to 17 | 18 | Config.BreakRodAfterFails = true -- true for to break the road after fails 19 | Config.FailAttemptsToBreak = 1 -- how many times player need to fail for breaking the rod 20 | 21 | -- Skill check difficulties 22 | Config.Skillcheck1 = 'easy' -- easy/medium/hard 23 | Config.Skillcheck2 = 'easy' 24 | Config.Skillcheck3 = 'easy' 25 | 26 | -- Skill check keys 27 | Config.SkillKey1 = 'w' 28 | Config.SkillKey2 = 'a' 29 | Config.SkillKey3 = 's' 30 | Config.SkillKey4 = 'd' 31 | 32 | Config.speedMultiplier = 2 -- Speed of the skill check 33 | 34 | Config.areaSize = 60 -- This is the size of the success area in degrees on the skill check 35 | 36 | 37 | -- Notifications 38 | 39 | Config.Title = "Fishing" 40 | Config.AlreadyFishing = "You are already fishing" 41 | Config.StandInFrontOfWater = "You need to be standing in front of water to fish!" 42 | Config.FishCaught = "You caught a fish!" 43 | Config.Failed = "You failed to catch anything!" 44 | Config.FishingRodBroke = "Your fishing rod broke!" 45 | --------------------------------------------------------------------------------