Make sure to check the qb.lua and esx.lua files for examples on how to implement the script for your framework. They are always up to date with the latest changes.
Framework functions
getIdentifier
This function is used to retrieve a player's identifier to manage and verify tickets.
-- This is an example from the brnx-cinemasystem esx.lua file--@param source: numbergetIdentifier=function(source)returnGetPlayerIdentifierByType(source, 'license')end
canAcessThePanel
This function is used to check who can access the tablet.
-- This is an example from the brnx-cinemasystem esx.lua file--@param source: numbercanAcessThePanel=function(source)locallicense<const>=GetPlayerIdentifierByType(source, 'license')ifnotlicensethenreturnfalseendlocallicenses<const>= { ['license:xxxxxxxxxxxxxxxxxxxxxxxx'] =true }returnlicenses[license]end
tryPayment
This function is used to attempt to process the payment.
buyTicket
This function is used to buy the tickets
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.
-- 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
-- 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
-- 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