Início › Documentação › Instalação · origen_vendings

Instalação · origen_vendings


1. Adicionar ao server.cfg

Coloca o origen_vendings depois de todas as suas dependências:

cfg
ensure ox_lib
ensure oxmysql
ensure qb-core        # or qbx_core / es_extended
ensure ox_inventory   # or your active inventory
 
ensure origen_vendings

2. Base de dados

O origen_vendings cria e mantém as suas próprias tabelas automaticamente no primeiro arranque. Não precisas de executar nenhum SQL manualmente.

Em cada reinício, o recurso verifica se faltam tabelas ou colunas e aplica-as automaticamente com o esquema definido em database.sql.

Se estás a atualizar a partir de uma versão anterior, o recurso vai detetar e adicionar automaticamente as colunas novas. Não é necessária nenhuma migração manual.

Segue-se o esquema completo como referência:

sql
CREATE TABLE `origen_vendings_groups` (
    `id`          INT          NOT NULL AUTO_INCREMENT,
    `name`        VARCHAR(100) NOT NULL,
    `category`    ENUM('drinks','snacks','coffee','cigarettes','custom') NOT NULL DEFAULT 'drinks',
    `enabled`     TINYINT(1)   NOT NULL DEFAULT 1,
    `created_at`  TIMESTAMP    NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at`  TIMESTAMP    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    KEY `idx_category` (`category`),
    KEY `idx_enabled`  (`enabled`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
CREATE TABLE `origen_vendings_group_props` (
    `id`         INT          NOT NULL AUTO_INCREMENT,
    `group_id`   INT          NOT NULL,
    `prop_model` VARCHAR(100) NOT NULL,
    `prop_label` VARCHAR(150) NOT NULL DEFAULT '',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uq_group_prop` (`group_id`, `prop_model`),
    KEY `idx_group` (`group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
CREATE TABLE `origen_vendings_group_items` (
    `id`         INT           NOT NULL AUTO_INCREMENT,
    `group_id`   INT           NOT NULL,
    `item_name`  VARCHAR(100)  NOT NULL,
    `label`      VARCHAR(150)  NOT NULL,
    `price`      INT           NOT NULL DEFAULT 0,
    `use_stock`  TINYINT(1)    NOT NULL DEFAULT 0,
    `stock`      INT           DEFAULT NULL,
    `created_at` TIMESTAMP     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE KEY `uq_group_item` (`group_id`, `item_name`),
    KEY `idx_group`    (`group_id`),
    KEY `idx_item`     (`item_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
 
CREATE TABLE `origen_vendings_machines` (
    `id`          INT           NOT NULL AUTO_INCREMENT,
    `group_id`    INT           NOT NULL,
    `name`        VARCHAR(150)  NOT NULL,
    `prop_model`  VARCHAR(100)  NOT NULL,
    `x`           FLOAT         NOT NULL DEFAULT 0,
    `y`           FLOAT         NOT NULL DEFAULT 0,
    `z`           FLOAT         NOT NULL DEFAULT 0,
    `heading`     FLOAT         NOT NULL DEFAULT 0,
    `spawn_prop`  TINYINT(1)    NOT NULL DEFAULT 1,
    `enabled`     TINYINT(1)    NOT NULL DEFAULT 1,
    `created_at`  TIMESTAMP     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at`  TIMESTAMP     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    KEY `idx_group_id` (`group_id`),
    KEY `idx_enabled`  (`enabled`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

3. Configuração inicial

Abre config.lua e define a tua framework e o teu inventário antes de arrancar o recurso:

lua
-- Framework: 'qb-core' | 'qbx_core' | 'esx'
Config.Framework = 'qb-core'
 
-- Inventory: 'auto' detects the active inventory automatically
Config.Inventory = 'auto'
 
-- Admin groups (ACE-based)
Config.GroupPermissions = { 'god', 'admin', 'superadmin' }

Se quiseres logs no Discord, abre svconfig.lua e substitui cada 'YOUR_WEBHOOK_URL' pelos URL dos teus webhooks do Discord:

lua
return {
    enabled = true,
    webhooks = {
        ['group-created'] = 'https://discord.com/api/webhooks/...',
        ['group-updated'] = 'https://discord.com/api/webhooks/...',
        ['group-deleted'] = 'https://discord.com/api/webhooks/...',
        ['item-added']    = 'https://discord.com/api/webhooks/...',
        ['item-updated']  = 'https://discord.com/api/webhooks/...',
        ['item-removed']  = 'https://discord.com/api/webhooks/...',
        ['machine-created'] = 'https://discord.com/api/webhooks/...',
        ['machine-updated'] = 'https://discord.com/api/webhooks/...',
        ['machine-deleted'] = 'https://discord.com/api/webhooks/...',
    },
}

Define enabled = false em svconfig.lua para desativar todos os logs do Discord sem remover os webhooks.


4. Verificar a instalação

Depois de arrancar o recurso, verifica a consola do servidor. Deves ver um resumo de arranque semelhante a este:

text
========================================================
[origen_vendings]
* Framework: qb-core
* Inventory: ox_inventory
* Language:  en
* Version:   1.0.0 Latest Version
========================================================

Se vires Can't get version info!, não é um erro: significa apenas que o servidor não conseguiu contactar o endpoint de versões do GitHub.