> For the complete documentation index, see [llms.txt](https://dragon-heart-studios.gitbook.io/dragonheartstudios/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dragon-heart-studios.gitbook.io/dragonheartstudios/scripts/dhs-fishing/integration.md).

# Integration

{% hint style="warning" %}
WARNING: ONLY MESS WITH THESE IF YOU KNOW WHAT YOU ARE DOING!!!!
{% endhint %}

### Minigame

{% hint style="info" %}
By default we use ps-ui for the fishing minigame however, in the DHS-Fishing/client/editablefunctions.lua you can edit this to match whatever minigame you want.
{% endhint %}

```lua
function TriggerFishingMinigame()
    local fishinglvl = Bridge.Framework.GetPlayerMetaData('fishinglvl') or 1
    local passed = false

    -- Check if ps-ui is available
    if GetResourceState('ps-ui') == 'started' then
        exports['ps-ui']:Circle(function(success)
            if success then
                passed = true
            else
                passed = false
            end
        end, Config.DifficultySettings[fishinglvl].MinigameCircleNum,
        Config.DifficultySettings[fishinglvl].MinigameCircleMS)
    else
        -- Fallback to ox_lib skill check if ps-ui is not available
        local success = lib.skillCheck({'easy', 'easy', 'medium'}, {'e'})
        passed = success
    end

    return passed
end
```

***

### Dispatch Function

{% hint style="info" %}
By default we use qbcore built in system however we have support for both:

* ps-dispatch
* cd-dispatch

however if you know what you are doing you can implement your own as well.

* DHS-Fishing/client/editablefunctions.lua
  {% endhint %}

```lua
function CallPolice()
    local coords = GetEntityCoords(cache.ped)

    -- Use Community Bridge Dispatch module if available
    if Bridge.Modules and Bridge.Modules.Dispatch then
        local alertData = {
            coords = coords,
            title = Config.Lang.police_alert.illegal_activity or 'Illegal Fishing Activity',
            description = 'Suspicious fishing activity reported',
            alert_code = '10-15',
            sprite = 431,
            color = 3,
            scale = 1.2,
            jobs = {'police'}
        }
        local success, err = pcall(function()
            Bridge.Dispatch.AlertPolice(alertData)
        end)
        if not success then
            DebugLog('Dispatch alert failed: ' .. tostring(err))
        end
        return
    end

    -- Fallback to traditional dispatch systems with safe checks
    if Config.DispatchSystem == 'qbcore' then
        TriggerServerEvent('police:server:policeAlert', Config.Lang.police_alert.illegal_activity)
    elseif Config.DispatchSystem == 'ps-dispatch' then
        if GetResourceState('ps-dispatch') == 'started' then
            local success, err = pcall(function()
                exports['ps-dispatch']:SuspiciousActivity()
            end)
            if not success then
                DebugLog('ps-dispatch alert failed: ' .. tostring(err))
            end
        end
    elseif Config.DispatchSystem == 'cd-dispatch' then
        if GetResourceState('cd_dispatch') == 'started' then
            local success, err = pcall(function()
                local data = exports['cd_dispatch']:GetPlayerInfo()
                TriggerServerEvent('cd_dispatch:AddNotification', {
                    job_table = {'police'},
                    coords = data.coords,
                    title = '10-15 - Illegal Fishing Activity',
                    message = 'A ' .. data.sex .. ' using illegal bait at ' .. data.street,
                    flash = 0,
                    unique_id = tostring(math.random(0000000, 9999999)),
                    blip = {
                        sprite = 431,
                        scale = 1.2,
                        colour = 3,
                        flashes = false,
                        text = '911 - Illegal Fishing Activity',
                        time = (5 * 60 * 1000),
                        sound = 1,
                    }
                })
            end)
            if not success then
                DebugLog('cd_dispatch alert failed: ' .. tostring(err))
            end
        end
    else
        -- No dispatch system configured or available
        DebugLog('No dispatch system available for police alert')
    end
end
```

***

### Notify System

{% hint style="info" %}
By default we use the built in qbcore notify system however we also support ox\_lib notify but if you know what you are doing you can integrate this as well.

* DHS-Fishing/client/editablefunctions.lua
  {% endhint %}

```lua
function Notify(text, type, time)
    if Config.HandleNotify and Bridge and Bridge.Notify then
        Bridge.Notify.SendNotify(text, type, time)
    else
        -- Fallback to print if Bridge not ready
        print('[DHS-Fishing] Notify: ' .. tostring(text))
    end
end
```

***
