Page cover

Open Files Preview

Here you can see the open files of the Tebexwrapper

config/config.lua
Config = {}
Locales = {}

Config.Framework = 'ESX'
Config.Locale = 'en'

Config.Command = 'store'
Config.CommandDescription = 'Open the Nova tebexwrapper'

-- UI Settings
Config.Title = {
    normal = "Nova",
    bold = "Tebexwrapper"
}

Config.DarkColors = {
    mainColor = "#4b0082",  -- The main color of the UI 
    hoverColor = "#4b0082", -- The hover color
    backgroundColor = "#2b243a",
    borderColor = "#241d34",
    bonusColor = "#1c3aed", -- The bonus color for coin packages
}

Config.LightColors = {
    mainColor = "#b899ff",  -- The main color of the UI 
    hoverColor = "#a78bfa", -- The hover color
    backgroundColor = "#f0e3fa",
    borderColor = "#b899ff",
    bonusColor = "#1c3aed", -- The bonus color for coin packages
}

Config.StoreManagers = {
    {
        name = "Bomba",
        identifier = "license:36921e8928e8fbd9ab13c66f79cac4e9930e8fce"
    },
    {
        name = "Nova",
        identifier = "discord:1234567890"
    }
}

Config.Coins = {
    {
        name = "10 Coins", -- Must be the same as the package name
        description = "Buy 10 coins for €1",
        coins = 10,
        image = "coins.png",
        package = "https://nova-scripting.tebex.io/",
        bonus = 0
    },
    {
        name = "50 Coins", -- Must be the same as the package name
        description = "Buy 50 coins for €5",
        coins = 50,
        image = "coins.png",
        package = "https://nova-scripting.tebex.io/",
        bonus = 10
    },
    {
        name = "100 Coins", -- Must be the same as the package name
        description = "Buy 100 coins for €10",
        coins = 100,
        image = "coins.png",
        package = "https://nova-scripting.tebex.io/",
        bonus = 10
    },
    {
        name = "200 Coins", -- Must be the same as the package name
        description = "Buy 200 coins for €20",
        coins = 200,
        image = "coins.png",
        package = "https://nova-scripting.tebex.io/",
        bonus = 10
    },
    {
        name = "500 Coins", -- Must be the same as the package name
        description = "Buy 500 coins for €50",
        coins = 500,
        image = "coins.png",
        package = "https://nova-scripting.tebex.io/",
        bonus = 10
    },
    {
        name = "1000 Coins", -- Must be the same as the package name
        description = "Buy 1000 coins for €100",
        coins = 1000,
        image = "coins.png",
        package = "https://nova-scripting.tebex.io/",
        bonus = 10 -- 10% bonus
    },  
    {
        name = "1500 Coins", -- Must be the same as the package name
        description = "Buy 1500 coins for €150",
        coins = 1500,
        image = "coins.png",
        package = "https://nova-scripting.tebex.io/",
        bonus = 10
    },  
    {
        name = "2000 Coins", -- Must be the same as the package name
        description = "Buy 2000 coins for €200",
        coins = 2000,
        image = "coins.png",
        package = "https://nova-scripting.tebex.io/",
        bonus = 10 -- 10% bonus
    },
    {
        name = "2500 Coins", -- Must be the same as the package name
        description = "Buy 2500 coins for €250",
        coins = 2500,
        image = "coins.png",
        package = "https://nova-scripting.tebex.io/",
        bonus = 10 -- 10% bonus
    },
    {
        name = "3000 Coins", -- Must be the same as the package name
        description = "Buy 3000 coins for €300",
        coins = 3000,
        image = "coins.png",
        package = "https://nova-scripting.tebex.io/",
        bonus = 20 -- 20% bonus
    },
}

Config.TestDrive = {
    {
        type = "car",
        duration = 120,
        startlocation = vector4(-2154.0898, 3229.0068, 32.8103, 145.8016),
    },
    {
        type = "boat",
        duration = 80,
        startlocation = vector4(-2827.0100, 2921.8203, 1.5734, 63.4459),
    },
    {
        type = "aircraft",
        duration = 80,
        startlocation = vector4(-1983.7316, 2844.9116, 32.8105, 57.9889),
    }
}

Config.Categories = {
    {
        id = "vehicles",
        name = "Vehicles",
        description = "Here you can find all the cars of our store",
        type = "vehicle",
        testdrive = true,
        testdrivetype = "car",
        products = {
            {
                id = "jugular",
                name = "Jugular",
                description = "A nice car",
                price = 200,
                image = "jugular.png",
                metadata = {
                    model = "jugular",
                    vehicletype = "car"
                }
            },
        }
    },
    {
        id = "boats",
        name = "Boats",
        description = "Here you can find all the boats of our store",
        type = "vehicle",
        testdrive = true,
        testdrivetype = "boat",
        products = {
            {
                id = "longfin",
                name = "Longfin",
                description = "A nice boat",
                price = 200,
                image = "longfin.png",
                metadata = {
                    model = "longfin",
                    vehicletype = "boat"
                }
            }
        }
    },
    {
        id = "weapons",
        name = "Weapons",
        description = "Buy weapons and ammunition",
        type = "weapons",
        products = {
            {
                id = "pistol",
                name = "Pistol",
                description = "A Pistol with 36 bullets",
                price = 50,
                image = "WEAPON_PISTOL.png",
                metadata = {
                    weapons = {
                        { weapon = "WEAPON_PISTOL", ammocount = 36 },
                    }
                }
            },
        }
    },
    {
        id = "items",
        name = "Items",
        description = "Buy items",
        type = "item",
        products = {
            {
                id = "repairkitpack",
                name = "Repair Kit (Pack)",
                description = "Everything you need to repair a vehicle",
                price = 10,
                image = "repairkitpack.png",
                metadata = {
                    pack = {
                        { item = "fixkit", count = 1 },
                        { item = "fixtool", count = 2 }
                    }
                }
            },
            {
                id = "bandage",
                name = "Bandage",
                description = "A bandage for your wounds",
                price = 10,
                image = "bandage.png",
                metadata = {
                    item = "bandage",
                    count = 1
                }
            }
        }
    },
    {
        id = "money",
        name = "Money",
        description = "Buy some cash!",
        type = "money",
        products = {
            {
                id = "1mil",
                name = "1 million dollars",
                description = "Pocket money",
                price = 10,
                image = "money.png",
                metadata = {
                    amount = 1000000
                }
            }
        }
    },
} 
config/webhook.lua
Webhook = {
    tebexPackagePurchase = "https://discord.com/api/webhooks/",
    Purchase = "https://discord.com/api/webhooks/",
    AdminActions = "https://discord.com/api/webhooks/",
    ClaimTransaction = "https://discord.com/api/webhooks/"
client/utils.lua
StoreNotify = function(message)
    lib.notify({
        title = 'Store',
        description = message,
        duration = 3000,
        position = 'top-right',
        style = {
            backgroundColor = '#141517',
            color = '#C1C2C5',
            ['.description'] = {
                color = '#909296'
            }
        },
        icon = 'fas fa-store',
        iconColor = '#ffa500'
    })
end
server/utils.lua
StoreNotify = function(src, message)
    TriggerClientEvent('ox_lib:notify', src, {
        title = 'Store',
        description = message,
        duration = 3000,
        position = 'top-right',
        style = {
            backgroundColor = '#141517',
            color = '#C1C2C5',
            ['.description'] = {
                color = '#909296'
            }
        },
        icon = 'fas fa-store',
        iconColor = '#ffa500'
    })
end

function GeneratePlate()
    local plate = ""
    for i = 1, 8 do
        if i <= 2 or i >= 7 then
            plate = plate .. string.char(math.random(65, 90)) -- A-Z
        else
            plate = plate .. math.random(0, 9)
        end
    end
    return plate
end

SendToDiscord = function(webhook, title, msg, color)
    local connect = {
        ["color"] = color,
        ["title"] = title,
        ["description"] = msg,
        ["footer"] = {
            ["text"] = "nv-tebexwrapper",
            ["icon_url"] = "https://media.discordapp.net/attachments/1386108052645740584/1387448603416465588/nova_logo_nobg.png?ex=68693f34&is=6867edb4&hm=29e0f07fc2858fc6ed64fbe2d67178ac81a0469df796f4a131df7a4894b5c087&=&format=webp&quality=lossless"
        }
    }
    PerformHttpRequest(webhook, function() end, 'POST', json.encode({
        username = "Nova Scripts",
        avatar_url = "https://media.discordapp.net/attachments/1386108052645740584/1387448603416465588/nova_logo_nobg.png?ex=68693f34&is=6867edb4&hm=29e0f07fc2858fc6ed64fbe2d67178ac81a0469df796f4a131df7a4894b5c087&=&format=webp&quality=lossless",
        embeds = { connect }
    }), { ['Content-Type'] = 'application/json' })
end
server/types.lua
RegisterProductType("vehicle", function(source, product)
    local model = product.metadata.model
    local type = product.metadata.vehicletype or "car"
    local Player = GETPFI(source)

    local citizenid = Player.PlayerData.citizenid
   local identifier = GetIdentifierFunction(source)
    local plate = GeneratePlate()
    local vehicle = model
    local hash = GetHashKey(vehicle)
    local mods = '{}'
    local garage = 'pillboxgarage'
    local state = 1

    MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, garage, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
        license,
        citizenid,
        vehicle,
        hash,
        mods,
        plate,
        garage,
        state
    })

    SendToDiscord(Webhook.Purchase, 'Vehicle Bought', ('**%s** has bought a **%s**!\n PlayerID: **%s**\nLicense: %s\n Plate: **%s**\n Vehicle Type: **%s**\n Vehicle Model: **%s**'):format(GetPlayerName(source), product.name, source, identifier, plate, type, model), 0x00ff00)
    StoreNotify(source, (locale.package_purchase_notify):format(product.name))
end)

RegisterProductType("weapons", function(source, product)
    local weapons = product.metadata.weapons
    local Player = GETPFI(source)
    local identifier = GetIdentifierFunction(source)
    
    for _, item in pairs(weapons) do
        AddWeapon(source, item.weapon, item.ammocount)
    end
    
    SendToDiscord(Webhook.Purchase, 'Weapons Bought', ('**%s** has bought a **%s**!\n PlayerID: **%s**\nLicense: %s\n Weapons: **%s**'):format(GetPlayerName(source), product.name, source, identifier, json.encode(weapons)), 0x00ff00)
    StoreNotify(source, (locale.package_purchase_notify):format(product.name))
end)

RegisterProductType("item", function(source, product)
    local items = product.metadata.pack or { { item = product.metadata.item, count = product.metadata.count or 1 } }
    local Player = GETPFI(source)
    local identifier = GetIdentifierFunction(source)
    
    for _, entry in pairs(items) do
        AddItem(source, entry.item, entry.count or 1)
    end

    SendToDiscord(Webhook.Purchase, 'Item Bought', ('**%s** has bought a **%s**!\n PlayerID: **%s**\nLicense: %s\n Items: **%s**'):format(GetPlayerName(source), product.name, source, identifier, json.encode(items)), 0x00ff00)
    StoreNotify(source, (locale.package_purchase_notify):format(product.name))
end)

RegisterProductType("money", function(source, product)
    local amount = product.metadata.amount
    local Player = GETPFI(source)
    local identifier = GetIdentifierFunction(source)
    
    AddMoneyFunction(source, amount)
    
    SendToDiscord(Webhook.Purchase, 'Money Bought', ('**%s** has bought a **%s**!\n PlayerID: **%s**\nLicense: %s\n Amount: **%s**'):format(GetPlayerName(source), product.name, source, identifier, amount), 0x00ff00)
    StoreNotify(source, (locale.package_purchase_notify):format(product.name))
end)
framework/server-framework.lua
Core = nil

if Config['Framework']:upper() == 'ESX' then

    Core = exports['es_extended']:getSharedObject()

    RESCB = Core.RegisterServerCallback
    GETPFI = Core.GetPlayerFromId
    RUI = Core.RegisterUsableItem

    function GetPlayersFunction()
        return Core.GetPlayers()
    end

    function AddMoneyFunction(source, amount)
        local xPlayer = GETPFI(source)
        xPlayer.addAccountMoney('bank', amount)
    end

    function GetPlayerJobFunction(source)
        local xPlayer = GETPFI(source)
        PlayerJob = xPlayer.job.name
        return PlayerJob
    end

    function GetItemCount(source, item)
        local xPlayer = GETPFI(source)
        return xPlayer.getInventoryItem(item).count
    end
    function AddWeapon(source, weaponName, ammo)
        local xPlayer = GETPFI(source)
        xPlayer.addWeapon(weaponName, ammo)
    end

    function AddItem(source, item, count)
        local xPlayer = GETPFI(source)
        xPlayer.addInventoryItem(item, count)
    end

    function RemoveItem(source, item, amount)
        local xPlayer = GETPFI(source)
        xPlayer.removeInventoryItem(item, amount)
    end

    function GetIdentifierFunction(source)
        local xPlayer = GETPFI(source)
        return xPlayer.identifier
    end

elseif Config['Framework']:upper() == 'QBCORE' then

    Core = exports['qb-core']:GetCoreObject()
    
    RESCB = Core.Functions.CreateCallback
    GETPFI = Core.Functions.GetPlayer
    RUI = Core.Functions.CreateUseableItem

    function GetPlayersFunction()
        return Core.Functions.GetPlayers()
    end

    function AddMoneyFunction(source, amount)
        local xPlayer = GETPFI(source)
        xPlayer.Functions.AddMoney('bank', amount)
    end

    function GetPlayerJobFunction(source)
        local xPlayer = GETPFI(source)
        PlayerJob = xPlayer.PlayerData.job.name
        return PlayerJob
    end

    function GetItemCount(source, item)
        local xPlayer = GETPFI(source)

        local items = xPlayer.Functions.GetItemByName(item)
        local item_count = 0
        if items ~= nil then
            item_count = items.amount
        else
            item_count = 0
        end
        return item_count
    end

    function AddWeapon(source, weaponName, ammo)
        local xPlayer = GETPFI(source)
        xPlayer.Functions.AddItem(weaponName, ammo)
    end

    function AddItem(source, item, count)
        local xPlayer = GETPFI(source)
        xPlayer.Functions.AddItem(item, count)
    end

    function RemoveItem(source, item, amount)
        local xPlayer = GETPFI(source)
        xPlayer.Functions.RemoveItem(item, amount)
    end

    function GetIdentifierFunction(source)
        local xPlayer = GETPFI(source)
        return xPlayer.PlayerData.license
    end
end

Last updated