Brunx
  • Home
  • Cinema System
    • Installation
    • Configuration
      • Language
      • Setting up cinema
      • Setting up store
      • Keybinds and commands
    • Frameworks
      • Client guide
      • Server guide
    • Exports and events
      • Client events
      • Server events
      • State bags
  • Ice-O-Rink System
    • Installation
    • Configuration
      • Ice Skates
      • Language
      • Setting up controls
      • Setting up wardrobe
      • Setting up peds
      • Setting up store
      • Keybinds and commands
    • Frameworks
      • Server guide
    • Inventorys
      • Server guide
      • Items
    • Exports and events
      • Server exports
      • Server events
      • State bags
Powered by GitBook
On this page
  • Framework functions
  • tryPayment
  • buyItem
  • hasTicket
  • canAcessTablet
  1. Ice-O-Rink System
  2. Frameworks

Server guide

Framework functions

tryPayment


This function is to execute a payment

-- This is an example from the brnx-iceorinksystem qb.lua file

-- @param player: number | string
-- @param value: number
local function tryPayment(player, value)
    if (value) and value >= 0 then
        if (player?.Functions.GetMoney('cash') >= value) then
            player?.Functions.RemoveMoney('cash', value, 'Ice O Rink - Store')
            return true
        else
            if (player?.Functions.GetMoney('bank') >= value) then
                player?.Functions.RemoveMoney('bank', value, 'Ice O Rink - Store')
                return true
            end
        end
    end
    return false
end

buyItem


This is the store's purchase function

-- This is an example from the brnx-iceorinksystem qb.lua file

-- @param source: number | string
-- @param data: table
buyItem = function(source, data)
    local Player = QB.Functions.GetPlayer(source)
    if (data.price) and tryPayment(Player, data.price) then
        addItem(source, data.item, 1)
        TriggerClientEvent('QBCore:Notify', source, L('SHOP.BACK_END.PURCHASE', {
            name = data.label,
            price = formatCurrency(data.price, L('CURRENCY'))
        }), 'success', 5000)
    else
        TriggerClientEvent('QBCore:Notify', source, L('SHOP.BACK_END.NO_MONEY'), 'error', 5000)
    end
end

data:

  • price: number

  • item: string

  • label: string

  • image: string

hasTicket


This function checks if you have a ticket to access the arena.

-- This is an example from the brnx-iceorinksystem qb.lua file

-- @param source: number | string
hasTicket = function(source)
    local itemAmount = getItemAmount(source, 'ticket_iceorink')
    if (itemAmount > 0) then
        return removeItem(source, 'ticket_iceorink', 1)
    end
    TriggerClientEvent('QBCore:Notify', source, L('SHOP.BACK_END.NO_TICKET'), 'error', 5000)
    return false
end

canAcessTablet


This function is used to check if the player can open the music tablet

-- This is an example from the brnx-iceorinksystem qb.lua file

-- @param source: number | string
canAcessTablet = function(source)
    return true
end
PreviousFrameworksNextInventorys

Last updated 19 days ago