Skip to main content

Config Server


Variables Globales

ESX

  • Type : table
  • Description : Objet partagé d'ESX utilisé pour interagir avec le framework ESX.
  • Initialisation :
    ESX = exports['es_extended']:getSharedObject()

config

  • Type : table
  • Description : Table principale de configuration qui contient des paramètres pour les actions et les événements administratifs.

config.owner

  • Type : table<number, string>
  • Description : Liste des propriétaires du serveur, identifiés par leur ID Discord, pour des actions risquées.

config.guild

  • Type : number
  • Description : ID du serveur Discord utilisé pour la gestion des rôles et permissions.

config.role

  • Type : table<string, string>
  • Description : Liste des rôles Discord avec leurs correspondances en jeu (par exemple, admin, modérateur, etc.).

config.botToken

  • Type : string
  • Description : Token du bot Discord utilisé pour l'intégration avec le serveur. Attention : Ne jamais partager ce token publiquement.

Fonctions Administratives

config.revive

  • Description : Revive un joueur ciblé.
  • Paramètres :
    • target (int) : Identifiant du joueur à revive.
  • Utilisation :
    config.revive(target)

config.heal

  • Description : Soigne un joueur ciblé.
  • Paramètres :
    • target (int) : Identifiant du joueur à soigner.
  • Utilisation :
    config.heal(target)

config.banPlayer

  • Description : Fonction qui bannit un joueur pour une durée spécifique avec une raison.
  • Paramètres :
    • source (int) : Source du ban.
    • time (int) : Durée du ban.
    • reason (string) : Raison du ban.
  • Utilisation :
    config.banPlayer(source, time, reason)

config.reloadskin

  • Description : Recharge l'apparence d'un joueur.
  • Paramètres :
    • source (int) : Identifiant du joueur à recharger.
  • Utilisation :
    config.reloadskin(source)

config.changerWeather

  • Description : Change le type de météo sur le serveur.
  • Paramètres :
    • weatherType (string) : Type de météo à définir.
  • Utilisation :
    config.changerWeather("clear")

config.changerTime

  • Description : Change l'heure sur le serveur.
  • Paramètres :
    • hour (int) : Heure à définir.
    • minute (int) : Minute à définir.
  • Utilisation :
    config.changerTime(12, 30)

Événements

gunware:sendAnnonce

  • Description : Envoie une annonce globale à tous les joueurs connectés.
  • Paramètres :
    • msg (string) : Message de l'annonce.
  • Utilisation :
    RegisterNetEvent("gunware:sendAnnonce")
    AddEventHandler("gunware:sendAnnonce", function(msg)
    TriggerClientEvent("gunware:sendAnnonce", -1, msg)
    end)

gunware:wipeVehicles

  • Description : Supprime tous les véhicules possédés dans la base de données.
  • Utilisation :
    RegisterNetEvent("gunware:wipeVehicles")
    AddEventHandler("gunware:wwipeVehicles", function()
    MySQL.Async.execute("DELETE FROM owned_vehicles", {}, function()
    TriggerClientEvent("gunware:notify", -1, "All vehicles have been wiped")
    end)
    end)

gunware:wipePlayers

  • Description : Supprime tous les joueurs de la base de données (actuellement désactivé pour éviter les suppressions accidentelles).
  • Utilisation :
    RegisterNetEvent("gunware:wipePlayers")
    AddEventHandler("gunware:wipePlayers", function()
    -- MySQL.Async.execute("DELETE FROM users", {}, function()
    -- for k,v in pairs(GetPlayers()) do
    -- DropPlayer(v, "Admin has wiped all players")
    -- end)
    -- end)
    print("Wipe players")
    end)

Commandes

/allitems

  • Description : Crée un stash contenant tous les items disponibles dans le serveur.
  • Utilisation :
    lib.addCommand('allitems', {
    help = 'Tous les items',
    restricted = 'group.admin',
    }, function(source, args)
    local ox_inventory = exports.ox_inventory
    local allitems = ox_inventory:Items()
    local table = {}
    local maxWeight = 0
    for name, item in pairs(allitems) do
    if name and item then
    table[#table+1] = {name, 500000}
    maxWeight = maxWeight + (item.weight * 500000)
    end
    end
    local stash = ox_inventory:CreateTemporaryStash({
    label = 'Tous les items',
    slots = #table,
    maxWeight = maxWeight,
    items = table
    })
    TriggerClientEvent('ox_inventory:openInventory', source, 'stash', stash)
    end)

/searchitems

  • Description : Permet de rechercher un item spécifique dans l'inventaire en utilisant un pattern.
  • Utilisation :
    lib.addCommand('searchitems', {
    help = 'Rechercher un item',
    params = {
    { name = 'pattern', type = 'string', help = 'Pattern of name or label item' },
    },
    restricted = 'group.admin',
    }, function(source, args)
    local ox_inventory = exports.ox_inventory
    local allitems = ox_inventory:Items()
    local table = {}
    local maxWeight = 0
    for name, item in pairs(allitems) do
    if name and item and (
    string.find(name:lower(), args.pattern:lower()) or
    string.find(item.label:lower(), args.pattern:lower())
    ) then
    table[#table+1] = {name, 500000}
    maxWeight = maxWeight + (item.weight * 500000)
    end
    end
    local stash = ox_inventory:CreateTemporaryStash({
    label = 'Item patter: ' .. args.pattern,
    slots = #table,
    maxWeight = maxWeight,
    items = table
    })
    TriggerClientEvent('ox_inventory:openInventory', source, 'stash', stash)
    end)

/trash

  • Description : Crée un stash temporaire "Poubelle" pour déposer les items.
  • Utilisation :
    lib.addCommand('trash', {
    help = 'Poubelle',
    restricted = 'group.admin',
    }, function(source, args)
    local ox_inventory = exports.ox_inventory
    local stash = ox_inventory:CreateTemporaryStash({
    label = 'Poubelle',
    slots = 1000000,
    maxWeight = 1000000 * 1000000,
    items = {}
    })
    TriggerClientEvent('ox_inventory:openInventory', source, 'stash', stash)
    end)