ElixirFW
ElixirFW
  • Getting Started
    • ElixirFW Documentation
    • FiveM Escrow System
  • ElixirFW Resources
    • Vending Machines
      • Installation
      • Configuration
  • Origen V2
    • Installation
  • Origen V2.5 (Coming Soon)
    • Jobs
      • Public Jobs
        • og-lumberjack
        • og_cityworker
      • CityHall Jobs
        • og_taxijob
        • og-electrical
Powered by GitBook
On this page
  • config.lua
  • open_client.lua
  • open_server.lua

Was this helpful?

  1. ElixirFW Resources
  2. Vending Machines

Configuration

config.lua

Config = {}
--  ███╗   ███╗ █████╗  ██████╗██╗  ██╗██╗███╗   ██╗███████╗███████╗
--  ████╗ ████║██╔══██╗██╔════╝██║  ██║██║████╗  ██║██╔════╝██╔════╝
--  ██╔████╔██║███████║██║     ███████║██║██╔██╗ ██║█████╗  ███████╗
--  ██║╚██╔╝██║██╔══██║██║     ██╔══██║██║██║╚██╗██║██╔══╝  ╚════██║
--  ██║ ╚═╝ ██║██║  ██║╚██████╗██║  ██║██║██║ ╚████║███████╗███████║
--  ╚═╝     ╚═╝╚═╝  ╚═╝ ╚═════╝╚═╝  ╚═╝╚═╝╚═╝  ╚═══╝╚══════╝╚══════╝
--                                                                  
-- =================================================================
Config.Framework = "qb" -- qb or esx, if qb it will use QBCore Functions for player data and use citizenID, if esx it will blow up.


Config.MenuLibrary = 'ox_lib' -- options: 'qb-menu', 'ox_lib'
Config.InputLibrary = 'ox_lib' -- options: 'qb-input', 'ox_lib'
Config.SNotificationType = "ox" -- Can be "qb", "ox", or "custom" (Server Side, Editable in 'open_server.lua' Line: 3)
Config.CNotificationLibrary = 'ox' -- Can be "qb", "ox", or "custom" (Client Side, Editable in 'open_client.lua' Line: 77)
Config.ProgressbarType = "ox" -- Can be "qb", "ox", or "custom"
Config.DrawTextType = "ox" -- Options: "qb", "ox", "custom"
Config.TargetSystem = "qb-target" -- DON'T TOUCH IT Even you if you use ox_target, (Already has a Compat (auto converting the qb-target exports!)) 
Config.UseOxInventory = true

Config.ElectricityConsumption = 5 -- Max electricity = 100, amount is removed per hour (irl hour)
Config.MaxStock = 5 -- Max stock, lets you change how many types of items one vending machine can have
Config.TaxPercentage = 7 -- Percentage the server takes as tax from each payment (0 = none)
Config.MaxMachines = 1 -- Max number of machines per player
Config.ForceCarry = true -- Player will hold the machine in their hands
Config.VendingItem = 'vending_machine' -- Vending Machine Item

Config.RequireItem = true -- Require item to move the vending machine?
Config.RemoveItem = 'vending_remover' -- Item to move the machine
Config.RemoveTime = 5000 -- MS (1000 = 1 sec)

Config.ElectricityBill = 100 -- how much should rechargin from 0 to 100 be, it is then multiplied by the current electricity for the price from any point.


Config.MaxStock = 50 -- how many items can a vending machine have of one item.
-- =================================================================
Config.MachineLoading = 10000 -- do not touch

Config.ItemPrices = {
    ["sandwich"] = 10, -- "itemname" = price
}

open_client.lua

local QBCore = exports['qb-core']:GetCoreObject()

function startProgressBar(label, duration, onSuccess)
    if Config.ProgressbarType == "qb" then
        QBCore.Functions.Progressbar("doing_shit", label, duration, false, true, {
            disableMovement = true,
            disableCarMovement = true,
            disableMouse = true,
            disableCombat = true,
         }, {}, {}, {}, function()
            onSuccess()
         end, function()
            ClearPedTasks(PlayerPedId())
         end)
    elseif Config.ProgressbarType == "ox" then
        if lib.progressBar({
            duration = duration,
            label = label,
            useWhileDead = false,
            canCancel = false,
            disable = {
                car = true,
                combat = true,
                mouse = true,
                move = true,
            },
        }) then
            onSuccess()
        else
            ClearPedTasks(PlayerPedId())
        end
    elseif Config.ProgressbarType == "custom" then
        -- Replace with your custom progress bar function
        CustomProgressbar({
            duration = duration,
            label = label,
            onCancel = function()
                ClearPedTasks(PlayerPedId())
            end,
            onFinish = function()
                onSuccess()
            end,
        })
    end
end

-- Example Custom Progress Bar function (You need to implement this)
function CustomProgressbar(options)
    -- Your custom progress bar logic here
    -- Call options.onFinish() when done
    -- Call options.onCancel() if cancelled
end

function drawText(text)
    if Config.DrawTextType == "qb" then
        exports['qb-core']:DrawText(text, 'right')
    elseif Config.DrawTextType == "ox" then
        lib.showTextUI(text)
    elseif Config.DrawTextType == "custom" then
        -- Replace with your custom draw text function
        CustomDrawText(text)
    end
end

function hideText()
    if Config.DrawTextType == "qb" then
        exports['qb-core']:HideText()
    elseif Config.DrawTextType == "ox" then
        lib.hideTextUI()
    elseif Config.DrawTextType == "custom" then
        -- Replace with your custom hide text function
        CustomHideText()
    end
end

function notify(message, type)
    if Config.CNotificationLibrary == 'qb' then
        QBCore.Functions.Notify(message, type)
    elseif Config.CNotificationLibrary == 'ox' then
        local notifyType = "inform" -- Default type for `ox_lib`

        if type == "success" then
            notifyType = "success"
        elseif type == "error" then
            notifyType = "error"
        elseif type == "info" then
            notifyType = "inform"
        end
        lib.notify({ description = message, type = notifyType })
    elseif Config.CNotificationLibrary == 'custom' then
        -- Replace with your custom notification logic
        TriggerEvent('custom:notify', message, type)
    end
end

open_server.lua

local QBCore = exports['qb-core']:GetCoreObject()

function sendNotification(src, message, type)
    if Config.SNotificationType == "qb" then
        TriggerClientEvent('QBCore:Notify', src, message, type, 5000)
    elseif Config.SNotificationType == "ox" then
        local notifyType = "inform" -- Default type for `ox_lib`

        if type == "success" then
            notifyType = "success"
        elseif type == "error" then
            notifyType = "error"
        elseif type == "info" then
            notifyType = "inform"
        end

        -- Adjusted ox_lib notify trigger
        TriggerClientEvent('ox_lib:notify', src, {
            title = "Notification", -- Optional: can be removed or customized
            description = message,
            type = notifyType,
            duration = 5000, -- Optional: customize duration if needed
            position = 'top-right' -- Optional: customize position if needed
        })
    elseif Config.SNotificationType == "custom" then
        -- Replace with your custom notification function
        CustomNotify(src, message, type)
    end
end

-- Example Custom Notification function (You need to implement this)
function CustomNotify(src, message, type)
    -- Your custom notification logic here
end
PreviousInstallationNextInstallation

Last updated 9 months ago

Was this helpful?