01配置
快速安装 · config.lua · Agency-Vending
--[[
╔══════════════════════════════════════════════════════════════════════╗
║ AGENCY VENDING - CONFIGURATION ║
║ (c) Agency Scripts ║
╚══════════════════════════════════════════════════════════════════════╝
CONTENTS
1. Agency Companion
2. Agency Integrations
3. Language / Locale
4. Framework
5. Interaction
6. Payment
7. Player-Owned Machines
8. Discord Webhook
9. Admin Spawner
10. Seizing Player-Owned Machines
11. Machine Types
12. Custom Locations
Discord: https://discord.gg/RTax3aBMUs · Shop: https://shop.agencyg.de
]]
Config = {}
--==============================================================================
-- 1 · AGENCY COMPANION
--==============================================================================
-- Agency-Companion (free): https://shop.agencyg.de/en/product/agency-companion
-- One resource for every Agency script: your players link them with the free
-- Agency Companion app (iPhone, Android, web), and your admins pick one accent
-- colour for all Agency scripts in game (/app, admin page). Drop it into your
-- resources and this script follows it by itself. Nothing else to set up.
Config.Companion = {
Enabled = true, -- connect with Agency-Companion (app tips + accent colour)
}
-- ── Accent colour ────────────────────────────────────────────────────────────
-- false = the colour from Agency-Companion, gold without it
-- { r,g,b } = a fixed colour for this script only, e.g. { 0, 190, 255 }
Config.AccentColor = false
-- true = every machine type keeps its own colour from section 11 (color / colorAccent)
-- false = the machines use the accent colour above (Agency look)
Config.UseMachineColors = false
--==============================================================================
-- 2 · AGENCY INTEGRATIONS
--==============================================================================
-- Used by themselves when they run (on their own or inside Agency-Essentials),
-- the script's own notification / progress bar otherwise.
-- Agency-Notify (free): https://agency-script.tebex.io/package/6937769
-- Agency-Progressbar (free): https://agency-script.tebex.io/package/7000468
Config.Integrations = {
AgencyNotify = true, -- false = never use Agency-Notify
AgencyProgressbar = true, -- false = never use Agency-Progressbar
}
--==============================================================================
-- 3 · LANGUAGE / LOCALE
--==============================================================================
-- en bg cs da de el es fi fr hr hu it ja ko nb nl pl pt ro ru sk sv tr uk zh (also 'esm')
Config.Locale = 'en'
-- Older list:
-- 'en' English 'de' Deutsch 'fr' Français
-- 'esm' Español 'it' Italiano 'nl' Nederlands
-- 'pl' Polski 'pt' Português 'ro' Română
-- 'ru' Русский 'sv' Svenska 'tr' Türkçe
-- 'cs' Čeština
--==============================================================================
-- 4 · FRAMEWORK
--==============================================================================
Config.Framework = 'auto'
-- 'auto' Automatically detects whether ESX or QBCore is present
-- 'esx' Force ESX
-- 'qb' Force QBCore
-- 'standalone' No framework (custom money logic)
Config.StandaloneMoneyAccount = 'money'
-- Only relevant if no framework is detected
-- 'money' Cash
-- 'bank' Bank account
--==============================================================================
-- 5 · INTERACTION
--==============================================================================
Config.InteractionDistance = 2.0 -- Distance to the machine (in meters)
Config.UseAnimation = true -- Play purchase animation?
Config.UIPosition = 'center' -- UI position: 'center', 'left', 'right'
Config.Notification = 'agency' -- Notifications: 'agency' (Agency-Notify, see section 2, framework without it), 'default', 'ox', 'custom'
-- Target System
Config.UseTarget = false -- true = ox_target/qb-target, false = 3D text + E key
Config.TargetResource = 'auto' -- 'auto', 'ox_target' or 'qb-target'
--==============================================================================
-- 6 · PAYMENT
--==============================================================================
Config.PaymentMethods = {
cash = true, -- Insert cash (credit system)
card = true, -- AgencyPay / Card payment (bank)
}
Config.CardFee = 0 -- Card fee in % (e.g. 5 = 5% surcharge)
Config.DepositAmounts = { 1, 5, 10, 20 } -- Deposit amounts in the UI
--==============================================================================
-- 7 · PLAYER-OWNED MACHINES
--==============================================================================
--
-- Ownership Mode:
-- 'hybrid' State machines usable AND purchasable (default)
-- 'restricted' All machines must be purchased first
-- 'none' State-owned only, no player ownership
--
-- ⚠️ WARNING: Switching to 'none' DELETES ALL player-owned machines
-- from the database! Purchase prices are automatically refunded.
-- This action CANNOT be undone!
Config.OwnershipMode = 'hybrid'
-- Purchase prices per machine type
Config.MachinePurchasePrices = {
['drinks'] = 5000,
['coffee'] = 6000,
['snacks'] = 5500,
['water'] = 3000,
}
Config.MaxMachinesPerPlayer = 5 -- Max. machines per player
Config.MaxStockPerSlot = 50 -- Max. stock per item slot
Config.ManagementDistance = 2.0 -- Distance for management menu
-- Price adjustment by owner
Config.AllowPriceChange = true
Config.MinPricePercent = 50 -- Min. 50% of default price
Config.MaxPricePercent = 200 -- Max. 200% of default price
-- Automatic profit payout
Config.AutoPayoutInterval = 60 -- In minutes (0 = disabled, manual only)
--==============================================================================
-- 8 · DISCORD WEBHOOK
--==============================================================================
--
-- Logs machine purchases (player buy + admin spawn) to Discord.
-- Leave WebhookURL empty ('') to disable logging.
Config.WebhookURL = '' -- Discord Webhook URL (e.g. 'https://discord.com/api/webhooks/...')
Config.WebhookBotName = '' -- Bot display name
Config.WebhookBotAvatar = '' -- Bot avatar URL (leave empty for default)
--==============================================================================
-- 9 · ADMIN SPAWNER
--==============================================================================
--
-- Who can use the Vending Spawner?
-- 'everyone' Every player (⚠️ Not recommended!)
-- 'ace' Only with ACE permission (see AdminAce)
-- 'group' Only specific admin groups (see AdminGroups)
Config.AdminPermission = 'group'
Config.AdminAce = 'agency-vending.admin'
Config.AdminGroups = { 'admin', 'superadmin', 'god' }
Config.AdminCommand = 'vendingadmin'
-- Opens the admin panel: place machines + manage player-owned machines
-- (previously 'vendingspawn' - an old Config.SpawnerCommand is still respected)
Config.PlacementMaxDistance = 50.0 -- Max. distance when placing
Config.PlacementSnapToGround = true -- Automatically snap to ground
--==============================================================================
-- 10 · SEIZING PLAYER-OWNED MACHINES
--==============================================================================
--
-- Admins can take machines away from players in the admin panel
-- ("Player Machines" tab). The prop stays in the world, only the
-- ownership is revoked - the machine becomes a normal state machine.
--
-- What does the owner get back?
-- 'none' Nothing - purchase price and earnings are forfeited (default)
-- 'earnings' Only the uncollected earnings of the machine
-- 'full' Earnings + half the purchase price (same as a normal sale)
Config.AdminRemoveRefund = 'none'
Config.AdminRemoveNotifyOwner = true -- Notify the owner if they are online
--==============================================================================
-- 11 · MACHINE TYPES
--==============================================================================
-- All machine types with their products are defined here.
-- Each type has:
-- label Display name in the UI
-- icon Emoji for the UI
-- color Primary color (HEX)
-- colorAccent Accent color (HEX)
-- models GTA V prop models (as hash)
-- items Products with slot, name, item, price, image
--
-- Slot system: Letter = row, Number = column
-- (e.g. A1, A2, B1, B2, C1...)
--
-- Image: Filename without extension from html/images/
Config.MachineTypes = {
-- ╔══════════════════════════════════════╗
-- ║ SODA MACHINE ║
-- ╚══════════════════════════════════════╝
['drinks'] = {
label = 'Soda Machine',
icon = '🥤',
color = '#e74c3c',
colorAccent = '#c0392b',
models = {
GetHashKey('prop_vend_soda_01'),
GetHashKey('prop_vend_soda_02'),
},
items = {
-- Slot Label Item Name Price Image
{ slot = 'A1', label = 'Cola', item = 'cola', price = 3, image = 'cola' },
{ slot = 'A2', label = 'Sprunk', item = 'sprunk', price = 3, image = 'sprunk' },
{ slot = 'A3', label = 'eCola', item = 'ecola', price = 3, image = 'ecola' },
{ slot = 'B1', label = 'Orange Juice', item = 'orange_juice', price = 4, image = 'orange_juice' },
{ slot = 'B2', label = 'Energy Drink', item = 'energy_drink', price = 5, image = 'energy_drink' },
{ slot = 'B3', label = 'Water', item = 'water', price = 2, image = 'water' },
},
},
-- ╔══════════════════════════════════════╗
-- ║ COFFEE MACHINE ║
-- ╚══════════════════════════════════════╝
['coffee'] = {
label = 'Coffee Machine',
icon = '☕',
color = '#8B4513',
colorAccent = '#6B3410',
models = {
GetHashKey('prop_vend_coffe_01'),
},
items = {
{ slot = 'A1', label = 'Espresso', item = 'espresso', price = 4, image = 'espresso' },
{ slot = 'A2', label = 'Cappuccino', item = 'cappuccino', price = 5, image = 'cappuccino' },
{ slot = 'A3', label = 'Latte Macchiato', item = 'latte', price = 5, image = 'latte' },
{ slot = 'B1', label = 'Americano', item = 'americano', price = 4, image = 'americano' },
{ slot = 'B2', label = 'Hot Chocolate', item = 'hot_choco', price = 4, image = 'hot_choco' },
{ slot = 'B3', label = 'Tea', item = 'tea', price = 3, image = 'tea' },
},
},
-- ╔══════════════════════════════════════╗
-- ║ SNACK MACHINE ║
-- ╚══════════════════════════════════════╝
['snacks'] = {
label = 'Snack Machine',
icon = '🍫',
color = '#e67e22',
colorAccent = '#d35400',
models = {
GetHashKey('prop_vend_fridge01'),
GetHashKey('prop_vend_snak_01'),
GetHashKey('prop_vend_snak_01_tu'),
},
items = {
{ slot = 'A1', label = 'Chocolate Bar', item = 'chocolate_bar', price = 3, image = 'chocolate_bar' },
{ slot = 'A2', label = 'Chips', item = 'chips', price = 3, image = 'chips' },
{ slot = 'A3', label = 'Cookies', item = 'cookies', price = 3, image = 'cookies' },
{ slot = 'B1', label = 'Sandwich', item = 'sandwich', price = 5, image = 'sandwich' },
{ slot = 'B2', label = 'Donut', item = 'donut', price = 4, image = 'donut' },
{ slot = 'B3', label = 'Granola Bar', item = 'granola_bar', price = 4, image = 'granola_bar' },
},
},
-- ╔══════════════════════════════════════╗
-- ║ WATER COOLER ║
-- ╚══════════════════════════════════════╝
['water'] = {
label = 'Water Cooler',
icon = '💧',
color = '#3498db',
colorAccent = '#2980b9',
models = {
GetHashKey('prop_watercooler'),
GetHashKey('prop_watercooler_dark'),
},
items = {
{ slot = 'A1', label = 'Water (Cold)', item = 'water_cold', price = 1, image = 'water_cold' },
{ slot = 'A2', label = 'Water (Regular)', item = 'water', price = 1, image = 'water' },
{ slot = 'A3', label = 'Sparkling Water', item = 'sparkling', price = 2, image = 'sparkling' },
},
},
}
--==============================================================================
-- 12 · CUSTOM LOCATIONS
--==============================================================================
-- Optional
-- Force machines at fixed positions.
-- These exist in addition to the default GTA props.
Config.CustomLocations = {
-- Example:
-- { coords = vector3(25.7, -1347.3, 29.5), type = 'drinks', heading = 270.0 },
}
02SQL 文件
在启动资源之前,将此SQL文件导入数据库:
-- =============================================
-- Agency Vending - Database Setup
-- =============================================
-- Execute this SQL in your database
-- The tables are required for the player-owned machines system
--
-- NOTE: The tables are also created automatically on first
-- resource start. This SQL is optional for manual setup.
-- =============================================
CREATE TABLE IF NOT EXISTS `agency_vending_machines` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`owner` VARCHAR(50) NOT NULL,
`type` VARCHAR(50) NOT NULL,
`coords` TEXT NOT NULL,
`heading` FLOAT NOT NULL DEFAULT 0,
`earnings` FLOAT NOT NULL DEFAULT 0
);
CREATE TABLE IF NOT EXISTS `agency_vending_stock` (
`machine_id` INT NOT NULL,
`slot` VARCHAR(10) NOT NULL,
`stock` INT NOT NULL DEFAULT 0,
`price` FLOAT NOT NULL DEFAULT 0,
PRIMARY KEY (`machine_id`, `slot`)
);
CREATE TABLE IF NOT EXISTS `agency_vending_spawned` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`type` VARCHAR(50) NOT NULL,
`model` VARCHAR(100) NOT NULL,
`coords` TEXT NOT NULL,
`heading` FLOAT NOT NULL DEFAULT 0,
`spawned_by` VARCHAR(50) NOT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
