Newer
Older
TFC-BurgerShot / client / shop.lua
local QBCore = exports['qb-core']:GetCoreObject()
lib.registerContext({
    id = 'bs_shop',
    title = 'Shop',
    options = {
        {
            title = 'Bread',
            description = '$100',
            event = 'tfc-bs-job:client:buymenu',
            arrow = true,
            args = {
                item = "bread",
                label = "Bread",
                price = 100,
            }
        },
        {
            title = 'Cheddar',
            description = '$100',
            event = 'tfc-bs-job:client:buymenu',
            arrow = true,
            args = {
                item = "cheddar",
                label = "Cheddar",
                price = 100,
            }
        },
        {
            title = 'Fruits & Veg',
            icon = 'fas fa-apple-whole',
            menu = 'bs_shop_fruits_veg',
            arrow = true,
        },
        {
            title = 'Meat',
            icon = 'fas fa-drumstick-bite',
            menu = 'bs_shop_meat',
            arrow = true,
        }

    }
})
lib.registerContext({
    id = 'bs_shop_fruits_veg',
    title = 'Shop',
    options = {
        {
            title = 'Tomato',
            description = '$100',
            event = 'tfc-bs-job:client:buymenu',
            arrow = true,
            args = {
                item = "tomato",
                label = "Tomato",
                price = 100,
            }
        },
        {
            title = 'Broccoli',
            description = '$100',
            event = 'tfc-bs-job:client:buymenu',
            arrow = true,
            args = {
                item = "broccoli",
                label = "Broccoli",
                price = 100,
            }
        },
        {
            title = 'Onion',
            description = '$100',
            event = 'tfc-bs-job:client:buymenu',
            arrow = true,
            args = {
                item = "onion",
                label = "Onion",
                price = 100,
            }
        },
        {
            title = 'Potato',
            description = '$100',
            event = 'tfc-bs-job:client:buymenu',
            arrow = true,
            args = {
                item = "potato",
                label = "Potato",
                price = 100,
            }
        },
        {
            title = 'Pickle',
            description = '$100',
            event = 'tfc-bs-job:client:buymenu',
            arrow = true,
            args = {
                item = "pickle",
                label = "Pickle",
                price = 100,
            }
        },
        {
            title = 'Back',
            icon = 'fas fa-backward',
            menu = 'bs_shop',
            arrow = false
        }
    }
})
lib.registerContext({
    id = 'bs_shop_meat',
    title = 'Shop',
    options = {
        {
            title = 'Pig Meat',
            description = '$100',
            event = 'tfc-bs-job:client:buymenu',
            arrow = true,
            args = {
                item = "meat_pig",
                label = "Pig Meat",
                price = 100,
            }
        },
        {
            title = 'Beef',
            description = '$100',
            event = 'tfc-bs-job:client:buymenu',
            arrow = true,
            args = {
                item = "meat_cow",
                label = "Beef",
                price = 100,
            }
        },
        {
            title = 'Back',
            icon = 'fas fa-backward',
            menu = 'bs_shop',
            arrow = false
        }
    }
})
RegisterNetEvent('tfc-bs-job:client:buymenu', function(args)
    lib.registerContext({
        id = 'bs_payment',
        title = 'Payment for '..args.label,
        options = {
            {
            title = 'You Owe $'..args.price,
            readOnly = true
            },
            {
            title = 'Cash',
            serverEvent = 'tfc-bs-job:server:buy',
            args = {
                item = args.item,
                price = args.price,
                label = args.label,
                payment = "cash"
                }
            },
            {
            title = 'Bank',
            serverEvent = 'tfc-bs-job:server:buy',
            args = {
                item = args.item,
                price = args.price,
                label = args.label,
                payment = "bank"
                }
            },
            {
                title = 'Back',
                icon = 'fas fa-backward',
                menu = 'bs_shop',
                arrow = false
              }
        }
    })
    lib.showContext('bs_payment')
end)

RegisterNetEvent('tfc-bs-job:client:buyfinished', function()
    QBCore.Functions.Notify('Purchase Successful', 'success')
    lib.showContext('bs_shop')
end)

RegisterNetEvent('tfc-bs-job:client:buyfailed', function()
    QBCore.Functions.Notify('You need more money', 'error', 5000)
end)