Accueil › Documentation › Installation · origen_vendings

Installation · origen_vendings


1. Ajouter à server.cfg

Place origen_vendings après toutes ses dépendances :

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 données

origen_vendings crée et maintient lui-même ses tables automatiquement au premier démarrage. Tu n’as besoin d’exécuter aucun SQL manuellement.

À chaque redémarrage, la ressource vérifie s’il manque des tables ou des colonnes et les applique automatiquement avec le schéma défini dans database.sql.

Si tu mets à jour depuis une version précédente, la ressource détectera et ajoutera automatiquement les nouvelles colonnes. Aucune migration manuelle n’est nécessaire.

Le schéma complet est fourni ci-dessous à titre de référence :

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. Configuration initiale

Ouvre config.lua et définis ton framework et ton inventaire avant de démarrer la ressource :

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' }

Si tu veux des logs Discord, ouvre svconfig.lua et remplace chaque 'YOUR_WEBHOOK_URL' par les URL de tes webhooks 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/...',
    },
}

Mets enabled = false dans svconfig.lua pour désactiver tous les logs Discord sans retirer les webhooks.


4. Vérifier l’installation

Après avoir démarré la ressource, consulte la console du serveur. Tu devrais voir un résumé de démarrage semblable à celui-ci :

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

Si tu vois Can't get version info!, ce n’est pas une erreur : cela signifie simplement que le serveur n’a pas pu joindre le point de terminaison des versions de GitHub.