A comprehensive vapeshop system for QBCore with business management, stock tracking, and automated sales. Thanks chatgpt for this documentation and the exports ya dog.
- Business Management: Purchase and manage your own vapeshop
- Stock System: Track vape inventory with visual NUI dashboard
- Automated Sales: Random NPC sales generate passive income
- Business Balance: Separate business funds from personal money
- Purchase Cooldowns: Prevent spam purchasing
- Configurable Settings: Easy customization through config file
- Export System: API for other scripts to interact with vapeshops
- Place the
vd-vapeshopfolder in yourresourcesdirectory - Add
ensure vd-vapeshopto yourserver.cfg - Configure settings in
config.lua - Restart your server
config.ShopPrice = 50000 -- Initial vapeshop purchase price
config.Currency = "cash" -- Currency for initial purchase (cash/bank)
config.StartingBalance = 33 -- Starting business balance for new shops
config.MaxBusinessBalance = 999999999 -- Maximum business balance (prevents overflow)config.PurchaseCooldown = 30 -- Seconds between vape shipment purchasesconfig.SalesCheckInterval = 30000 -- How often to check for sales (milliseconds)
config.SalesChance = 6 -- 1 in X chance for a sale each check
config.MinSaleQuantity = 1 -- Minimum vapes sold per sale
config.MaxSaleQuantity = 3 -- Maximum vapes sold per saleconfig.Blip = {
label = "Vapeshop Business",
sprite = 140,
colour = 3,
scale = 1.0,
location = vector3(416.6877, -217.5833, 59.9104)
}The script includes 6 different vape types:
config.Vapes = {
{
name = "Basic Vape",
price = 650,
shipment = { vapecount = 15, price = 7500 }
},
{
name = "Mint Breeze Vape",
price = 700,
shipment = { vapecount = 20, price = 14000 }
},
{
name = "Blueberry Chill Vape",
price = 850,
shipment = { vapecount = 18, price = 16000 }
},
{
name = "Mango Burst Vape",
price = 950,
shipment = { vapecount = 22, price = 20000 }
},
{
name = "Watermelon Ice Vape",
price = 1100,
shipment = { vapecount = 25, price = 24000 }
},
{
name = "Premium Gold Vape",
price = 1500,
shipment = { vapecount = 30, price = 42000 }
}
}- Purchase a Vapeshop: Go to the vapeshop location and interact with "Purchase"
- Manage Your Shop: Use "Manage Shop" to open the dashboard
- Buy Shipments: Purchase vape shipments using your business balance
- Monitor Sales: Watch your stock and balance grow from automated sales
- Withdraw/Deposit: Manage money between personal and business accounts
The script provides a comprehensive export system for other scripts to interact with vapeshops.
- Description: Check if a player owns a vapeshop
- Parameters:
source(number) - Player source ID - Returns:
boolean- True if player owns a vapeshop
- Description: Get a player's vapeshop business balance
- Parameters:
source(number) - Player source ID - Returns:
number- Business balance amount
- Description: Add money to a player's vapeshop business balance
- Parameters:
source(number),amount(number) - Returns:
boolean- Success status
- Description: Remove money from a player's vapeshop business balance
- Parameters:
source(number),amount(number) - Returns:
boolean- Success status
- Description: Set a player's vapeshop business balance to a specific amount
- Parameters:
source(number),amount(number) - Returns:
boolean- Success status
- Description: Get a player's vapeshop stock data
- Parameters:
source(number) - Player source ID - Returns:
table- Stock data with vape names and quantities
- Description: Add vapes to a player's vapeshop stock
- Parameters:
source(number),vapeName(string),quantity(number) - Returns:
boolean- Success status
- Description: Remove vapes from a player's vapeshop stock
- Parameters:
source(number),vapeName(string),quantity(number) - Returns:
boolean- Success status
- Description: Get vape configuration by name
- Parameters:
vapeName(string) - Name of the vape - Returns:
table- Vape configuration or nil if not found
- Description: Get all vape configurations
- Returns:
table- All vape configurations
- Description: Check if a player can afford a vapeshop
- Parameters:
source(number) - Player source ID - Returns:
boolean- True if player can afford it
- Description: Purchase a vapeshop for a player (bypasses normal purchase flow)
- Parameters:
source(number) - Player source ID - Returns:
boolean, string- Success status and message
- Description: Get vapeshop statistics for a player
- Parameters:
source(number) - Player source ID - Returns:
table- Statistics including balance, stock count, total value
- Description: Force a random sale for a player's vapeshop
- Parameters:
source(number) - Player source ID - Returns:
boolean, string- Success status and message
- Description: Get all vapeshop owners (for admin purposes)
- Returns:
table- List of citizenids who own vapeshops
- Description: Get vapeshop data by citizenid (for admin purposes)
- Parameters:
citizenid(string) - Citizen ID - Returns:
table- Vapeshop data or nil
-- Add 5 Basic Vapes to player's stock
local success = exports['vd-vapeshop']:AddVapeshopStock(source, "Basic Vape", 5)
-- Remove 2 Premium Gold Vapes from player's stock
local success = exports['vd-vapeshop']:RemoveVapeshopStock(source, "Premium Gold Vape", 2)-- Add $1000 to player's business balance
local success = exports['vd-vapeshop']:AddVapeshopBalance(source, 1000)
-- Check if player has enough balance
local balance = exports['vd-vapeshop']:GetVapeshopBalance(source)
if balance >= 5000 then
-- Player has enough money
end-- Get all vapeshop owners
local owners = exports['vd-vapeshop']:GetAllVapeshopOwners()
-- Get specific player's vapeshop data
local vapeshopData = exports['vd-vapeshop']:GetVapeshopByCitizenId("ABC12345")
-- Force a sale for a player
local success, message = exports['vd-vapeshop']:ForceRandomSale(source)-- Get comprehensive stats for a player
local stats = exports['vd-vapeshop']:GetVapeshopStats(source)
if stats then
print("Balance: $" .. stats.balance)
print("Total Stock: " .. stats.totalStock)
print("Total Value: $" .. stats.totalValue)
endqb-coreox_libox_targetoxmysql
The script automatically creates a vd_vapeshop table with the following structure:
citizenid(VARCHAR) - Player's citizen IDbalance(INT) - Business balancestock_data(TEXT) - JSON encoded stock data
- All exports return
falseornilif the player doesn't own a vapeshop (where applicable) - Stock operations automatically update the database
- Balance operations include validation to prevent negative balances
- All exports are server-side only
- Make sure to handle errors appropriately in your scripts
For issues or questions, please check the configuration and ensure all dependencies are properly installed.