> ## Documentation Index
> Fetch the complete documentation index at: https://docs.humalike.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Zbuduj własny most

> Utwórz osobny zasób FiveM, który łączy Twój framework z Humalike.

Ten przykład rejestruje własnego dostawcę gracza oraz klienckiego dostawcę
interakcji. Dodawaj tylko te domeny, które Twój serwer faktycznie obsługuje.

## Katalog

```text theme={null}
resources/
├── humalike/
└── my-humalike-bridge/
    ├── fxmanifest.lua
    ├── server.lua
    └── client.lua
```

## Manifest

```lua theme={null}
fx_version 'cerulean'
game 'gta5'
lua54 'yes'

name 'my-humalike-bridge'
version '1.0.0'

dependency 'humalike'

server_script 'server.lua'
client_script 'client.lua'
```

Uruchamiaj go po Humalike:

```cfg theme={null}
ensure humalike
ensure my-humalike-bridge
```

## Dostawca serwerowy

```lua theme={null}
local function registerProviders()
    local ok, err = exports.humalike:RegisterProvider('player', {
        name = 'my_framework',
        apiVersion = 1,
        priority = 100,

        Available = function()
            return GetResourceState('my-core') == 'started'
        end,

        GetCharacterId = function(source)
            local player = exports['my-core']:GetPlayer(source)
            return player and player.characterId or nil
        end,

        GetCharacterName = function(source)
            local player = exports['my-core']:GetPlayer(source)
            return player and player.fullName or nil
        end,

        IsCharacterLoaded = function(source)
            return exports['my-core']:GetPlayer(source) ~= nil
        end,

        HasJob = function(source, jobNames, requireDuty)
            local player = exports['my-core']:GetPlayer(source)
            if not player then return false end

            for _, name in ipairs(jobNames) do
                if player.job.name == name then
                    return not requireDuty or player.job.onDuty == true
                end
            end
            return false
        end,

        Notify = function(source, message, kind)
            TriggerClientEvent('my-ui:notify', source, message, kind)
        end,
    })

    if not ok then
        print(('[my-humalike-bridge] player provider failed: %s'):format(err))
    end
end

AddEventHandler('onResourceStart', function(resource)
    if resource == GetCurrentResourceName() then registerProviders() end
end)

AddEventHandler('humalike:integration:ready', registerProviders)
```

Nie buforuj obiektu gracza między callbackami. Za każdym razem ustalaj aktywną
postać na podstawie `source`, aby ponowne połączenia i zmiany postaci były
obsługiwane poprawnie.

## Kliencki dostawca interakcji

```lua theme={null}
local entries = {}

local function registerInteraction()
    exports.humalike:RegisterInteractionProvider({
        name = 'my_target',
        apiVersion = 1,
        priority = 100,

        Available = function()
            return GetResourceState('my-target') == 'started'
        end,

        watchedResources = { 'my-target' },

        Add = function(id, entity, options)
            entries[id] = { entity = entity, options = options }
            exports['my-target']:AddEntity(entity, options)
            return true
        end,

        Remove = function(id)
            local entry = entries[id]
            if not entry then return end
            exports['my-target']:RemoveEntity(entry.entity)
            entries[id] = nil
        end,

        Progress = function(durationMs, label)
            return exports['my-progress']:Run(durationMs, label) == true
        end,
    })
end

AddEventHandler('onClientResourceStart', function(resource)
    if resource == GetCurrentResourceName() then registerInteraction() end
end)

AddEventHandler('humalike:integration:ready', registerInteraction)
```

Każda opcja zawiera `text`, opcjonalne `icon`, `canInteract(entity)` oraz
`onSelect(entity)`. Zachowaj te callbacki, dostosowując opcję do swojego
systemu targetowania.

## Wybierz i zweryfikuj

```cfg theme={null}
set humalike_player my_framework
set humalike_interaction my_target
```

Uruchom `humalike_status` w konsoli serwera i klienta. Obie domeny powinny
pokazywać `selected`, oczekiwaną nazwę dostawcy oraz most jako właściciela.

Zobacz [API dostawcy](/pl/ai-npc/integrations/provider-api), aby poznać każdy
deskryptor i wartość zwracaną.

## Dalej

* [Dodaj neutralne zdarzenia gracza](/pl/ai-npc/integrations/world-events).
* [Sprawdź status dostawców](/pl/ai-npc/operations#stany-dostawców).
* [Przejrzyj bezpieczeństwo integracji](/pl/ai-npc/security#granice-zaufania).
