# Fishing (ESX)

{% hint style="warning" %}
**ESX/QBCore:** This script requires purchase of either the ESX or QBCore version.
{% endhint %}

{% embed url="<https://store.dracem.com/package/5786761>" %}
**Only available at** [**DrAceM.com**](https://dracem.com)
{% endembed %}

<details>

<summary>Description</summary>

This script adds the ability to fish in any body of water, on your ESX server! Simply provide players with a way of obtaining a fishing rod item (add it to a shop, for example). Players can then use their fishing rod when facing water to start fishing. The player will perform a fishing animation with a visible fishing rod in their hand and periodically have a chance for a fish to bite. When the fish bites, the player must perform a skill check to catch the fish, which adds the species of fish to their inventory. These fish can be sold at the fish market for money.

By default, the Config.CommonFish species (carp) cannot be sold and is caught when a random chance generator is not successful to obtain a better species. If you would like this fish to be sold as well, simply add it to the Config.Fish table, with the chance as 100 and price as whatever you desire. Use the config.lua file to change the rod item name, chance to catch each fish, timing of the skill check, species of fish available, fish market info, etc. All display text can be customized in locales/en.lua or whatever language you are using.

</details>

<details>

<summary>Installation</summary>

1. Upload the script to your server's "resources" folder (or any \[sub\_directory])
2. Configure settings to your needs in `config.lua`
3. Execute `dam_fishing.sql` on your database, or manually add the rod item and fish species you set in `config.lua`
4. Ensure the script is starting in your `server.cfg`

</details>

<details>

<summary>Usage</summary>

Use the fishing rod item when facing any body of water, to start fishing.\
Press E at the right time to catch a fish.\
Sell fish at the fish market.

</details>

<details>

<summary>Config</summary>

```lua
Config = Config or {}

Config.OldESX       = false                                      -- Uses the old esx:getSharedObject event if true, or the new export if false | Default: false
Config.Locale       = GetConvar("esx:locale", "en")              -- Language file using esx:locale, defaulting to "en" | Default: GetConvar("esx:locale", "en")
Config.CatchChance  = 25                                         -- Chance (%) of a fish biting, every 5 seconds | Default: 25
Config.RodItem      = "fishing_rod"                              -- Fishing rod item name | Defalt: "fishing_rod"
Config.CommonFish   = "carp"                                     -- Junk fish name, given if the RNG (1-100) is outside the range of all other fish chances | Defalt: "carp"
Config.SkillbarTime = 2000                                       -- Time it takes the skillbar to go from 0-100% (in ms) | Default: 2000

Config.Fish = {                                                  -- Types of fish you can catch
    ["trout"]       = { chance = 80, price = 100 },              -- A fish type (key = item name, value = a table with chance as 1-100 (%) and price as sale value)
    ["bass"]        = { chance = 55, price = 150 },
    ["whiting"]     = { chance = 40, price = 200 },
    ["salmon"]      = { chance = 20, price = 300 },
    ["squid"]       = { chance = 5, price = 400 },
}

Config.Marketplace = {
    Label   = "Fish Market",                                     -- Label for the fish market (blip label and sales menu header) | Default: "Fish Market"
    Pos     = vector3(-1039.63, -1396.79, 4.55),                 -- Coordinates (vector3) of the fish market
    Marker  = {
        Show        = true,                                      -- Enable marker | Default: true
        Type        = 1,                                         -- Marker type | Default: 1
        Distance    = 100.0,                                     -- Marker draw distance | Default: 100.0
        Radius      = 2.5,                                       -- Marker interact radius. If the marker's a circle, this should be the same value as Size.x | Default: 2.5
        Size        = { x = 2.5, y = 2.5, z = 0.25 },            -- Marker size (xyz table). If the marker's a circle, x should be the same value as Radius
        Colour      = { r = 255, g = 255, b = 255, a = 180 }     -- Marker colour (rgba table)
    },
    Blip    = {
        Show        = true,                                      -- Enable map blip | Default: true
        Sprite      = 68,                                        -- Blip sprite/type | Default: 68
        Display     = 4,                                         -- Blip display type | Default: 4
        Scale       = 1.0,                                       -- Blip scale/size | Default: 1.0
        Colour      = 38                                         -- Blip colour | Default: 38
    }
}

Config.Notify = function(msg, type, time)                        -- Custom notification function (client side)
    -- exports.mythic_notify:SendAlert(type, msg, time)
    ESX.ShowNotification(msg, type, time)
end
```

</details>

| Code is accessible    | No    |
| --------------------- | ----- |
| Subscription-based    | No    |
| Lines (approximately) | \~200 |
| Requirements          | ESX   |
| Support               | Yes   |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dracem.com/scripts/dam_fishing/esx.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
