> For the complete documentation index, see [llms.txt](https://bluen-store.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bluen-store.gitbook.io/docs/cinema-system/frameworks/server-guide.md).

# Server guide

## Framework functions

### getIdentifier

This function is used to retrieve a player's identifier to manage and verify tickets.

***

```lua
-- This is an example from the brnx-cinemasystem esx.lua file

-- @param source: number
getIdentifier = function(source)
    return GetPlayerIdentifierByType(source, 'license')
end
```

### canAcessThePanel

***

This function is used to check who can access the tablet.

```lua
-- This is an example from the brnx-cinemasystem esx.lua file

-- @param source: number
canAcessThePanel = function(source)
    local license <const> = GetPlayerIdentifierByType(source, 'license')
    if not license then return false end
    local licenses <const> = {
        ['license:xxxxxxxxxxxxxxxxxxxxxxxx'] = true
    }
    return licenses[license]
end
```

### tryPayment

***

This function is used to attempt to process the payment.

```lua
-- This is an example from the brnx-cinemasystem esx.lua file

-- @param source: number
-- @param price: number
tryPayment = function(source, price)
    local player = ESX.GetPlayerFromId(source)
    if player then
        if (price) and price > 0 then
            if (player?.getAccount("bank")?.money >= price) then
                player.removeAccountMoney("bank", price)
                return true
            end
            return false
        end
    end
    return true
end
```

### buyTicket

***

This function is used to buy the tickets

```lua
-- This is an example from the brnx-cinemasystem esx.lua file

-- @param source: number
-- @param data: table (cinema:string | id:number | room:string | time:string)
-- @param filmData: table (name:string | minutes:string | img:string | synopsis:string | schedules:table | price:number)
buyTicket = function(source, data, filmData)
    if config.item.enabled then
        if tryPayment(source, filmData.price) then
            addItem(source, config.item.spawn, 1)

            setItemMeta(source, {
                room = data.room,
                schedule = data.time,
                date = os.time()
            })

            createHistoric(source, { 
                product = filmData.name, 
                price = filmData.price 
            })

            TriggerClientEvent('brnx-cinemasystem:notify', source, 'success', L('NOTIFYS.PURCHASE_TICKET', {
                name = filmData.name,
                hour = data.time,
                room = data.room,
                price = Lib.Shared.formatCurrency(filmData.price, L('CURRENCY'))
            }), 5000)
        else
            TriggerClientEvent('brnx-cinemasystem:notify', source, 'denied', L('NOTIFYS.NO_PURCHASE_TICKET'), 5000)
        end
    else
        local identifier <const> = getIdentifier(source)
        
        local hasTicket <const> = oxmysql:scalar_async(GET_TICKET_DB, { identifier, data.room, data.time })
        if not hasTicket then
            if tryPayment(source, filmData.price) then
                oxmysql:insert_async([[
                    INSERT IGNORE INTO 
                        brnx_cinema_tickets(identifier,room,schedule)
                    VALUES(?,?,?)
                ]], { identifier, data.room, data.time })

                createHistoric(source, { 
                    product = filmData.name, 
                    price = filmData.price 
                })

                TriggerClientEvent('brnx-cinemasystem:notify', source, 'success', L('NOTIFYS.PURCHASE_TICKET', {
                    name = filmData.name,
                    hour = data.time,
                    room = data.room,
                    price = Lib.Shared.formatCurrency(filmData.price, L('CURRENCY'))
                }), 5000)
            else
                TriggerClientEvent('brnx-cinemasystem:notify', source, 'denied', L('NOTIFYS.NO_PURCHASE_TICKET'), 5000)
            end
        else
            TriggerClientEvent('brnx-cinemasystem:notify', source, 'denied', L('NOTIFYS.HAS_TICKET'), 5000)
        end
    end
end
```

data:

* cinema: `string`
* id: `number`
* room: `string`
* time: `string`

filmData:

* name: `string`
* minutes: `string`
* img: `string`
* synopsis: `string`
* schedules: `table`
* price: `number`

### buyItem

***

This function is used to purchase items from the cinema store.

```lua
-- This is an example from the brnx-cinemasystem esx.lua file

-- @param source: number
-- @param itemData: table (item:string | label:string | image:string | price:number)
buyItem = function(source, itemData)
    local amount <const> = 1
    if canAddItem(source, itemData.item, amount) then
        if tryPayment(source, itemData.price) then
            addItem(source, itemData.item, amount)

            createHistoric(source, { 
                product = itemData.label, 
                price = itemData.price 
            })

            TriggerClientEvent('brnx-cinemasystem:notify', source, 'success', L('NOTIFYS.PURCHASE_ITEM', {
                name = itemData.label,
                price = Lib.Shared.formatCurrency(itemData.price, L('CURRENCY'))
            }), 5000)
        else
            TriggerClientEvent('brnx-cinemasystem:notify', source, 'denied', L('NOTIFYS.NO_PURCHASE_ITEM'), 5000)
        end
    else
        TriggerClientEvent('brnx-cinemasystem:notify', source, 'denied', L('NOTIFYS.NO_SPACE'), 5000)
    end
end
```

itemData:

* item: `string`
* label: `string`
* image: `string`
* price: `number`
