> For the complete documentation index, see [llms.txt](https://documentation.rcore.cz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.rcore.cz/paid-resources/rcore_banners/api/server.md).

# Server

## Events

<details>

<summary><code>rcore_banners:server:worldInteract</code></summary>

All data related to placing or removing banners in the world.

```lua
---@param bannerId number DB-ID of the banner.
---@param playerId number Player who performed the interaction.
---@param actionType string Task performed: ADDED_BANNER, REMOVED_BANNER.
---@param locationType string Where the interaction happened: WORLD, BILLBOARD.
AddEventHandler('rcore_banners:server:worldInteract', function(bannerId, playerId, actionType, locationType)
end)
```

</details>

<details>

<summary><code>rcore_banners:server:Stations</code></summary>

All data related to business work station changes.

```lua
---@param businessName string Name of the business the change relates to.
---@param playerId number Player who performed the interaction at the work station.
---@param stationIdx number Unique ID of the station where the change happened.
---@param stationState string What happened to the station: UPDATED_STATION, STARTED_PRODUCTION.
---@param changeState string Informational string describing the change.
---@param data table Any relevant extra data associated with the state/change.
AddEventHandler('rcore_banners:server:Stations', function(businessName, playerId, stationIdx, stationState, changeState, data)
end)
```

</details>

<details>

<summary><code>rcore_banners:server:Billboards</code></summary>

All data related to billboard changes.

```lua
---@param session table Data related to the billboard change.
AddEventHandler('rcore_banners:server:Billboards', function(session)
    -- session = {
    --     initiator: playerId,                    -- Player initiating the action
    --     initiatorName: GetPlayerName(playerId),  -- Name of the player initiating the action
    --     billboardId: billboardId,                -- ID of the billboard involved in the action
    --     owner: owner,                            -- Owner of the billboard (business/faction)
    --     action: 'buyBillboard',                  -- Type of action: [buyBillboard, sellBillboard, setBillboardImage, transferBillboard]
    --     data: {
    --         -- Specific dynamic data related to the action, e.g. for 'sellBillboard':
    --         sellPrice: sellPrice,
    --         targetSociety: targetSociety,
    --         targetSocietyCut: targetSocietyCut,
    --         ownedBusinessReturn: ownedBusinessReturn
    --     }
    --     -- OR, for 'setBillboardImage':
    --     data: {
    --         side: side,                          -- Side of the billboard (if applicable, A or B)
    --         banner_name: data['banner_name'],
    --         banner_image: data['banner_image']
    --     }
    -- }

    if session.action == 'buyBillboard' then
        -- Handle buy billboard logic
    elseif session.action == 'sellBillboard' then
        -- Handle sell billboard logic
    elseif session.action == 'setBillboardImage' then
        local side = session.data.side
        local bannerName = session.data.banner_name
        local bannerImage = session.data.banner_image
    elseif session.action == 'transferBillboard' then
        -- Handle transfer billboard logic
    end
end)
```

</details>

## Exports

<details>

<summary><code>AddBannerIntoSystem</code></summary>

Create your own banner from your own resource and register it into `rcore_banners`.

```lua
---@param data table { banner_name: string, banner_type: 'custom', banner_image: string }
---@return boolean state
---@return number statusCode
local state, statusCode = exports.rcore_banners:AddBannerIntoSystem({
    banner_name = 'banner_name', -- Name of the banner
    banner_type = 'custom', -- Type needs to be custom!
    banner_image = 'banner_image_url' -- Link to your banner image (accepts image/png, image/jpg, image/gif)
})

if state then
    print('Banner was defined into rcore_banners resource')
end
```

</details>

<details>

<summary><code>AddBannerToPlayerInventory</code></summary>

Give a banner item that exists in the banners resource to a player.

```lua
---@param playerId number Player's server identifier.
---@param amount number Amount of the item to give.
---@param data table { banner_name: string }
---@return boolean itemState
---@return number itemStatusCode
local itemState, itemStatusCode = exports.rcore_banners:AddBannerToPlayerInventory(playerId, amount, {
    banner_name = 'rcore_banners',
})

if itemState then
    print('Banner item was added to the player')
end
```

</details>
