# Welcome

#### Version française&#x20;

Bonjour et bienvenue sur la documentation officielle de **PE Scripts** ! Nous sommes ravis de vous accueillir dans cet espace entièrement dédié à la présentation, à l’explication et à la personnalisation de nos différents scripts. Chez PE Scripts, nous nous spécialisons dans la création de scripts variés, conçus pour s’adapter à vos besoins spécifiques et offrir une expérience totalement modulable et personnalisable.

Notre objectif est de vous fournir non seulement des outils fonctionnels, mais également une documentation claire et complète qui vous permettra de comprendre chaque fonctionnalité en détail. Que vous soyez débutant ou utilisateur avancé, vous trouverez des ressources pour vous aider à tirer le meilleur parti de nos scripts.

Nous vous invitons également à visiter notre chaîne dédiée, où vous pourrez découvrir les aperçus exclusifs de nos prochains scripts, suivre les mises à jour et bénéficier de démonstrations interactives. Cette chaîne est pensée pour vous tenir informé des nouveautés, partager des astuces et vous offrir une vision complète de ce que PE Scripts peut vous apporter.

Pour rester encore plus proche de notre communauté, nous avons mis en place un **serveur Discord** officiel. Vous pourrez y rejoindre d’autres utilisateurs, poser vos questions, signaler des bugs, obtenir de l’aide directement auprès de notre équipe, et recevoir toutes les annonces importantes concernant les prochaines mises à jour et nouvelles fonctionnalités. Ce serveur est le lieu idéal pour interagir avec nous et tirer le meilleur parti de votre expérience avec PE Scripts.

Nous espérons que cette documentation vous sera utile et agréable, et nous vous remercions de votre confiance dans nos outils. Plongez dans l’univers de PE Scripts et découvrez comment nos scripts peuvent enrichir et simplifier vos projets !

#### English version

Hello and welcome to the official documentation of **PE Scripts**! We are delighted to have you here in this space, entirely dedicated to the presentation, explanation, and customization of our various scripts. At PE Scripts, we specialize in creating a wide range of scripts designed to adapt to your specific needs, offering a fully flexible and customizable experience.

Our goal is to provide you not only with functional tools but also with clear and comprehensive documentation that will allow you to understand every feature in detail. Whether you are a beginner or an advanced user, you will find resources to help you make the most of our scripts.

We also invite you to visit our dedicated channel, where you can discover exclusive previews of our upcoming scripts, stay up to date with updates, and enjoy interactive demonstrations. This channel is designed to keep you informed about new releases, share tips, and provide a complete insight into what PE Scripts can offer you.

To stay even closer to our community, we have set up an **official Discord server**. There, you can join other users, ask questions, report bugs, get direct support from our team, and receive all important announcements about future updates and new features. This server is the perfect place to interact with us and make the most out of your PE Scripts experience.

We hope this documentation will be both useful and enjoyable, and we sincerely thank you for trusting our tools. Dive into the world of PE Scripts and discover how our scripts can enhance and simplify your projects!

{% embed url="<https://discord.gg/pescripts>" %}

{% embed url="<https://www.youtube.com/@pescripts-fivem>" %}


# PAnimationmenu


# Installation

{% stepper %}
{% step %}

#### Install

Install the resource on your Keymaster after purchasing the script. <mark style="color:$primary;">(</mark>[<mark style="color:$primary;">https://portal.cfx.re/</mark>](https://portal.cfx.re/)<mark style="color:$primary;">)</mark>&#x20;

{% endstep %}

{% step %}

#### Drag And Drop

Please place the animationmenu resource on your base.
{% endstep %}

{% step %}

### Start

Next, please make sure that the animation resource is added in your `server.cfg` or `resources.cfg`.<br>

{% endstep %}

{% step %}

### Config script

Configure your resource in the `config.lua` file.
{% endstep %}
{% endstepper %}

<details>

<summary>Here is the <code>config.lua</code> file. ESX/QB</summary>

```lua
-----------------------------------------------
-- EMOTES MENU - Main Configuration
-- Configuration principale
-----------------------------------------------

Config = {}

-----------------------------------------------
-- Menu Settings / Paramètres Menu
-----------------------------------------------
Config.MenuKey = "F7"
-- FR: Touche pour ouvrir le menu des animations
-- EN: Key to open the emote menu

Config.Language = "fr"
-- FR: Langue du menu (modifiable dans la table Languages)
-- EN: Menu language (editable in Languages table)

-----------------------------------------------
-- Camera Preview Settings / Aperçu Caméra
-----------------------------------------------
Config.MaxDistancesForPreview = {
	[0] = 5.0,   -- THIRD PERSON CLOSE / 3ème personne proche
	[1] = 7.5,   -- THIRD PERSON MEDIUM / 3ème personne moyenne
	[2] = 10.0,  -- THIRD PERSON FAR / 3ème personne éloignée
	[3] = 0.0,   -- CINEMATIC MODE / Mode cinématique
	[4] = 4.0    -- FIRST PERSON / Première personne
}
-- FR: Distance maximale de la caméra lors de la preview du personnage
-- EN: Maximum camera distance for character preview

-----------------------------------------------
-- Emotes Settings / Paramètres Animations
-----------------------------------------------
Config.MaxDistanceForSharedEmotes = 3.0
-- FR: Distance maximale pour les animations partagées (invitation)
-- EN: Maximum distance for shared emotes (invite range)

Config.AllowedInCars = false
-- FR: Autoriser les animations dans les véhicules
-- EN: Allow emotes inside vehicles

-----------------------------------------------
-- Notifications / Notifications
-----------------------------------------------
Config.Notify = function(msg, title, type, duration)
    TriggerEvent('esx:showNotification', msg, type, duration or 5000)

	-- QBCore integration
	-- TriggerEvent("QBCore:Notify", msg, type == "info" and "primary" or type, 5000)
end
-- FR: Fonction de notification (ESX par défaut, QBCore en option)
-- EN: Notification function (ESX default, QBCore optional)

-----------------------------------------------
-- Keybinds / Raccourcis Clavier
-----------------------------------------------
Config.ShortcutKey = 21
-- FR: Touche pour lancer l'animation sauvegardée (21 = SHIFT)
-- EN: Key to play saved animation

Config.CancelKey = "X"
-- FR: Touche pour annuler l’animation en cours
-- EN: Key to cancel current animation

Config.CancelHandsUp = true
-- FR: Lever les mains si aucune animation n’est en cours lors de l’annulation
-- EN: Raise hands if no animation to cancel

-----------------------------------------------
-- Pointing Settings / Paramètres Pointage
-----------------------------------------------
Config.PointCommand = "point"
-- FR: Nom de la commande pour pointer
-- EN: Command name for pointing

Config.PointKey = "B"
-- FR: Touche pour pointer
-- EN: Key to point

-----------------------------------------------
-- Ragdoll Settings / Paramètres Ragdoll
-----------------------------------------------
Config.RagdollCommand = "ragdoll"
-- FR: Nom de la commande ragdoll (modifiable)
-- EN: Ragdoll command name (editable)

Config.RagdollKey = "U"
-- FR: Touche par défaut pour le ragdoll
-- EN: Default ragdoll key

Config.AnimationAcceptKey = "Y"
-- FR: Touche pour accepter une animation partagée
-- EN: Key to accept shared animation

Config.AnimationDeclineKey = "N"
-- FR: Touche pour refuser une animation partagée
-- EN: Key to decline shared animation

-----------------------------------------------
-- Display Settings / Paramètres d'affichage
-----------------------------------------------
Config.ShowAllImagesDefault = true
-- FR: Afficher toutes les images d’animations par défaut
--     false = affichage uniquement au survol
-- EN: Show all animation images by default
--     false = show only on hover
```

</details>


# PHud


# Installation

{% stepper %}
{% step %}

#### Install

Install the resource on your Keymaster after purchasing the script. <mark style="color:$primary;">(</mark>[<mark style="color:$primary;">https://portal.cfx.re/</mark>](https://portal.cfx.re/)<mark style="color:$primary;">)</mark>&#x20;

{% endstep %}

{% step %}

#### Drag And Drop

Please place the carplay resource on your base.
{% endstep %}

{% step %}

### Start

Next, please make sure that the **HUD** resource is added in your `server.cfg` or `resources.cfg`.\
Start this resource at the very bottom of your resources list.

{% endstep %}

{% step %}

### Config script

Configure your resource in the `config.lua` file.
{% endstep %}
{% endstepper %}

<details>

<summary>Here is the <code>config.lua</code> file. ESX/QB</summary>

```lua
-----------------------------------------------
-- PHUD - Main Configuration
-- Configuration principale
-----------------------------------------------

Config = {}

-----------------------------------------------
-- Language / Langue
-----------------------------------------------
Config.Locale = 'en' -- en, fr, de, es, ru, zh
-- FR: Langue utilisée pour les messages et l'interface
-- EN: Language used for messages and UI

-----------------------------------------------
-- Framework Settings / Paramètres Framework
-----------------------------------------------
Config.Framework = "auto" -- auto, esx, qb, standalone
-- FR: Framework utilisé (auto = détection automatique)
-- EN: Framework used (auto = automatic detection)

Config.ESXExport = "es_extended"
-- FR: Nom de la ressource ESX
-- EN: ESX resource name

-----------------------------------------------
-- Performance / Performance
-----------------------------------------------
Config.UpdateInterval = 150
-- FR: Intervalle de mise à jour en ms (plus bas = plus fluide mais plus gourmand)
-- EN: Update interval in ms (lower = smoother but more resource intensive)

Config.HideInPauseMenu = true
-- FR: Masquer le HUD quand le menu pause est ouvert
-- EN: Hide HUD when pause menu is open

-----------------------------------------------
-- Server Info / Informations Serveur
-----------------------------------------------
Config.ServerName = "PEScripts"
-- FR: Nom du serveur affiché en haut à droite
-- EN: Server name displayed in top right

Config.ServerLogo = "logo.png"
-- FR: Logo du serveur (fichier dans html/assets/)
-- EN: Server logo (file in html/assets/)

Config.LogoAnimation = "bounce"
-- FR: Animation du logo (none, pulse, glow, rotate, bounce)
-- EN: Logo animation (none, pulse, glow, rotate, bounce)
-- Note: Les animations peuvent causer une légère baisse de FPS

-----------------------------------------------
-- Discord Integration / Intégration Discord
-----------------------------------------------
Config.ShowDiscord = true
Config.DiscordInvite = "discord.gg/pescripts"
Config.DiscordLink = "https://discord.gg/pescripts"

-----------------------------------------------
-- Keybinds / Raccourcis Clavier
-----------------------------------------------
Config.DefaultKeybind = "F6" -- Open settings / Ouvrir les paramètres
Config.ToggleKeybind = "F7" -- Toggle HUD / Activer/désactiver le HUD

-----------------------------------------------
-- Minimap Settings / Paramètres Minimap
-----------------------------------------------
Config.ShowMinimap = false
-- FR: Afficher la minimap par défaut
-- EN: Show minimap by default

Config.AllowMinimapToggle = true
-- FR: Autoriser le joueur à activer/désactiver la minimap
-- EN: Allow player to toggle minimap

Config.BottomLeftHudOffset = 360
-- FR: Décalage du HUD en bas à gauche (augmenter si chevauchement avec minimap)
-- EN: Bottom left HUD offset (increase if overlapping with minimap)

-----------------------------------------------
-- HUD Position / Position du HUD
-----------------------------------------------
Config.ManualHUDOffset = {
    x = 15, -- Horizontal offset / Décalage horizontal
    y = 0   -- Vertical offset / Décalage vertical
}

Config.MoveHudWhenMinimapDisabled = true
-- FR: Déplacer automatiquement le HUD quand la minimap est désactivée
-- EN: Automatically move HUD when minimap is disabled

-----------------------------------------------
-- Default Theme / Thème par Défaut
-----------------------------------------------
Config.DefaultTheme = "clean"
-- Options: clean, darkness, neon, ocean, sunset, forest, blood, royal

Config.DefaultPosition = "bottom-center"
-- Options: top-left, top-center, top-right, bottom-left, bottom-center, bottom-right

Config.DefaultShape = "square"
-- Options: square, rounded, circle, diamond, hexagon

Config.DefaultSpeedoStyle = "minimal"
-- Options: minimal, circle, digital

Config.StatusBarStyle = "shadow"
-- Options: clean, shadow, outline, neon, gradient

Config.StatusBarAnimation = "glow"
-- Options: none, pulse, glow

-----------------------------------------------
-- Display Options / Options d'Affichage
-----------------------------------------------
Config.ShowHunger = true
Config.ShowThirst = true
Config.ShowOxygen = true
Config.ShowVehicleHUD = true
Config.ShowStatusBar = true
Config.ShowCash = true
Config.ShowBank = true
Config.ShowPlayerId = true
Config.ShowWeaponHUD = true
Config.ShowSeatbelt = true
Config.ShowRadioFrequency = true

-----------------------------------------------
-- Vehicle Settings / Paramètres Véhicule
-----------------------------------------------
Config.UseKMH = true
-- FR: Utiliser KM/H (false = MPH)
-- EN: Use KM/H (false = MPH)

Config.HideFuelWhenFull = true
-- FR: Masquer la jauge d'essence quand elle est pleine
-- EN: Hide fuel gauge when full

Config.HideEngineWhenFull = true
-- FR: Masquer la jauge moteur quand elle est pleine
-- EN: Hide engine gauge when full

Config.FuelFullThreshold = 95
-- FR: Seuil pour considérer que la jauge est "pleine" (%)
-- EN: Threshold to consider gauge as "full" (%)

-----------------------------------------------
-- System Integration / Intégration Systèmes
-----------------------------------------------
-- FR: Options: "auto" (détection automatique de tous les systèmes)
--      ou spécifier un système spécifique
-- EN: Options: "auto" (auto-detect all systems)
--      or specify a specific system
-- FR: Les systèmes personnalisés peuvent être ajoutés dans editable/*/
-- EN: Custom systems can be added in editable/*/ folders

Config.FuelSystem = "LegacyFuel"
-- Options: LegacyFuel, ox_fuel, cdn-fuel, frfuel, ps-fuel, etc.
-- FR: Voir editable/fuel/ pour les systèmes supportés
-- EN: See editable/fuel/ for supported systems

Config.NeedsSystem = "esx_status"
-- Options: esx_status, esx_basicneeds, qb-hud, okokNeeds, renewed-lib, etc.
-- FR: Voir editable/needs/ pour les systèmes supportés
-- EN: See editable/needs/ for supported systems

Config.VoiceSystem = "pma-voice"
-- Options: pma-voice, mumble-voip, saltychat, tokovoip, etc.
-- FR: Voir editable/voice/ pour les systèmes supportés
-- EN: See editable/voice/ for supported systems

-----------------------------------------------
-- Settings Saving / Sauvegarde Paramètres
-----------------------------------------------
Config.SaveSettings = true
-- FR: Sauvegarder les paramètres du joueur
-- EN: Save player settings

Config.UseKVP = true
-- FR: Utiliser KVP pour la sauvegarde (survit aux redémarrages)
-- EN: Use KVP for saving (survives restarts)

-----------------------------------------------
-- Admin Settings / Paramètres Admin
-----------------------------------------------
Config.AdminGroups = {"admin", "superadmin", "god"}
Config.AdminCommand = "pehud"

-----------------------------------------------
-- Weapon Images / Images des Armes
-----------------------------------------------
Config.WeaponImages = {
    -- Pistols / Pistolets
    ["WEAPON_PISTOL"] = "weapon_pistol.png",
    ["WEAPON_PISTOL_MK2"] = "weapon_pistol_mk2.png",
    ["WEAPON_COMBATPISTOL"] = "weapon_combatpistol.png",
    ["WEAPON_APPISTOL"] = "weapon_appistol.png",
    ["WEAPON_PISTOL50"] = "weapon_pistol50.png",
    ["WEAPON_SNSPISTOL"] = "weapon_snspistol.png",
    ["WEAPON_HEAVYPISTOL"] = "weapon_heavypistol.png",
    ["WEAPON_VINTAGEPISTOL"] = "weapon_vintagepistol.png",
    ["WEAPON_REVOLVER"] = "weapon_revolver.png",

    -- SMGs / Mitraillettes
    ["WEAPON_MICROSMG"] = "weapon_microsmg.png",
    ["WEAPON_SMG"] = "weapon_smg.png",
    ["WEAPON_SMG_MK2"] = "weapon_smg_mk2.png",
    ["WEAPON_ASSAULTSMG"] = "weapon_assaultsmg.png",
    ["WEAPON_MINISMG"] = "weapon_minismg.png",

    -- Shotguns / Fusils à pompe
    ["WEAPON_PUMPSHOTGUN"] = "weapon_pumpshotgun.png",
    ["WEAPON_PUMPSHOTGUN_MK2"] = "weapon_pumpshotgun_mk2.png",
    ["WEAPON_SAWNOFFSHOTGUN"] = "weapon_sawnoffshotgun.png",
    ["WEAPON_BULLPUPSHOTGUN"] = "weapon_bullpupshotgun.png",

    -- Assault Rifles / Fusils d'assaut
    ["WEAPON_ASSAULTRIFLE"] = "weapon_assaultrifle.png",
    ["WEAPON_ASSAULTRIFLE_MK2"] = "weapon_assaultrifle_mk2.png",
    ["WEAPON_CARBINERIFLE"] = "weapon_carbinerifle.png",
    ["WEAPON_CARBINERIFLE_MK2"] = "weapon_carbinerifle_mk2.png",
    ["WEAPON_ADVANCEDRIFLE"] = "weapon_advancedrifle.png",
    ["WEAPON_SPECIALCARBINE"] = "weapon_specialcarbine.png",
    ["WEAPON_SPECIALCARBINE_MK2"] = "weapon_specialcarbine_mk2.png",
    ["WEAPON_BULLPUPRIFLE"] = "weapon_bullpuprifle.png",
    ["WEAPON_COMPACTRIFLE"] = "weapon_compactrifle.png",

    -- Sniper Rifles / Fusils de sniper
    ["WEAPON_SNIPERRIFLE"] = "weapon_sniperrifle.png",
    ["WEAPON_HEAVYSNIPER"] = "weapon_heavysniper.png",
    ["WEAPON_HEAVYSNIPER_MK2"] = "weapon_heavysniper_mk2.png",
    ["WEAPON_MARKSMANRIFLE"] = "weapon_marksmanrifle.png",
    ["WEAPON_MARKSMANRIFLE_MK2"] = "weapon_marksmanrifle_mk2.png",

    -- Machine Guns / Mitrailleuses
    ["WEAPON_MG"] = "weapon_mg.png",
    ["WEAPON_COMBATMG"] = "weapon_combatmg.png",
    ["WEAPON_COMBATMG_MK2"] = "weapon_combatmg_mk2.png",
    ["WEAPON_GUSENBERG"] = "weapon_gusenberg.png",

    -- Heavy Weapons / Armes lourdes
    ["WEAPON_RPG"] = "weapon_rpg.png",
    ["WEAPON_GRENADELAUNCHER"] = "weapon_grenadelauncher.png",
    ["WEAPON_MINIGUN"] = "weapon_minigun.png",
    ["WEAPON_FIREWORK"] = "weapon_firework.png",
    ["WEAPON_RAILGUN"] = "weapon_railgun.png",

    -- Melee / Corps à corps
    ["WEAPON_KNIFE"] = "weapon_knife.png",
    ["WEAPON_NIGHTSTICK"] = "weapon_nightstick.png",
    ["WEAPON_HAMMER"] = "weapon_hammer.png",
    ["WEAPON_BAT"] = "weapon_bat.png",
    ["WEAPON_CROWBAR"] = "weapon_crowbar.png",
    ["WEAPON_GOLFCLUB"] = "weapon_golfclub.png",
    ["WEAPON_BOTTLE"] = "weapon_bottle.png",
    ["WEAPON_DAGGER"] = "weapon_dagger.png",
    ["WEAPON_HATCHET"] = "weapon_hatchet.png",
    ["WEAPON_MACHETE"] = "weapon_machete.png",
    ["WEAPON_SWITCHBLADE"] = "weapon_switchblade.png",
    ["WEAPON_BATTLEAXE"] = "weapon_battleaxe.png",
    ["WEAPON_POOLCUE"] = "weapon_poolcue.png",
    ["WEAPON_WRENCH"] = "weapon_wrench.png"
}

```

</details>


# Exports

## PHud - Exports Documentation

This document lists all available exports for PHud and how to use them in your other scripts.

### Table of Contents

* HUD Control
* Minimap
* Seatbelt
* Money
* Voice
* Radio
* Status
* Settings

***

### HUD Control

#### ToggleHUD

Show or hide the complete HUD.

**Usage:**

```lua
-- Hide the HUD
exports['PHud']:ToggleHUD(false)

-- Show the HUD
exports['PHud']:ToggleHUD(true)
```

**Parameters:**

* `state` (boolean): `true` to show, `false` to hide

**Usage Examples:**

```lua
-- During a cutscene
exports['PHud']:ToggleHUD(false)
Wait(5000)
exports['PHud']:ToggleHUD(true)

-- During a special event
RegisterNetEvent('myserver:startCutscene', function()
    exports['PHud']:ToggleHUD(false)
end)

RegisterNetEvent('myserver:endCutscene', function()
    exports['PHud']:ToggleHUD(true)
end)
```

#### IsHUDVisible

Check if the HUD is currently visible.

**Usage:**

```lua
local isVisible = exports['PHud']:IsHUDVisible()
if isVisible then
    print("HUD is visible")
end
```

**Returns:**

* `boolean`: `true` if visible, `false` if hidden

***

### Minimap

#### ToggleMinimap

Show or hide the minimap.

**Usage:**

```lua
-- Hide the minimap
exports['PHud']:ToggleMinimap(false)

-- Show the minimap
exports['PHud']:ToggleMinimap(true)
```

**Parameters:**

* `state` (boolean): `true` to show, `false` to hide

***

### Seatbelt

#### SetSeatbelt / seatbelt

Enable or disable the seatbelt.

**Usage:**

```lua
-- Put on seatbelt
exports['PHud']:SetSeatbelt(true)

-- Remove seatbelt
exports['PHud']:SetSeatbelt(false)

-- Alias (works the same way)
exports['PHud']:seatbelt(true)
```

**Parameters:**

* `state` (boolean): `true` to fasten, `false` to unfasten

#### GetSeatbelt

Check if the seatbelt is fastened.

**Usage:**

```lua
local isBeltOn = exports['PHud']:GetSeatbelt()
if isBeltOn then
    print("Seatbelt is fastened")
end
```

**Returns:**

* `boolean`: `true` if fastened, `false` otherwise

***

### Money

#### SetMoney

Update the display of cash and bank money.

**Usage:**

```lua
-- Update money
exports['PHud']:SetMoney(5000, 25000)
```

**Parameters:**

* `cash` (number): Cash amount
* `bank` (number): Bank amount

**Example:**

```lua
RegisterNetEvent('banking:updateMoney', function(cash, bank)
    exports['PHud']:SetMoney(cash, bank)
end)
```

***

### Voice

#### UpdateVoiceRange

Update voice range (whisper/normal/shout).

**Usage:**

```lua
-- Whisper
exports['PHud']:UpdateVoiceRange(1)

-- Normal
exports['PHud']:UpdateVoiceRange(2)

-- Shout
exports['PHud']:UpdateVoiceRange(3)
```

**Parameters:**

* `range` (number): 1 = whisper, 2 = normal, 3 = shout

#### UpdateTalking

Update talking state (speaking or not).

**Usage:**

```lua
-- Player is talking
exports['PHud']:UpdateTalking(true)

-- Player stopped talking
exports['PHud']:UpdateTalking(false)
```

**Parameters:**

* `talking` (boolean): `true` if talking, `false` otherwise

#### UpdateVoice

Update both voice range AND talking state at once.

**Usage:**

```lua
-- Normal range, talking
exports['PHud']:UpdateVoice(2, true)

-- Shout range, not talking
exports['PHud']:UpdateVoice(3, false)
```

**Parameters:**

* `range` (number): 1 = whisper, 2 = normal, 3 = shout
* `talking` (boolean): `true` if talking, `false` otherwise

**Example with pma-voice:**

```lua
-- In your voice script
AddEventHandler('pma-voice:setTalkingMode', function(mode)
    exports['PHud']:UpdateVoiceRange(mode)
end)

local voiceTarget = LocalPlayer.state['proximity']
CreateThread(function()
    while true do
        local newVoiceTarget = LocalPlayer.state['proximity']
        if newVoiceTarget ~= voiceTarget then
            voiceTarget = newVoiceTarget
            exports['PHud']:UpdateVoiceRange(voiceTarget.index)
        end
        Wait(100)
    end
end)
```

***

### Radio

#### SetRadioFrequency / UpdateRadio

Update the displayed radio frequency.

**Usage:**

```lua
-- Set frequency to 123.4
exports['PHud']:SetRadioFrequency(123.4)

-- Alias (works the same way)
exports['PHud']:UpdateRadio(123.4)

-- Disable radio (set to 0)
exports['PHud']:SetRadioFrequency(0.0)
```

**Parameters:**

* `frequency` (number): Radio frequency (0.0 = disabled)

**Example with pma-voice:**

```lua
AddEventHandler('pma-voice:radioActive', function(radioActive)
    if radioActive then
        local frequency = exports['pma-voice']:getRadioChannel()
        exports['PHud']:UpdateRadio(frequency)
    else
        exports['PHud']:UpdateRadio(0.0)
    end
end)
```

***

### Status

#### SetStress

Update player's stress level.

**Usage:**

```lua
-- Stress at 50%
exports['PHud']:SetStress(50)

-- No stress
exports['PHud']:SetStress(0)

-- Maximum stress
exports['PHud']:SetStress(100)
```

**Parameters:**

* `value` (number): Stress level from 0 to 100

#### SetDead

Indicate if the player is dead (shows an overlay).

**Usage:**

```lua
-- Player is dead
exports['PHud']:SetDead(true)

-- Player is alive
exports['PHud']:SetDead(false)
```

**Parameters:**

* `state` (boolean): `true` if dead, `false` if alive

**Example:**

```lua
AddEventHandler('esx:onPlayerDeath', function()
    exports['PHud']:SetDead(true)
end)

AddEventHandler('esx:onPlayerSpawn', function()
    exports['PHud']:SetDead(false)
end)
```

***

### Settings

#### OpenSettings

Open the HUD settings menu.

**Usage:**

```lua
exports['PHud']:OpenSettings()
```

**Example with command:**

```lua
RegisterCommand('hudsettings', function()
    exports['PHud']:OpenSettings()
end, false)
```

***

### Complete Examples

#### Example 1: ESX Integration

```lua
-- Money update
RegisterNetEvent('esx:setAccountMoney', function(account)
    if account.name == 'money' then
        local xPlayer = ESX.GetPlayerData()
        local cash = account.money
        local bank = xPlayer.accounts[2].money
        exports['PHud']:SetMoney(cash, bank)
    end
end)

-- Death management
AddEventHandler('esx:onPlayerDeath', function()
    exports['PHud']:SetDead(true)
end)

AddEventHandler('esx:onPlayerSpawn', function()
    exports['PHud']:SetDead(false)
end)
```

#### Example 2: Custom Seatbelt System

```lua
local seatbeltOn = false
local lastVehicle = nil

CreateThread(function()
    while true do
        local ped = PlayerPedId()
        local vehicle = GetVehiclePedIsIn(ped, false)

        if vehicle ~= 0 and vehicle ~= lastVehicle then
            lastVehicle = vehicle
            seatbeltOn = false
            exports['PHud']:SetSeatbelt(false)
        end

        Wait(500)
    end
end)

RegisterCommand('seatbelt', function()
    local ped = PlayerPedId()
    if IsPedInAnyVehicle(ped, false) then
        seatbeltOn = not seatbeltOn
        exports['PHud']:SetSeatbelt(seatbeltOn)

        if seatbeltOn then
            TriggerEvent('chat:addMessage', { args = { 'Seatbelt fastened' } })
        else
            TriggerEvent('chat:addMessage', { args = { 'Seatbelt unfastened' } })
        end
    end
end, false)

RegisterKeyMapping('seatbelt', 'Toggle Seatbelt', 'keyboard', 'B')
```

#### Example 3: Hide HUD During Cutscene

```lua
RegisterNetEvent('myserver:startHeist', function()
    -- Hide HUD during briefing
    exports['PHud']:ToggleHUD(false)

    -- Show your cutscene
    -- ...

    Wait(10000) -- 10 seconds

    -- Show HUD again
    exports['PHud']:ToggleHUD(true)
end)
```

#### Example 4: Complete Radio Integration

```lua
local radioChannel = 0.0

RegisterNetEvent('radio:onChannelChange', function(channel)
    radioChannel = channel
    exports['PHud']:UpdateRadio(channel)
end)

RegisterNetEvent('radio:onRadioClose', function()
    radioChannel = 0.0
    exports['PHud']:UpdateRadio(0.0)
end)
```

***

### Important Notes

1. **Client-side only**: All these exports are client-side. Do not call them from the server.
2. **Resource check**: If you're not sure PHud is started, check before calling:

```lua
if GetResourceState('PHud') == 'started' then
    exports['PHud']:ToggleHUD(false)
end
```

3. **Default values**: If you pass an invalid value, the HUD will use its last known value.
4. **Performance**: These exports are optimized and can be called frequently without major performance impact.

***

### Support

If you encounter any issues or have questions about using the exports, check the complete documentation in the `editable/` folder for more integration examples.


# Database

Please add this table to your database.

```sql
CREATE TABLE IF NOT EXISTS `phud_settings` (
  `identifier` varchar(60) NOT NULL,
  `settings` longtext DEFAULT NULL,
  PRIMARY KEY (`identifier`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

```


# Needs add system

{% hint style="info" %}
Our HUD is already compatible with several needs systems: `esx_basicneeds`, `esx_status`, `okokNeeds`, `qb-hud`, and `renewed-lib`.
{% endhint %}

## Custom Needs System Integration Guide

This guide explains how to integrate your own needs system (hunger/thirst) with PHUD.

### 📋 Table of Contents

* How It Works
* Method 1: Using Event Handlers
* Method 2: Using Polling Loop
* Available Exports
* Real Examples
* Configuration
* Troubleshooting

***

### How It Works

PHUD needs to receive hunger and thirst values (0-100 scale) from your needs system:

* **0** = empty/dead
* **100** = full/satisfied

The HUD will automatically update when values change.

***

### Method 1: Using Event Handlers (Recommended)

This method listens to events triggered by your needs system.

#### Step 1: Create Your Integration File

Create a new file in this folder: `your-system-name.lua`

#### Step 2: Use This Template

```lua
-- Listen to events from your needs system
RegisterNetEvent('your_needs_system:onUpdate')
AddEventHandler('your_needs_system:onUpdate', function(data)
    local hunger, thirst = nil, nil

    -- Extract hunger and thirst from your system's data
    -- Adapt this to match your system's data structure
    for i = 1, #data do
        if data[i].name == 'hunger' then
            hunger = math.floor(data[i].percent) -- Convert to 0-100 if needed
        elseif data[i].name == 'thirst' then
            thirst = math.floor(data[i].percent)
        end
    end

    -- Update the HUD
    if hunger or thirst then
        UpdateNeeds(hunger, thirst)
    end
end)
```

#### Real Example: ESX Status

```lua
RegisterNetEvent('esx_status:onTick')
AddEventHandler('esx_status:onTick', function(data)
    local hunger, thirst = nil, nil

    for i = 1, #data do
        if data[i].name == 'hunger' then
            hunger = math.floor(data[i].percent)
        elseif data[i].name == 'thirst' then
            thirst = math.floor(data[i].percent)
        end
    end

    if hunger or thirst then
        UpdateNeeds(hunger, thirst)
    end
end)

-- Also listen to other events for real-time updates
RegisterNetEvent('esx_status:update')
AddEventHandler('esx_status:update', function(data)
    -- Same logic as above
end)

RegisterNetEvent('esx_status:set')
AddEventHandler('esx_status:set', function(name, val)
    if name == 'hunger' then
        local percent = math.floor((val / 1000000) * 100)
        UpdateHunger(percent)
    elseif name == 'thirst' then
        local percent = math.floor((val / 1000000) * 100)
        UpdateThirst(percent)
    end
end)
```

***

### Method 2: Using Polling Loop

This method actively checks your needs system at regular intervals.

#### Template

```lua
Citizen.CreateThread(function()
    while true do
        Wait(1000) -- Update every 1 second (adjust as needed)

        -- Get values from your needs system
        -- Replace these with your actual functions/exports
        local hunger = exports['your-needs-system']:GetHunger() -- Should return 0-100
        local thirst = exports['your-needs-system']:GetThirst() -- Should return 0-100

        -- Update the HUD
        if hunger and thirst then
            UpdateNeeds(hunger, thirst)
        end
    end
end)
```

#### Real Example: QB-Core HUD

```lua
CreateThread(function()
    while true do
        Wait(1000)

        local player = PlayerPedId()
        if player and player > 0 then
            -- Get player metadata
            local PlayerData = QBCore.Functions.GetPlayerData()
            if PlayerData and PlayerData.metadata then
                local hunger = PlayerData.metadata['hunger'] or 100
                local thirst = PlayerData.metadata['thirst'] or 100

                UpdateNeeds(hunger, thirst)
            end
        end
    end
end)
```

***

### Available Exports

Use these functions in your integration file:

#### Update Functions

```lua
-- Update both hunger and thirst at once
UpdateNeeds(hunger, thirst)

-- Update only hunger
UpdateHunger(hunger)

-- Update only thirst
UpdateThirst(thirst)
```

#### Get Functions

```lua
-- Get current hunger value
local hunger = exports['PHud']:GetHunger()

-- Get current thirst value
local thirst = exports['PHud']:GetThirst()

-- Get both values
local needs = exports['PHud']:GetNeeds()
-- Returns: { hunger = 75, thirst = 80 }
```

#### Force Set Functions

```lua
-- Force set hunger without checking for changes
exports['PHud']:SetHunger(75)

-- Force set thirst without checking for changes
exports['PHud']:SetThirst(80)
```

***

### Real Examples

#### ESX Basic Needs

```lua
RegisterNetEvent('esx_basicneeds:onTick')
AddEventHandler('esx_basicneeds:onTick', function(data)
    local hunger, thirst = nil, nil

    for i = 1, #data do
        if data[i].name == 'hunger' then
            hunger = math.floor(data[i].percent)
        elseif data[i].name == 'thirst' then
            thirst = math.floor(data[i].percent)
        end
    end

    if hunger or thirst then
        UpdateNeeds(hunger, thirst)
    end
end)
```

#### OkOk Needs

```lua
CreateThread(function()
    while true do
        Wait(1000)

        if exports['okokNeeds'] then
            local hunger = exports['okokNeeds']:GetHunger()
            local thirst = exports['okokNeeds']:GetThirst()

            if hunger and thirst then
                UpdateNeeds(hunger, thirst)
            end
        end
    end
end)
```

#### Renewed Library

```lua
CreateThread(function()
    while true do
        Wait(1000)

        local needs = exports['Renewed-Lib']:getPlayerNeeds()

        if needs then
            local hunger = needs.hunger or 100
            local thirst = needs.thirst or 100

            UpdateNeeds(hunger, thirst)
        end
    end
end)
```

***

### Configuration

#### Step 1: Create Your Integration File

Create a new `.lua` file in the `phud/editable/needs/` folder.

**Example:**

* Create the file: `phud/editable/needs/custom.lua`
* In config.lua: `Config.NeedsSystem = "custom"`

**Important:** The filename (without `.lua`) must EXACTLY match the value you set in `Config.NeedsSystem`.

#### Step 2: Enable Your System in Config

Open `phud/config.lua` and set:

```lua
-- Use your specific system
Config.NeedsSystem = "custom" -- Filename without .lua extension
```

Available systems:

* `esx_status` - ESX Status (default version)
* `esx_basicneeds` - ESX Basic Needs
* `qb-hud` - QB-Core HUD
* `okokNeeds` - OkOk Needs
* `renewed-lib` - Renewed Library
* `Metabolic` - Metabolic system
* Or your custom filename

#### Step 3: Restart Resource

```
ensure phud
```

***

### Troubleshooting

#### HUD Not Updating

1. **Check if your file is loaded**
   * Make sure the filename matches `Config.NeedsSystem`
   * File should be in `phud/editable/needs/` folder
2. **Check console for errors**
   * Look for Lua errors in F8 console
   * Check server console for warnings
3. **Verify data format**
   * Hunger/thirst should be numbers between 0-100
   * Use `print()` to debug values
4. **Check events are triggering**

   ```lua
   RegisterNetEvent('your_event')
   AddEventHandler('your_event', function(data)
       print("Event received:", json.encode(data))
       -- Your code here
   end)
   ```

#### Values Not Correct

* Check if you need to convert values (e.g., from 0-1000000 to 0-100)
* Ensure you're using `math.floor()` to convert to integers
* Verify your needs system is actually running

#### Auto-Detection Not Working

* Set specific system name instead of "auto"
* Check if your needs resource is started before PHUD
* Ensure your needs system resource name matches

***

### Need Help?

If your needs system is not listed here:

1. Find out what events your system triggers
2. Or find out what exports your system provides
3. Use one of the methods above to integrate it
4. Check your system's documentation for available functions

Common event patterns:

* `system_name:onTick`
* `system_name:update`
* `system_name:onChange`

Common export patterns:

* `exports['system_name']:GetHunger()`
* `exports['system_name']:GetNeeds()`


# Fuel add system

{% hint style="info" %}
Our HUD is already compatible with several fuel systems: cdn-fuel, frfuel, LegacyFuel, lj-fuel, nd\_fuel, okokGasStation, ox\_fuel, ps-fuel, Renewed-Fuel, ti\_fuel.
{% endhint %}

## Custom Fuel System Integration

### How to add your own fuel system

1. Create a new `.lua` file in this folder (e.g., `myfuel.lua`)
2. Use this template:

```lua
-- My Custom Fuel System
return {
    name = "myfuel",           -- unique identifier
    resourceName = "myfuel",   -- resource name to check (use nil for no check)

    GetFuel = function(vehicle)
        -- Your code to get fuel level here
        local success, result = pcall(function()
            return exports['myfuel']:GetFuelLevel(vehicle)
        end)

        if success and result then
            return math.ceil(result)  -- return 0-100
        end

        return nil  -- return nil if failed
    end
}
```

3. Save the file
4. In `config.lua`, set:
   * `Config.FuelSystem = "auto"` (auto-detect all systems)
   * OR `Config.FuelSystem = "myfuel"` (use only your system)

### Available Systems

* **LegacyFuel** - LegacyFuel system
* **ox\_fuel** - Overextended fuel
* **cdn-fuel** - CDN Fuel
* **ps-fuel** - Project Sloth fuel
* **lj-fuel** - LJ Fuel
* **okokGasStation** - okokGasStation
* **Renewed-Fuel** - Renewed Fuel
* **ti\_fuel** - TI Fuel
* **nd\_fuel** - ND Fuel
* **frfuel** - FR Fuel
* **native** - GTA V native fuel (fallback)

### Configuration

In `config.lua`:

```lua
-- Auto-detect (tries all systems in order)
Config.FuelSystem = "auto"

-- Or specify one system
Config.FuelSystem = "LegacyFuel"
```

### Priority Order (when using "auto")

The system will try fuel systems in this order:

1. Your configured system (if specified)
2. All systems in `editable/fuel/` folder
3. Native GTA V fuel (fallback)

### Notes

* Return values should be between 0-100
* Use `math.ceil()` to round up decimals
* Return `nil` if fuel cannot be retrieved
* The `resourceName` field is optional (set to `nil` if not needed)


# Voice add system

{% hint style="info" %}
Our HUD is already compatible with several voice systems: mumble-voip, pma-voice, saltychat, tokovoip.
{% endhint %}

## Custom Voice System Integration Guide

This guide explains how to integrate your own voice/proximity chat system with PHUD.

### 📋 Table of Contents

* How It Works
* Method 1: Using Event Handlers
* Method 2: Using Polling Loop
* Available Exports
* Real Examples
* Configuration
* Troubleshooting

***

### How It Works

PHUD needs to receive two pieces of information from your voice system:

1. **Voice Range** (number 1-3):
   * `1` = Whisper (short range)
   * `2` = Normal (medium range)
   * `3` = Shouting (long range)
2. **Talking Status** (boolean):
   * `true` = Player is currently talking
   * `false` = Player is not talking

The HUD will automatically update the voice indicator.

***

### Method 1: Using Event Handlers (Recommended)

This method listens to events triggered by your voice system.

#### Step 1: Create Your Integration File

Create a new file in this folder: `your-voice-system.lua`

#### Step 2: Use This Template

```lua
-- Listen to range change events
AddEventHandler('your_voice:setTalkingMode', function(mode)
    if exports['PHud'] then
        exports['PHud']:UpdateVoiceRange(mode) -- mode should be 1, 2, or 3
    end
end)

-- Listen to talking status events
AddEventHandler('your_voice:isTalking', function(talking)
    if exports['PHud'] then
        exports['PHud']:UpdateTalking(talking) -- talking should be true or false
    end
end)
```

#### Real Example: PMA Voice

```lua
-- Listen to mode change
AddEventHandler('pma-voice:setTalkingMode', function(mode)
    if exports['PHud'] then
        exports['PHud']:UpdateVoiceRange(mode)
    end
end)

-- Listen to radio talking
AddEventHandler('pma-voice:radioActive', function(talking)
    if exports['PHud'] then
        exports['PHud']:UpdateTalking(talking)
    end
end)

-- Continuous update loop for real-time status
CreateThread(function()
    while true do
        Wait(100)
        local playerState = LocalPlayer.state
        local currentRange = playerState.proximity and playerState.proximity.mode or 2
        local isSpeaking = MumbleIsPlayerTalking(PlayerId()) or NetworkIsPlayerTalking(PlayerId())

        if exports['PHud'] then
            exports['PHud']:UpdateVoice(currentRange, isSpeaking)
        end
    end
end)
```

***

### Method 2: Using Polling Loop

This method actively checks your voice system at regular intervals.

#### Template

```lua
Citizen.CreateThread(function()
    while true do
        Wait(200) -- Update every 200ms (recommended for voice)

        -- Get voice range from your system
        local voiceRange = exports['your-voice-system']:GetVoiceRange() -- Should return 1, 2, or 3

        -- Check if player is talking
        local isTalking = exports['your-voice-system']:IsTalking() -- Should return true/false

        -- Or use native functions
        -- local isTalking = NetworkIsPlayerTalking(PlayerId())

        -- Update the HUD
        if voiceRange and isTalking ~= nil then
            UpdateVoice(voiceRange, isTalking)
        end
    end
end)
```

#### Real Example: Mumble VOIP

```lua
CreateThread(function()
    while true do
        Wait(100)

        -- Get voice range
        local voiceRange = exports['mumble-voip']:GetVoiceRange() or 2

        -- Check if player is talking using native
        local isTalking = MumbleIsPlayerTalking(PlayerId())

        -- Update HUD
        UpdateVoice(voiceRange, isTalking)
    end
end)
```

***

### Available Exports

Use these functions in your integration file:

#### Update Functions

```lua
-- Update both range and talking status at once
UpdateVoice(range, talking)

-- Update only voice range (1-3)
UpdateVoiceRange(range)

-- Update only talking status (true/false)
UpdateTalking(talking)
```

#### Get Functions

```lua
-- Get current voice range
local range = exports['PHud']:GetVoiceRange()

-- Get current talking status
local talking = exports['PHud']:GetTalking()

-- Get both values
local voice = exports['PHud']:GetVoice()
-- Returns: { range = 2, talking = false }
```

#### Force Set Functions

```lua
-- Force set voice range without checking for changes
exports['PHud']:SetVoiceRange(2)

-- Force set talking status without checking for changes
exports['PHud']:SetTalking(true)
```

***

### Real Examples

#### PMA Voice (Complete Implementation)

```lua
AddEventHandler('pma-voice:setTalkingMode', function(mode)
    if exports['PHud'] then
        exports['PHud']:UpdateVoiceRange(mode)
    end
end)

AddEventHandler('pma-voice:radioActive', function(talking)
    if exports['PHud'] then
        exports['PHud']:UpdateTalking(talking)
    end
end)

CreateThread(function()
    while true do
        Wait(100)
        local playerState = LocalPlayer.state
        local currentRange = playerState.proximity and playerState.proximity.mode or 2
        local isSpeaking = MumbleIsPlayerTalking(PlayerId()) or NetworkIsPlayerTalking(PlayerId())

        if exports['PHud'] then
            exports['PHud']:UpdateVoice(currentRange, isSpeaking)
        end
    end
end)
```

#### Salty Chat

```lua
RegisterNetEvent('SaltyChat_OnSpeakingStateChange')
AddEventHandler('SaltyChat_OnSpeakingStateChange', function(talking)
    UpdateTalking(talking)
end)

RegisterNetEvent('SaltyChat_OnVoiceRangeChange')
AddEventHandler('SaltyChat_OnVoiceRangeChange', function(range, index)
    -- Convert Salty Chat range to 1-3 scale
    local phudRange = index or 2
    UpdateVoiceRange(phudRange)
end)

CreateThread(function()
    while true do
        Wait(200)

        -- Get current range from Salty Chat
        local range = exports['saltychat']:GetVoiceRange() or 2
        local talking = exports['saltychat']:IsTalking() or false

        UpdateVoice(range, talking)
    end
end)
```

#### TokoVOIP

```lua
RegisterNetEvent('tokovoip:setTalkingMode')
AddEventHandler('tokovoip:setTalkingMode', function(mode)
    UpdateVoiceRange(mode)
end)

CreateThread(function()
    while true do
        Wait(150)

        if exports['tokovoip'] then
            local voiceData = exports['tokovoip']:getPlayerData()

            if voiceData then
                local range = voiceData.voiceMode or 2
                local talking = voiceData.talking or false

                UpdateVoice(range, talking)
            end
        end
    end
end)
```

#### Simple Native Implementation (No Voice System)

```lua
CreateThread(function()
    local currentRange = 2 -- Default to normal

    while true do
        Wait(100)

        -- Check if player is talking using native
        local isTalking = NetworkIsPlayerTalking(PlayerId())

        -- Allow manual range switching with a key
        if IsControlJustPressed(0, 20) then -- Z key by default
            currentRange = currentRange + 1
            if currentRange > 3 then
                currentRange = 1
            end
        end

        UpdateVoice(currentRange, isTalking)
    end
end)
```

***

### Configuration

#### Step 1: Create Your Integration File

Create a new `.lua` file in the `phud/editable/voice/` folder.

**Example:**

* Create the file: `phud/editable/voice/custom.lua`
* In config.lua: `Config.VoiceSystem = "custom"`

**Important:** The filename (without `.lua`) must EXACTLY match the value you set in `Config.VoiceSystem`.

#### Step 2: Enable Your System in Config

Open `phud/config.lua` and set:

```lua
-- Use your specific system
Config.VoiceSystem = "custom" -- Filename without .lua extension
```

Available systems:

* `pma-voice` - PMA Voice (default)
* `mumble-voip` - Mumble VOIP
* `saltychat` - Salty Chat
* `tokovoip` - TokoVOIP
* Or your custom filename

#### Step 3: Restart Resource

```
ensure phud
```

***

### Troubleshooting

#### Voice Indicator Not Updating

1. **Check if your file is loaded**
   * Make sure the filename matches `Config.VoiceSystem`
   * File should be in `phud/editable/voice/` folder
2. **Check console for errors**
   * Look for Lua errors in F8 console
   * Check server console for warnings
3. **Verify data format**
   * Range should be 1, 2, or 3
   * Talking should be true or false
   * Use `print()` to debug values
4. **Check events are triggering**

   ```lua
   AddEventHandler('your_event', function(data)
       print("Voice event received:", data)
       -- Your code here
   end)
   ```

#### Talking Status Not Working

* Check if your voice system has a talking event
* Use native function: `NetworkIsPlayerTalking(PlayerId())`
* Try `MumbleIsPlayerTalking(PlayerId())` if using Mumble
* Reduce Wait time in polling loop (try 100ms)

#### Range Not Changing

* Verify your voice system sends range change events
* Check if range values are numbers (1, 2, 3)
* Make sure you're not sending strings ("1" instead of 1)

#### Auto-Detection Not Working

* Set specific system name instead of "auto"
* Check if your voice resource is started before PHUD
* Ensure your voice system resource name matches

***

### Common Native Functions

These native functions work with most voice systems:

```lua
-- Check if local player is talking
NetworkIsPlayerTalking(PlayerId())

-- Check if player is talking via Mumble
MumbleIsPlayerTalking(PlayerId())

-- Get local player ID
PlayerId()

-- Check player state (for pma-voice)
LocalPlayer.state.proximity
LocalPlayer.state.radioChannel
```

***

### Need Help?

If your voice system is not listed here:

1. Find out what events your system triggers
2. Or find out what exports your system provides
3. Or use native functions to detect talking
4. Check your system's documentation for available functions

Common event patterns:

* `system_name:setTalkingMode`
* `system_name:isTalking`
* `system_name:onVoiceChange`
* `system_name:radioActive`

Common export patterns:

* `exports['system_name']:GetVoiceRange()`
* `exports['system_name']:IsTalking()`
* `exports['system_name']:getPlayerData()`

Common native fallbacks:

* `NetworkIsPlayerTalking(PlayerId())`
* `MumbleIsPlayerTalking(PlayerId())`


# PCarplay


# Installation

{% stepper %}
{% step %}

#### Install

Install the resource on your Keymaster after purchasing the script. <mark style="color:$primary;">(</mark>[<mark style="color:$primary;">https://portal.cfx.re/</mark>](https://portal.cfx.re/)<mark style="color:$primary;">)</mark>&#x20;

{% endstep %}

{% step %}

#### Drag And Drop

Please place the carplay resource on your base.

{% endstep %}

{% step %}

### Start

Next, please ensure that the carplay resource is included in your `server.cfg` or `resources.cfg`.

{% endstep %}

{% step %}

### Config script

You must first add your YouTube API key in the *`server.cfg`* file (the instructions are available in the README included with the script). Once this is done, you can configure the CarPlay settings in the *`config.lua`* file.
{% endstep %}
{% endstepper %}

<details>

<summary>Here is the <code>config.lua</code> file. ESX/QB</summary>

```lua
-----------------------------------------------
-- PCarplay - Main Configuration
-- Configuration principale
-----------------------------------------------

Config = {}

-----------------------------------------------
-- Debug Mode / Mode Debug
-----------------------------------------------
Config.Debug = false

-----------------------------------------------
-- Framework / Framework
-----------------------------------------------
Config.Framework = 'ESX' -- ESX / QBCore
-- FR: Framework utilisé (ESX ou QBCore)
-- EN: Framework used (ESX or QBCore)

-----------------------------------------------
-- ESX Version / Version ESX
-----------------------------------------------
Config.ESXVersion = 'new' -- 'old' / 'new'
-- FR: Version d'ESX ('old' = getSharedObject via TriggerEvent, 'new' = getSharedObject via export)
-- EN: ESX Version ('old' = getSharedObject via TriggerEvent, 'new' = getSharedObject via export)

-------------------------------------------------
--  Langue / Language
-------------------------------------------------
Config.Locale = 'en' -- fr / en / de / es / ru / zh
-- FR: Langue utilisée pour les messages et traductions
-- EN: Language used for messages and translations


-----------------------------------------------
-- ESX Resource Name / Nom de la ressource ESX
-----------------------------------------------
Config.ESXResource = 'es_extended'

-----------------------------------------------
-- QBCore Resource Name / Nom de la ressource QBCore
-----------------------------------------------
Config.QBResource = 'qb-core'

-----------------------------------------------
-- Notification System / Système de notifications
-----------------------------------------------
Config.Notifs = 'ESX' -- ESX / QB / PNotif / Custom
-- FR: Type de système de notifications utilisé
-- EN: Type of notification system used
-- ESX: Utilise les notifications ESX natives
-- QB: Utilise les notifications QBCore
-- PNotif: Utilise le système PNotif
-- Custom: Utilise un système personnalisé

-----------------------------------------------
-- Inventory System / Système d'inventaire
-----------------------------------------------
Config.Inventory = 'auto' -- auto / default / ox / qs / qb
-- FR: Système d'inventaire utilisé (auto = détection automatique)
-- EN: Inventory system used (auto = automatic detection)

-----------------------------------------------
-- Restricted Item / Item Restreint
-----------------------------------------------
Config.RestrictedItem = {
    enabled = true,
    itemName = 'carplay_device'
}
-- FR: Si enabled = true, les joueurs doivent avoir l'item pour utiliser CarPlay
-- EN: If enabled = true, players must have the item to use CarPlay
-- itemName: Nom de l'item requis

-----------------------------------------------
-- CarPlay Command / Commande CarPlay
-----------------------------------------------
Config.Command = 'carplay'

-----------------------------------------------
-- Audio Settings / Paramètres Audio
-----------------------------------------------
Config.MaxDistance = 10.0

Config.Volume = {
    default = 50,
    min = 0,
    max = 100
}

Config.AllowedInVehicle = true

Config.ShareWithPassengers = true

Config.FadeOutDistance = true

Config.FadeStart = 3.0

-----------------------------------------------
-- UI Settings / Paramètres Interface
-----------------------------------------------
Config.UIPosition = {
    enabled = true,
    x = 50,
    y = 50
}

-------------------------------------------------
-- Traductions / Locales
-------------------------------------------------
LOCALES = {}

function _U(str, ...)
    if LOCALES[Config.Locale] ~= nil then
        if LOCALES[Config.Locale][str] ~= nil then
            return string.format(LOCALES[Config.Locale][str], ...)
        else
            return 'Translation [' .. str .. '] does not exist'
        end
    else
        return 'Locale [' .. Config.Locale .. '] does not exist'
    end
end

```

</details>


# API Youtube

To set up the YouTube API, follow the steps one by one.<br>

#### 1. Create a Google Cloud Project

1. Go to the [Google Cloud Console](https://console.cloud.google.com/)
2. Sign in with your Google account
3. At the top, click on **"Select a project"**
4. Click on **"NEW PROJECT"**
5. Give your project a name (e.g., "CarPlay FiveM")
6. Click **"Create"**
7. Wait a few seconds for the project to be created
8. Select your new project from the dropdown at the top

#### 2. Enable YouTube Data API v3

**IMPORTANT:** If you cannot find "YouTube Data API v3", follow these steps:

**Option A: Through the API Library**

1. In the left menu (☰), click **"APIs & Services"**
2. Click **"Library"**
3. In the search bar, type: `YouTube Data API v3`
4. Click the result **"YouTube Data API v3"**
5. Click the blue **"ENABLE"** button
6. Wait a few seconds for the API to be activated<br>

**Option B: Using the Search Bar**

1. Go to <https://console.cloud.google.com>
2. In the top search bar (🔍), type: `YouTube Data API v3`
3. Select **"YouTube Data API v3"** from the results
4. Click **"ENABLE"**

#### 3. Create an API Key

1. In the left menu, go to **"APIs & Services" > "Credentials"**
2. Click **"+ CREATE CREDENTIALS"** at the top
3. Select **"API Key"**
4. Your API key will be generated
5. (Recommended) Click **"RESTRICT KEY"** to secure it
6. Under **"API Restrictions"**, select **"YouTube Data API v3"**
7. Click **"Save"**

#### 4. Configure the API Key in FiveM

1. Open your `server.cfg` file
2. Add the following line with your API key:

```cfg
setr youtube_api_key "YOUR_API_KEY_HERE"
```


# Inventory config

{% hint style="success" %}
&#x20;The CarPlay system includes a configuration with multiple base inventories. This system is designed to verify that you possess the required item in order to use the CarPlay.
{% endhint %}

```lua
-----------------------------------------------
-- Restricted Item / Item Restreint
-----------------------------------------------
Config.RestrictedItem = {
    enabled = true,
    itemName = 'carplay_device'
}
-- FR: Si enabled = true, les joueurs doivent avoir l'item pour utiliser CarPlay
-- EN: If enabled = true, players must have the item to use CarPlay
-- itemName: Nom de l'item requis

```

{% hint style="info" %}
For the system to function at 100%, please place these items in their respective inventories.
{% endhint %}

QBCore Items

```lua
carplay_device = { name = 'carplay_device', label = 'CarPlay Device', weight = 500, type = 'item', image = 'carplay_device.png', unique = false, useable = true, shouldClose = true, description = 'A device that allows you to use CarPlay and play music in your vehicle' },

```

OX-Inventory Items

```lua
['carplay_device'] = {
    label = 'CarPlay Device',
    weight = 500,
    stack = true,
    close = true,
    description = 'A CarPlay device to listen to music in your vehicle',
    client = {
        image = 'carplay_device.png',
    }
}
```

QS-Inventory Items

```lua
['carplay_device'] = {
    name = 'carplay_device',
    label = 'CarPlay Device',
    weight = 500,
    type = 'item',
    image = 'carplay_device.png',
    unique = false,
    useable = false,
    shouldClose = true,
    combinable = nil,
    description = 'A CarPlay device to listen to music in your vehicle'
}
```


# PLocker


# Installation

{% stepper %}
{% step %}

#### Install

Install the resource on your Keymaster after purchasing the script. <mark style="color:$primary;">(</mark>[<mark style="color:$primary;">https://portal.cfx.re/</mark>](https://portal.cfx.re/)<mark style="color:$primary;">)</mark>&#x20;

{% endstep %}

{% step %}

#### Drag And Drop

Please place the Locker resource on your base.

{% endstep %}

{% step %}

### Start

Next, please ensure that the Locker resource is included in your `server.cfg` or `resources.cfg`.

{% endstep %}

{% step %}

### Config inventory

You can configure your own inventory system. By default, QS, OX, and QB are supported, but you can easily add or set up your own inventory.
{% endstep %}
{% endstepper %}

<details>

<summary>Here is the <code>config.lua</code> file. (ESX) </summary>

```lua
-----------------------------------------------
-- PE Script - Locker System Configuration
-- Script de casiers pour FiveM
-- Locker system script for FiveM
-----------------------------------------------

Config = {}

-------------------------------------------------
--  Debug Prints
-------------------------------------------------
Config.DebugPrint = true -- true / false
-- FR: Active ou désactive les messages de debug dans la console.
-- EN: Enables or disables debug messages in the console.


-------------------------------------------------
--  Langue / Language
-------------------------------------------------
Config.Locale = 'fr' -- fr / en / de / es / ru / zh
-- FR: Langue utilisée pour les messages et traductions
-- EN: Language used for messages and translations

-------------------------------------------------
-- Framework Resources / Ressources du framework
----------------------------------------------------
-- Name of your ESX resource (change if your server uses a custom ESX resource)
-- Nom de votre ressources ESX (a modifier si votre server utilise une ressource ESX Personnalisée)

Config.ESXResource = "es_extended"

-------------------------------------------------
--  Groupes administrateurs / Admin Group
-------------------------------------------------
Config.AdminGroup = 'admin' 
-- FR: Groupe ayant accès à toutes les fonctions du script
-- EN: Group with access to all script functions

-------------------------------------------------
--  Notification System / Système de notifications
-------------------------------------------------
Config.Notifs = 'PNotif' -- ESX / Custom / PNotif
-- FR: Type de système de notifications utilisé
-- EN: Type of notification system used
-- ESX: Utilise les notifications ESX de base
-- Custom: Utilise un système personnalisé (event 'locker:notify')
-- PNotif: Utilise le système PNotif

-------------------------------------------------
--  Limites des casiers / Locker Limits
-------------------------------------------------
Config.MaxLockers = 25
-- FR: Nombre maximum de casiers créés sur le serveur
-- EN: Maximum number of lockers that can be created on the server

Config.MaxSlotsPerLocker = 25
-- FR: Nombre maximum d'emplacements dans chaque casier
-- EN: Maximum number of slots per locker

Config.MaxWeightPerLocker = 250
-- FR: Poids maximum total pouvant être stocké dans un casier
-- EN: Maximum total weight that can be stored in a locker

-------------------------------------------------
--  Interaction System / Système d'interaction
-------------------------------------------------
Config.InteractionSystem = 'DrawMarker' -- DrawMarker / ox_target / Custom
-- FR: Type de système d'interaction utilisé
-- EN: Type of interaction system used
-- DrawMarker: Utilise les marqueurs et la touche E
-- ox_target: Utilise ox_target pour l'interaction
-- Custom: Utilise un système personnalisé (event 'locker:customInteraction')

-------------------------------------------------
--  Interaction / Interaction Settings
-------------------------------------------------
Config.InteractionDistance = 2.0
-- FR: Distance maximale pour interagir avec un casier
-- EN: Maximum distance to interact with a locker

Config.MarkerDrawDistance = 15.0
-- FR: Distance maximale pour voir les marqueurs
-- EN: Maximum distance to see markers

Config.Keybind = 38
-- FR: Touche pour interagir avec le casier (E par défaut)
-- EN: Key to interact with the locker (default E)

-------------------------------------------------
--  Marqueur / Marker Settings
-------------------------------------------------
Config.MarkerType = 1
-- FR: Type de marqueur utilisé dans le monde (1 = Cylindre au sol)
-- EN: Type of marker used in the world (1 = Cylinder on ground)

Config.MarkerSize = { x = 1.5, y = 1.5, z = 0.8 }
-- FR: Taille du marqueur / Size of the marker
Config.MarkerColor = { r = 52, g = 152, b = 219, a = 200 } 
-- FR: Couleur du marqueur en RGBA / Color of the marker in RGBA

Config.DrawMarkers = true         
-- FR: Afficher les marqueurs sur le monde / Draw markers in the world
Config.Use3DText = true           
-- FR: Afficher un texte 3D au-dessus du casier / Display 3D text above the locker

-------------------------------------------------
--  Discord Webhook Logs
-------------------------------------------------
Config.DiscordWebhook = ""
-- FR: URL du webhook Discord pour les logs (laissez vide pour désactiver)
-- EN: Discord webhook URL for logs (leave empty to disable)

Config.DiscordLogs = {
    enabled = true,
    createLocker = true,
    deleteLocker = true,
    updateLocker = true,
    depositItem = true,
    withdrawItem = true,
    openLocker = false,
}

Config.DiscordColors = {
    create = 5763719,    -- Bleu
    delete = 15548997,   -- Rouge
    update = 16776960,   -- Jaune
    deposit = 5763719,   -- Bleu
    withdraw = 15105570, -- Orange
    open = 8421504,      -- Gris
}

-------------------------------------------------
--  Traductions / Locales
-------------------------------------------------
LOCALES = {}

function _U(str, ...)
    if LOCALES[Config.Locale] ~= nil then
        if LOCALES[Config.Locale][str] ~= nil then
            return string.format(LOCALES[Config.Locale][str], ...)
        else
            return 'Translation [' .. str .. '] does not exist'
        end
    else
        return 'Locale [' .. Config.Locale .. '] does not exist'
    end
end
```

</details>

<details>

<summary>Here is the <code>config.lua</code> file. (QB) </summary>

```lua
-----------------------------------------------
-- PE Script - Locker System Configuration
-- Script de casiers pour FiveM
-- Locker system script for FiveM
-----------------------------------------------

Config = {}

-------------------------------------------------
--  Debug Prints
-------------------------------------------------
Config.DebugPrint = true -- true / false
-- FR: Active ou désactive les messages de debug dans la console.
-- EN: Enables or disables debug messages in the console.

-------------------------------------------------
--  Langue / Language
-------------------------------------------------
Config.Locale = 'fr' -- fr / en / de / es / ru / zh
-- FR: Langue utilisée pour les messages et traductions
-- EN: Language used for messages and translations

-------------------------------------------------
-- Framework Resources / Ressources du framework
----------------------------------------------------
-- Name of your QB resource (change if your server uses a custom QB resource)
-- Nom de votre ressources QB (a modifier si votre server utilise une ressource QB Personnalisée)

Config.QBResource = "qb-core"

-------------------------------------------------
--  Permissions administrateur / Admin Permission
-------------------------------------------------
Config.AdminLicenses = {
    'license:', -- Exemple de license
    -- Ajoutez les licenses des administrateurs ici
    -- FR: Ajoutez les licenses Steam/Rockstar des joueurs autorisés
    -- EN: Add the Steam/Rockstar licenses of authorized players
}
-- FR: Liste des licenses ayant accès aux fonctions administratives
-- EN: List of licenses with access to administrative functions

-------------------------------------------------
--  Notification System / Système de notifications
-------------------------------------------------
Config.Notifs = 'QB' -- QB / Custom / PNotif
-- FR: Type de système de notifications utilisé
-- EN: Type of notification system used
-- QB: Utilise les notifications QBCore de base
-- Custom: Utilise un système personnalisé (event 'locker:notify')
-- PNotif: Utilise le système PNotif

-------------------------------------------------
--  Limites des casiers / Locker Limits
-------------------------------------------------
Config.MaxLockers = 25
-- FR: Nombre maximum de casiers créés sur le serveur
-- EN: Maximum number of lockers that can be created on the server

Config.MaxSlotsPerLocker = 25
-- FR: Nombre maximum d'emplacements dans chaque casier
-- EN: Maximum number of slots per locker

Config.MaxWeightPerLocker = 250
-- FR: Poids maximum total pouvant être stocké dans un casier
-- EN: Maximum total weight that can be stored in a locker

-------------------------------------------------
--  Interaction System / Système d'interaction
-------------------------------------------------
Config.InteractionSystem = 'DrawMarker' -- DrawMarker / ox_target / Custom
-- FR: Type de système d'interaction utilisé
-- EN: Type of interaction system used
-- DrawMarker: Utilise les marqueurs et la touche E
-- ox_target: Utilise ox_target pour l'interaction
-- Custom: Utilise un système personnalisé (event 'locker:customInteraction')

-------------------------------------------------
--  Interaction / Interaction Settings
-------------------------------------------------
Config.InteractionDistance = 2.0
-- FR: Distance maximale pour interagir avec un casier
-- EN: Maximum distance to interact with a locker

Config.MarkerDrawDistance = 15.0
-- FR: Distance maximale pour voir les marqueurs
-- EN: Maximum distance to see markers

Config.Keybind = 38
-- FR: Touche pour interagir avec le casier (E par défaut)
-- EN: Key to interact with the locker (default E)

-------------------------------------------------
--  Marqueur / Marker Settings
-------------------------------------------------
Config.MarkerType = 1
-- FR: Type de marqueur utilisé dans le monde (1 = Cylindre au sol)
-- EN: Type of marker used in the world (1 = Cylinder on ground)

Config.MarkerSize = { x = 1.5, y = 1.5, z = 0.8 }
-- FR: Taille du marqueur / Size of the marker
Config.MarkerColor = { r = 52, g = 152, b = 219, a = 200 } 
-- FR: Couleur du marqueur en RGBA / Color of the marker in RGBA

Config.DrawMarkers = true         
-- FR: Afficher les marqueurs sur le monde / Draw markers in the world
Config.Use3DText = true           
-- FR: Afficher un texte 3D au-dessus du casier / Display 3D text above the locker

-------------------------------------------------
--  Discord Webhook Logs
-------------------------------------------------
Config.DiscordWebhook = ""
-- FR: URL du webhook Discord pour les logs (laissez vide pour désactiver)
-- EN: Discord webhook URL for logs (leave empty to disable)

Config.DiscordLogs = {
    enabled = true,
    createLocker = true,
    deleteLocker = true,
    updateLocker = true,
    depositItem = true,
    withdrawItem = true,
    openLocker = false,
}

Config.DiscordColors = {
    create = 5763719,    -- Bleu
    delete = 15548997,   -- Rouge
    update = 16776960,   -- Jaune
    deposit = 5763719,   -- Bleu
    withdraw = 15105570, -- Orange
    open = 8421504,      -- Gris
}

-------------------------------------------------
--  Traductions / Locales
-------------------------------------------------
LOCALES = {}

function _U(str, ...)
    if LOCALES[Config.Locale] ~= nil then
        if LOCALES[Config.Locale][str] ~= nil then
            return string.format(LOCALES[Config.Locale][str], ...)
        else
            return 'Translation [' .. str .. '] does not exist'
        end
    else
        return 'Locale [' .. Config.Locale .. '] does not exist'
    end
end

```

</details>


# Permissions

{% hint style="success" %}
Our locker system comes in two different versions: one for QB-Core and one for ESX. They are located in separate folders, and the permissions differ between QB-Core and ESX.
{% endhint %}

This is the ESX version, which uses ESX groups to manage the permission system.

```lua
-------------------------------------------------
--  Groupes administrateurs / Admin Group
-------------------------------------------------
Config.AdminGroup = 'admin' 
-- FR: Groupe ayant accès à toutes les fonctions du script
-- EN: Group with access to all script functions
```

And here is the QB-Core version, which uses a license-based system to simplify integration with QB-Core.

```lua
-------------------------------------------------
--  Permissions administrateur / Admin Permission
-------------------------------------------------
Config.AdminLicenses = {
    'license:', -- Exemple de license
    -- Ajoutez les licenses des administrateurs ici
    -- FR: Ajoutez les licenses Steam/Rockstar des joueurs autorisés
    -- EN: Add the Steam/Rockstar licenses of authorized players
}
-- FR: Liste des licenses ayant accès aux fonctions administratives
-- EN: List of licenses with access to administrative functions

```


# Notifications

{% hint style="success" %}
In the PLocker system, we have integrated the default notifications: ESX notifications for the ESX version, and QB-Core’s native notifications for the QB-Core version.
{% endhint %}

You can easily add your own notification system. To do this, go to `editable/notif/custom.lua` and set up your system using an event.\
Here is the configuration of our notification system integrated into PLocker.

```lua
-----------------------------------------------
-- PNotif Notification System
-- Système de notifications PNotif
-----------------------------------------------

Notify = {}

function Notify.Send(playerId, message, title, type, duration)
    if not playerId then
        print('^1[PLocker] Notify.Send: playerId est nil !^0')
        return
    end

    TriggerClientEvent('pnotif:sendNotification', playerId, {
        title = title or 'Notification',
        message = message or '',
        type = type or 'info',
        duration = duration or 4000
    })
end

```

#### And here is the `custom.lua` file, where you can integrate your own system.

```lua
-----------------------------------------------
-- NOTIFICATION SYSTEM
-- SYSTÈME DE NOTIFICATION
-- Easy integration with any inventory system (events/exports)
-- Intégration facile avec n'importe quel système d’inventaire (events/exports)
-----------------------------------------------

Notify = {}

--[[
    FR :
    Ce système de notification est entièrement personnalisable. 
    Les développeurs peuvent remplacer ou connecter leur propre 
    système de notifications directement au script PLocker en 
    modifiant cette fonction ou en utilisant leurs events/exports.

    EN :
    This notification system is fully customizable.
    Developers can replace or connect their own notification 
    system directly to the PLocker script by editing this function 
    or using their own events/exports.
--]]

function Notify.Send(playerId, message, title, type, duration)
    if not playerId then
        print('^1[PLocker] Notify.Send: playerId is nil!^0')
        return
    end

    TriggerClientEvent('locker:notify', playerId, {
        title = title or 'Notification',
        message = message or '',
        type = type or 'info',
        duration = duration or 4000
    })
end

```


# Inventory

{% hint style="success" %}
Our Locker system already includes several default inventories: QB-Inventory for QB-Core, OX, and Quasar Inventory. You can easily add your own inventory via exports.\
Here is the configuration of the Quasar inventory system integrated into our PLocker.
{% endhint %}

QS integration into PLocker

```lua
function InventoryBridge:GetPlayerInventory(xPlayer)
    local playerId = xPlayer.source
    local success, inventory = pcall(function()
        return exports['qs-inventory']:GetInventory(playerId)
    end)
    local formattedItems = {}

    if success and inventory then
        for slot, item in pairs(inventory) do
            if item and item.amount and item.amount > 0 then
                table.insert(formattedItems, {
                    name = item.name,
                    label = item.label or item.name,
                    count = item.amount,
                    metadata = item.info or {}
                })
            end
        end
    end

    return formattedItems
end

function InventoryBridge:AddItem(xPlayer, itemName, count)
    local playerId = xPlayer.source
    return exports['qs-inventory']:AddItem(playerId, itemName, count)
end

function InventoryBridge:RemoveItem(xPlayer, itemName, count)
    local playerId = xPlayer.source
    return exports['qs-inventory']:RemoveItem(playerId, itemName, count)
end

function InventoryBridge:GetItemCount(xPlayer, itemName)
    local playerId = xPlayer.source
    local success, inventory = pcall(function()
        return exports['qs-inventory']:GetInventory(playerId)
    end)

    if success and inventory then
        for slot, item in pairs(inventory) do
            if item and item.name == itemName then
                return item.amount or 0
            end
        end
    end

    return 0
end
```

{% hint style="info" %}
To integrate your inventory, go to `editable/inv/default/main.lua` and modify the code.\
If you need help, feel free to join our Discord.\
Here is the code from `default/main.lua`.
{% endhint %}

```lua
function InventoryBridge:GetPlayerInventory(xPlayer)
    local items = xPlayer.getInventory(true)
    local formattedItems = {}

    for i = 1, #items do
        if items[i].count > 0 then
            table.insert(formattedItems, {
                name = items[i].name,
                label = items[i].label,
                count = items[i].count,
                metadata = items[i].metadata or {}
            })
        end
    end

    return formattedItems
end

function InventoryBridge:AddItem(xPlayer, itemName, count)
    xPlayer.addInventoryItem(itemName, count)
    return true
end

function InventoryBridge:RemoveItem(xPlayer, itemName, count)
    xPlayer.removeInventoryItem(itemName, count)
    return true
end

function InventoryBridge:GetItemCount(xPlayer, itemName)
    local item = xPlayer.getInventoryItem(itemName)
    return item and item.count or 0
end
```


# Logs

In our locker system, multiple logs are available and sent via Discord webhooks.\
Here is our configuration for this. \
The log system allows tracking all user actions: locker creation, withdrawals, PIN code changes, and more.

```lua
-------------------------------------------------
--  Discord Webhook Logs
-------------------------------------------------
Config.DiscordWebhook = ""
-- FR: URL du webhook Discord pour les logs (laissez vide pour désactiver)
-- EN: Discord webhook URL for logs (leave empty to disable)

Config.DiscordLogs = {
    enabled = true,
    createLocker = true,
    deleteLocker = true,
    updateLocker = true,
    depositItem = true,
    withdrawItem = true,
    openLocker = false,
}

Config.DiscordColors = {
    create = 5763719,    -- Bleu
    delete = 15548997,   -- Rouge
    update = 16776960,   -- Jaune
    deposit = 5763719,   -- Bleu
    withdraw = 15105570, -- Orange
    open = 8421504,      -- Gris
}
```


# PNotif


# Installation

{% hint style="success" %}
Here is our fully standalone notification system, easy to configure and integrate&#x20;
{% endhint %}

{% stepper %}
{% step %}

#### Install

Install the resource on your Keymaster after purchasing the script. <mark style="color:$primary;">(</mark>[<mark style="color:$primary;">https://portal.cfx.re/</mark>](https://portal.cfx.re/)<mark style="color:$primary;">)</mark>&#x20;

{% endstep %}

{% step %}

#### Drag And Drop

Please place the notif resource on your base.

{% endstep %}

{% step %}

### Start

Next, please ensure that the notif resource is included in your `server.cfg` or `resources.cfg`.

{% endstep %}

{% step %}

### Config notifcation

You can easily configure the system via the `config.lua` file.

{% endstep %}
{% endstepper %}

<details>

<summary>Here is the <code>config.lua</code> file. </summary>

```lua
Config = {
    Background = 'rgba(18, 22, 30, 0.85)',

    UseSound = true,

    Position = {
        Align = 'top',
        Side = 'right',
    },

    Types = {
        ['success'] = {
            ['color'] = '#10b981',
            ['icon'] = 'mdi-check-circle'
        },
        ['error'] = {
            ['color'] = '#ef4444',
            ['icon'] = 'mdi-alert-circle'
        },
        ['warning'] = {
            ['color'] = '#f59e0b',
            ['icon'] = 'mdi-alert'
        },
        ['info'] = {
            ['color'] = '#3b82f6',
            ['icon'] = 'mdi-information'
        },
    }
}

```

</details>


# Exports and Events

{% hint style="success" %}
Here is the event and export to use in your scripts to display notifications.
{% endhint %}

Via export (Client-Side)

```lua
exports['PNotif']:sendNotification({
    title = 'Titre de la notification',
    message = 'Message de la notification',
    type = 'success',
    duration = 5000
})
```

Via Event (Serveur to Client)

```lua
TriggerClientEvent('pnotif:sendNotification', playerId, {
    title = 'Titre de la notification',
    message = 'Message de la notification',
    type = 'info',
    duration = 4000
})
```

Example

```lua
RegisterCommand('notifyServerTest', function(source, args, rawCommand)
    TriggerClientEvent('pnotif:sendNotification', source, {
        title = '~r~Titre~s~ ~g~Coloré~s~',
        message = 'Ceci est un test avec ~b~titre coloré~s~ depuis le serveur',
        type = 'success',
        duration = 5000
    })

    TriggerClientEvent('pnotif:sendNotification', source, {
        title = '~y~Attention~s~',
        message = 'Message ~o~important~s~ avec titre ~bold~en gras~s~',
        type = 'warning',
        duration = 5000
    })

    TriggerClientEvent('pnotif:sendNotification', source, {
        title = '~lg~Super~s~ ~bold~Succès~s~',
        message = 'Opération réussie avec ~g~titre en couleur~s~',
        type = 'info',
        duration = 5000
    })
end)

```

You can always use `esx.ShowNotification`.\
If you make any changes in your `es_extended`, go to the file `es_extended/client/functions.lua`.<br>

Replace&#x20;

```lua
ESX.ShowNotification = function(msg)
	SetNotificationTextEntry('STRING')
	AddTextComponentString(msg)
	DrawNotification(0,1)
end
```

Then, add this

```lua
function ESX.ShowNotification(message, type, data)
    if GetResourceState("PNotif") ~= "missing" then
        local _data = data or {}

        return exports['PNotif']:sendNotification({
            message = message,
            type = type or 'info',
            title = _data.title or 'Notification',
            duration = _data.duration or 4000
        })
    end
end
```


# Color Codes

### Color Codes

Use these codes in the title **AND** the message to add colors:

#### Main Colors

| Code  | Couleur | Utilisation       |
| ----- | ------- | ----------------- |
| `~r~` | Red     | `~r~Erreur~s~`    |
| `~g~` | Green   | `~g~Succès~s~`    |
| `~b~` | Blue    | `~b~Info~s~`      |
| `~o~` | Orange  | `~o~Attention~s~` |
| `~y~` | Yellow  | `~y~Alerte~s~`    |

#### Light Colors

| Code   | Couleur      | Utilisation        |
| ------ | ------------ | ------------------ |
| `~lr~` | Light Red    | `~lr~Important~s~` |
| `~lg~` | Light Green  | `~lg~Valide~s~`    |
| `~lb~` | Light Blue   | `~lb~Nouveau~s~`   |
| `~lo~` | Light Orange | `~lo~Conseil~s~`   |
| `~lp~` | Light Purple | `~lp~Spécial~s~`   |

#### Special Colors

| Code  | Couleur   | Utilisation                |
| ----- | --------- | -------------------------- |
| `~p~` | Purple    | `~p~Magie~s~`              |
| `~s~` | End color | `~r~Texte rouge~s~ normal` |
| `~w~` | End color | Alias de `~s~`             |

#### Text Formatting

| Code       | Style      | Utilisation                     |
| ---------- | ---------- | ------------------------------- |
| `~bold~`   | Fat        | `~bold~Texte important~\/bold~` |
| `~\/bold~` | Fat end    | Close the tag `~bold~`          |
| `~n~`      | Line break | Add a new line (message only)   |


# PNotif V2


# Installation

{% hint style="success" %}
Here is our fully standalone notification system, easy to configure and integrate&#x20;
{% endhint %}

{% stepper %}
{% step %}

#### Install

Install the resource on your Keymaster after purchasing the script. <mark style="color:$primary;">(</mark>[<mark style="color:$primary;">https://portal.cfx.re/</mark>](https://portal.cfx.re/)<mark style="color:$primary;">)</mark>&#x20;

{% endstep %}

{% step %}

#### Drag And Drop

Please place the notif resource on your base.

{% endstep %}

{% step %}

### Start

Next, please ensure that the notif resource is included in your `server.cfg` or `resources.cfg`.

{% endstep %}

{% step %}

### Config notifcation

You can easily configure the system via the `config.lua` file.

{% endstep %}
{% endstepper %}

<details>

<summary>Here is the <code>config.lua</code> file. </summary>

```
SOON
```

</details>


# Animated notifications

{% hint style="success" %}
You have the option to add an animation to the notifications. You can choose from four animations, or select none. Animations are applied using the trigger below.
{% endhint %}

via this trigger

## Serveur

```lua
    TriggerClientEvent('pnotifv2:sendNotification', -1, {
        message = message,
        title = title,
        type = 'server',
        animation = 'pulse', -- You can set the animation of your choice here. Available options are: pulse, bounce, flash, and shake. If you don’t want any animation, simply remove this line.
        duration = 8000
    })
```

## Client&#x20;

```
TriggerEvent('pnotifv2:sendNotification', {
    message = message,
    title = title,
    type = 'server', 
    animation = 'pulse', -- You can set the animation of your choice here. Available options are: pulse, bounce, flash, and shake. If you don’t want any animation, simply remove this line.
    duration = 8000
})

```


# Exports and Events

{% hint style="success" %}
Here is the event and export to use in your scripts to display notifications.
{% endhint %}

Via export (Client-Side)

```lua
exports['PNotifv2']:sendNotification({
    message = 'Your message here',
    type = 'info',
    title = 'Custom Header',
    duration = 5000
})
```

Via Event (Serveur to Client)

```lua
TriggerClientEvent('pnotifv2:sendNotification', source, {
    message = 'Your message here',
    type = 'info',
    title = 'Custom Header',
    duration = 5000
})
```

Example

```lua
RegisterCommand('notifyServerTest', function(source, args, rawCommand)
    TriggerClientEvent('pnotifv2:sendNotification', source, {
        title = '~r~Colored~s~ ~g~Title~s~',
        message = 'This is a test with a ~b~colored title~s~ sent from the server',
        type = 'success',
        duration = 5000
    })

    TriggerClientEvent('pnotifv2:sendNotification', source, {
        title = '~y~Warning~s~',
        message = '~o~Important~s~ message with a ~bold~bold title~s~',
        type = 'error',
        duration = 5000
    })

    TriggerClientEvent('pnotifv2:sendNotification', source, {
        title = '~lg~Great~s~ ~bold~Success~s~',
        message = 'Operation completed successfully with a ~g~colored title~s~',
        type = 'info',
        duration = 5000
    })

end)
```

You can always use `esx.ShowNotification`.\
If you make any changes in your `es_extended`, go to the file `es_extended/client/functions.lua`.<br>

**Replace**&#x20;

```lua
ESX.ShowNotification = function(msg)
	SetNotificationTextEntry('STRING')
	AddTextComponentString(msg)
	DrawNotification(0,1)
end
```

**Then, add this**

```lua
function ESX.ShowNotification(msg, texttype, length)
    local convert = {
        ["primary"] = 'info',
        ["police"] = 'lspd',
        ["ambulance"] = 'ems',
    }
    if not texttype then
        texttype = 'info'
    end
    if convert[texttype] then
        texttype = convert[texttype]
    end
    TriggerEvent('pnotifv2:sendNotification', {
        message = msg,
        type = texttype,
        duration = length or 5000
    })
end
```

To use the ESX notification trigger, use this one: <br>

#### Client

```lua
-- Simple
TriggerEvent('esx:showNotification', 'Message')

-- With type
TriggerEvent('esx:showNotification', 'Message', 'success')

-- Full
TriggerEvent('esx:showNotification', 'Message', 'bank', 8000)
```

#### Server

```lua
-- To a player
TriggerClientEvent('esx:showNotification', source, 'Message', 'success')

-- To everyone
TriggerClientEvent('esx:showNotification', -1, 'Message', 'server', 10000)

-- To a job
local xPlayers = ESX.GetExtendedPlayers('job', 'police')
for _, xPlayer in pairs(xPlayers) do
    TriggerClientEvent('esx:showNotification', xPlayer.source, 'Message', 'lspd')
end
```

QBCore \
You can always use `QBCore.Functions.Notify`.\
If you make any changes in your `qb-core`, go to the file `qb-core/client/functions.lua`.\
\
**Replace**

```lua
function QBCore.Functions.Notify(text, texttype, length, icon)
    local message = {
        action = 'notify',
        type = texttype or 'primary',
        length = length or 5000,
    }

    if type(text) == 'table' then
        message.text = text.text or 'Placeholder'
        message.caption = text.caption or 'Placeholder'
    else
        message.text = text
    end

    if icon then
        message.icon = icon
    end

    SendNUIMessage(message)
end
```

**Then, add this**

```lua
function QBCore.Functions.Notify(text, texttype, length)
    local convert = {
        ["primary"] = 'info',
        ["police"] = 'lspd',
        ["ambulance"] = 'ems',
    }
    if not texttype then
        texttype = 'info'
    end

    if convert[texttype] then
        texttype = convert[texttype]
    end

    if type(text) == "table" then
        local ttext = text.text or 'Placeholder'
        local caption = text.caption or 'Placeholder'
        length = length or 5000
        TriggerEvent('pnotifv2:sendNotification', {
            message = ttext,
            type = texttype,
            title = caption,
            duration = length
        })
    else
        length = length or 5000
        TriggerEvent('pnotifv2:sendNotification', {
            message = text,
            type = texttype,
            duration = length
        })
    end
end
```

## Client

```lua
-- Simple
QBCore.Functions.Notify('Message')

-- With type
QBCore.Functions.Notify('Message', 'success')

-- Full (type + duration)
QBCore.Functions.Notify('Message', 'bank', 8000)
```

## Server

```lua
-- To a player
TriggerClientEvent('QBCore:Notify', source, 'Message', 'success', 5000)

-- To everyone
for _, playerId in pairs(QBCore.Functions.GetPlayers()) do
    TriggerClientEvent('QBCore:Notify', playerId, 'Message', 'info', 10000)
end

-- To a specific job
local players = QBCore.Functions.GetPlayersByJob('police')
for _, playerId in pairs(players) do
    TriggerClientEvent('QBCore:Notify', playerId, 'Message', 'police', 5000)
end

```


# Color Codes

### Color Codes

Use these codes in the title **AND** the message to add colors:

#### Main Colors

| Code  | Couleur | Utilisation       |
| ----- | ------- | ----------------- |
| `~r~` | Red     | `~r~Erreur~s~`    |
| `~g~` | Green   | `~g~Succès~s~`    |
| `~b~` | Blue    | `~b~Info~s~`      |
| `~o~` | Orange  | `~o~Attention~s~` |
| `~y~` | Yellow  | `~y~Alerte~s~`    |

#### Light Colors

| Code   | Couleur      | Utilisation        |
| ------ | ------------ | ------------------ |
| `~lr~` | Light Red    | `~lr~Important~s~` |
| `~lg~` | Light Green  | `~lg~Valide~s~`    |
| `~lb~` | Light Blue   | `~lb~Nouveau~s~`   |
| `~lo~` | Light Orange | `~lo~Conseil~s~`   |
| `~lp~` | Light Purple | `~lp~Spécial~s~`   |

#### Special Colors

| Code  | Couleur   | Utilisation                |
| ----- | --------- | -------------------------- |
| `~p~` | Purple    | `~p~Magie~s~`              |
| `~s~` | End color | `~r~Texte rouge~s~ normal` |
| `~w~` | End color | Alias de `~s~`             |

#### Text Formatting

| Code       | Style      | Utilisation                     |
| ---------- | ---------- | ------------------------------- |
| `~bold~`   | Fat        | `~bold~Texte important~\/bold~` |
| `~\/bold~` | Fat end    | Close the tag `~bold~`          |
| `~n~`      | Line break | Add a new line (message only)   |


# Customized notifications and icons

{% hint style="success" %}
You can create your own notifications in the `config.lua` file, with custom icons and titles.
{% endhint %}

You can modify it like this.

```lua
        ['test'] = { -- Type
            ['color'] = '#ff6b35', -- Your color
            ['icon'] = 'mdi-server', -- Your icons (see below for help)
            ['title'] = 'SERVER' -- Your title, this title will be displayed in the ESX or QBCore trigger if you use "title"
        },
```

Here are the available types in the `config.lua` file.

<details>

<summary>Types</summary>

```lua
    Types = {
        ['server'] = {
            ['color'] = '#ff6b35',
            ['icon'] = 'mdi-server',
            ['title'] = 'SERVER'
        },

        ['announcement'] = {
            ['color'] = '#f7931e',
            ['icon'] = 'mdi-bullhorn',
            ['title'] = 'ANNOUNCEMENT'
        },

        ['info'] = {
            ['color'] = '#3b82f6',
            ['icon'] = 'mdi-information',
            ['title'] = 'INFO'
        },

        ['twitter'] = {
            ['color'] = '#1da1f2',
            ['icon'] = 'mdi-twitter',
            ['title'] = 'TWITTER'
        },

        ['phone'] = {
            ['color'] = '#10b981',
            ['icon'] = 'mdi-phone',
            ['title'] = 'PHONE'
        },

        ['saved'] = {
            ['color'] = '#10b981',
            ['icon'] = 'mdi-bookmark-check',
            ['title'] = 'SAVED'
        },

        ['error'] = {
            ['color'] = '#ef4444',
            ['icon'] = 'mdi-alert-circle',
            ['title'] = 'ERROR'
        },

        ['sms'] = {
            ['color'] = '#eab308',
            ['icon'] = 'mdi-message-text',
            ['title'] = 'NEW SMS'
        },

        ['bank'] = {
            ['color'] = '#06b6d4',
            ['icon'] = 'mdi-bank',
            ['title'] = 'P-BANK'
        },

        ['success'] = {
            ['color'] = '#22c55e',
            ['icon'] = 'mdi-check-circle',
            ['title'] = 'SUCCESS'
        },

        ['lspd'] = {
            ['color'] = '#3b82f6',
            ['icon'] = 'mdi-shield-star',
            ['title'] = 'LSPD'
        },

        ['ems'] = {
            ['color'] = '#ef4444',
            ['icon'] = 'mdi-ambulance',
            ['title'] = 'EMS'
        },

        ['lscustom'] = {
            ['color'] = '#f97316',
            ['icon'] = 'mdi-car-wrench',
            ['title'] = 'LS CUSTOMS'
        },

        ['ballas'] = {
            ['color'] = '#a855f7',
            ['icon'] = 'mdi-skull',
            ['title'] = 'BALLAS'
        },

        ['families'] = {
            ['color'] = '#22c55e',
            ['icon'] = 'mdi-account-group',
            ['title'] = 'FAMILIES'
        },

        ['vagos'] = {
            ['color'] = '#eab308',
            ['icon'] = 'mdi-pistol',
            ['title'] = 'VAGOS'
        },

        ['lostmc'] = {
            ['color'] = '#71717a',
            ['icon'] = 'mdi-bike',
            ['title'] = 'LOST MC'
        },

        ['bennys'] = {
            ['color'] = '#ec4899',
            ['icon'] = 'mdi-car-sports',
            ['title'] = 'BENNYS'
        },

        ['taxi'] = {
            ['color'] = '#eab308',
            ['icon'] = 'mdi-taxi',
            ['title'] = 'TAXI'
        },

        ['lsfd'] = {
            ['color'] = '#ef4444',
            ['icon'] = 'mdi-fire-truck',
            ['title'] = 'LSFD'
        },

        ['ranger'] = {
            ['color'] = '#84cc16',
            ['icon'] = 'mdi-pine-tree',
            ['title'] = 'RANGER'
        },

        ['statepolice'] = {
            ['color'] = '#06b6d4',
            ['icon'] = 'mdi-shield-check',
            ['title'] = 'STATE POLICE'
        },

        ['status'] = {
            ['color'] = '#8b5cf6',
            ['icon'] = 'mdi-chart-line',
            ['title'] = 'STATUS'
        }
```

</details>

## Icons

For the icons, you can use the guide below.

{% stepper %}
{% step %}

### Check site

Please visit the following website: <https://pictogrammers.com/library/mdi/>
{% endstep %}

{% step %}

### Search for your icon

Once you’ve found the icon you want, retrieve its name.
{% endstep %}

{% step %}

### Config

You will create your notification in the script’s `config.lua` file, and in `['icon']`, you must add `mdi-` before your icon’s name.
{% endstep %}
{% endstepper %}


# ShowHelpNotification

{% hint style="success" %}
Here, you will learn how to integrate our `showHelpNotification` system into your scripts, as well as into ESX or QBCore.
{% endhint %}

Events and exports

## Client&#x20;

```lua
exports['PNotifv2']:ShowHelpNotification('Press ~INPUT_PICKUP~ to pick up', true, 'white')
```

```lua
TriggerEvent('pnotifv2:showHelpNotification', 'Press ~INPUT_PICKUP~ to pick up', true, 'white')
```

ESX

```lua
TriggerEvent('esx:showHelpNotification', 'Press ~INPUT_PICKUP~ to pick up', true, 'white')
```

```lua
ESX.ShowHelpNotification('Press ~INPUT_PICKUP~ to pick up', true)
```

QBCORE

```lua
QBCore.Functions.ShowHelpNotification('~g~Press~s~ ~INPUT_PICKUP~ to talk to the contact', true)
```

## Integrate ESX

You can always use `esx.ShowHelpNotification`.\
If you make any changes in your `es_extended`, go to the file `es_extended/client/functions.lua`.

Replace

```lua
ESX.ShowHelpNotification = function(msg, thisFrame, beep, duration)
	AddTextEntry('esxHelpNotification', msg)

	if thisFrame then
		DisplayHelpTextThisFrame('esxHelpNotification', false)
	else
		if beep == nil then beep = true end
		BeginTextCommandDisplayHelp('esxHelpNotification')
		EndTextCommandDisplayHelp(0, false, beep, duration or -1)
	end
end
```

**Then, add this**

```lua
function ESX.ShowHelpNotification(msg, thisFrame, beep, duration)
    exports['PNotifv2']:ShowHelpNotification(msg, thisFrame or false)
end
```

Next, open the file `es_extended/client/main.lua` and add the following at the end of the file.

```lua
RegisterNetEvent('esx:showHelpNotification')
AddEventHandler('esx:showHelpNotification', function(msg, thisFrame, color)
    exports['PNotifv2']:ShowHelpNotification(msg, thisFrame or false)
end)
```

## Integrate QBCore

You can always use `QBCore.Functions.ShowHelpNotification`.\
If you need to make any changes, open the file `qb-core/client/functions.lua` and add the corresponding line **at the very end of the file**.

```lua
function QBCore.Functions.ShowHelpNotification(text, thisFrame, color)
    TriggerEvent('pnotifv2:showHelpNotification', text, thisFrame, color or 'white')
end
```


# PDrag


# Installation

{% stepper %}
{% step %}

#### Install

Install the resource on your Keymaster after purchasing the script. <mark style="color:$primary;">(</mark>[<mark style="color:$primary;">https://portal.cfx.re/</mark>](https://portal.cfx.re/)<mark style="color:$primary;">)</mark>&#x20;

{% endstep %}

{% step %}

#### Drag And Drop

Please place the Drag resource on your base.

{% endstep %}

{% step %}

### Start

Next, please ensure that the Drag resource is included in your `server.cfg` or `resources.cfg`.

{% endstep %}

{% step %}

### Config System

To configure PDrag, please open the `config.lua` file. Then, you can adjust the system settings as needed.
{% endstep %}
{% endstepper %}


# PPanelAdmin


# Installation

{% stepper %}
{% step %}

#### Install

Install the resource on your Keymaster after purchasing the script. <mark style="color:$primary;">(</mark>[<mark style="color:$primary;">https://portal.cfx.re/</mark>](https://portal.cfx.re/)<mark style="color:$primary;">)</mark>&#x20;

{% endstep %}

{% step %}

#### Drag And Drop

Please place the PanelAdmin resource on your base.

{% endstep %}

{% step %}

### Start

Next, please ensure that the PanelAdmin resource is included in your `server.cfg` or `resources.cfg`.

{% endstep %}

{% step %}

### Config System

To configure PPanelAdmin, please open the `config.lua` and `permissions.lua` file. Then, you can adjust the system settings as needed.

{% endstep %}
{% endstepper %}

<details>

<summary>Here is the <code>config.lua</code> file. (ESX)</summary>

```lua
-----------------------------------------------
-- PPanelAdmin - Main Configuration
-- Configuration principale
-----------------------------------------------

Config = {}

-------------------------------------------------
-- Framework / Framework
-------------------------------------------------
Config.Framework = 'ESX'

-------------------------------------------------
-- Langue / Language
-------------------------------------------------
Config.Locale = 'en' -- fr / en 
-- FR: Langue utilisée pour les messages et traductions
-- EN: Language used for messages and translations

-------------------------------------------------
-- Debug Mode / Mode Debug
-------------------------------------------------
Config.Debug = true

-------------------------------------------------
-- ESX Resource Name / Nom de la ressource ESX
-------------------------------------------------
Config.ESXResource = "es_extended"

-------------------------------------------------
-- Command / Commande
-------------------------------------------------
Config.Command = 'ppadmin'

-------------------------------------------------
-- Keybind Settings / Paramètres de touche
-------------------------------------------------
Config.Keybind = 'F5'
-- FR: Touche pour ouvrir le menu (F5, F6, F7, etc.)
-- EN: Key to open the menu (F5, F6, F7, etc.)
-- Touches disponibles / Available keys: F5, F6, F7, F8, F9, F10, etc.

-------------------------------------------------
-- Notification System / Système de notifications
-------------------------------------------------
Config.Notifs = 'ESX' -- ESX / PNotif / Custom
-- FR: Type de système de notifications utilisé
-- EN: Type of notification system used
-- ESX: Utilise les notifications ESX natives
-- PNotif: Utilise le système PNotif
-- Custom: Utilise un système personnalisé (event 'admin:notify')

-------------------------------------------------
-- Inventory System / Système d'inventaire
-------------------------------------------------
Config.Inventory = 'auto' -- 'auto' = Auto-detect / 'default' = ESX Default / 'ox' = ox_inventory / 'qs' = Quasar Inventory / 'qb' = qb-inventory
-- FR: Système d'inventaire utilisé (auto détecte automatiquement)
-- EN: Inventory system used (auto detects automatically)

-------------------------------------------------
-- Item Images Path / Chemin des images d'items
-------------------------------------------------
-- Pour Quasar Inventory, les images doivent être placées dans:
-- [qs-inventory]/html/images/
-- Format: [item_name].png

Config.ItemImagesPath = 'nui://qs-inventory/html/images/'

-------------------------------------------------
-- Search Settings / Paramètres de recherche
-------------------------------------------------
Config.EnableSearch = true
Config.SearchMinChars = 2

-------------------------------------------------
-- Give Settings / Paramètres de don
-------------------------------------------------
Config.MaxAmount = 999999
Config.DefaultAmount = 1

Config.EnableMetadata = true

-------------------------------------------------
-- Player Display Settings / Affichage des joueurs
-------------------------------------------------
Config.ShowPlayerID = true
Config.ShowPlayerIdentifier = true

-------------------------------------------------
-- Discord Webhooks Logs / Logs Discord
-------------------------------------------------
Config.DiscordLogs = {
    enabled = true,

    webhooks = {
        itemGives = '',
        panelAccess = '',
        quotaReset = '',
        accessDenied = ''
    },

    colors = {
        itemGives = 5763719,
        panelAccess = 3447003,
        quotaReset = 10181046,
        accessDenied = 15158332
    },

    logItemGives = true,
    logPanelAccess = true,
    logQuotaReset = true,
    logAccessDenied = true,

    includeSteamInfo = true,
    includeLicenseInfo = true,
    includeDiscordInfo = true,
    includeServerInfo = false,

    thumbnail = 'https://i.imgur.com/YourImageHere.png',

    footer = {
        text = 'PPanelAdmin Logs',
        icon_url = 'https://i.imgur.com/YourIconHere.png'
    }
}

-------------------------------------------------
-- Quota Reset Timer / Timer de réinitialisation du quota
-------------------------------------------------
Config.QuotaResetEnabled = true
-- FR: Active la réinitialisation automatique du quota
-- EN: Enable automatic quota reset

Config.QuotaResetInterval = 24 * 60 * 60 -- en secondes (24 heures par défaut)
-- FR: Intervalle de réinitialisation en secondes
-- EN: Reset interval in seconds
-- Exemples / Examples:
-- 1 heure / 1 hour: 60 * 60 = 3600
-- 12 heures / 12 hours: 12 * 60 * 60 = 43200
-- 24 heures / 24 hours: 24 * 60 * 60 = 86400
-- 7 jours / 7 days: 7 * 24 * 60 * 60 = 604800

-------------------------------------------------
-- Traductions / Locales
-------------------------------------------------
LOCALES = {}

function _U(str, ...)
    if LOCALES[Config.Locale] ~= nil then
        if LOCALES[Config.Locale][str] ~= nil then
            return string.format(LOCALES[Config.Locale][str], ...)
        else
            return 'Translation [' .. str .. '] does not exist'
        end
    else
        return 'Locale [' .. Config.Locale .. '] does not exist'
    end
end

```

</details>

<details>

<summary>Here is the <code>permissions.lua</code> file. (ESX)</summary>

```lua
-----------------------------------------------
-- PPanelAdmin - Permissions Configuration
-- Configuration des permissions
-----------------------------------------------

Permissions = {}

-------------------------------------------------
-- Admin Groups / Groupes administrateurs (ESX)
-------------------------------------------------
-- Les groupes qui ont accès au panel (pour ESX)
Permissions.AllowedGroups = {
    'admin',
    'superadmin',
    'mod'
}

-------------------------------------------------
-- Specific Permissions / Permissions spécifiques
-------------------------------------------------
-- Permissions par identifiant de joueur (ESX)
-- Format: ["identifier"] = true
Permissions.AllowedIdentifiers = {
    -- ["steam:110000XXXXXXXX"] = true,
    -- ["license:XXXXXXXXXXXXXXX"] = true,
}

-------------------------------------------------
-- Item Restrictions / Restrictions d'items
-------------------------------------------------
-- Items qui ne peuvent pas être donnés
Permissions.RestrictedItems = {
    -- "weapon_specialcarbine_mk2",
    -- "black_money",
}

-------------------------------------------------
-- Amount Limits by Group / Limites de quantité par groupe (ESX)
-------------------------------------------------
Permissions.AmountLimits = {
    ['admin'] = 100000,
    ['superadmin'] = 999999,
    ['mod'] = 50000
}

-------------------------------------------------
-- Metadata Permissions / Permissions des métadonnées
-------------------------------------------------
-- Groupes qui peuvent ajouter des métadonnées
Permissions.CanUseMetadata = {
    'admin',
    'superadmin'
}

-------------------------------------------------
-- Functions / Fonctions
-------------------------------------------------

function Permissions:HasAccess(xPlayer)
    if not xPlayer then return false end

    local playerGroup = xPlayer.getGroup and xPlayer.getGroup() or xPlayer.group

    for _, group in ipairs(self.AllowedGroups) do
        if playerGroup == group then
            return true
        end
    end

    local identifier = xPlayer.getIdentifier()
    if self.AllowedIdentifiers[identifier] then
        return true
    end

    return false
end

function Permissions:GetMaxAmount(xPlayer)
    if not xPlayer then return Config.DefaultAmount end

    local playerGroup = xPlayer.getGroup and xPlayer.getGroup() or xPlayer.group
    return self.AmountLimits[playerGroup] or Config.MaxAmount
end

function Permissions:GetAdminRole(xPlayer)
    if not xPlayer then return nil end

    local playerGroup = xPlayer.getGroup and xPlayer.getGroup() or xPlayer.group

    for _, group in ipairs(self.AllowedGroups) do
        if playerGroup == group then
            return playerGroup
        end
    end

    return nil
end

function Permissions:CanGiveItem(itemName)
    for _, restricted in ipairs(self.RestrictedItems) do
        if restricted == itemName then
            return false
        end
    end
    return true
end

function Permissions:CanUseMetadata(xPlayer)
    if not xPlayer then return false end

    local playerGroup = xPlayer.getGroup and xPlayer.getGroup() or xPlayer.group

    local metadataGroups = {
        'admin',
        'superadmin'
    }

    for _, group in ipairs(metadataGroups) do
        if playerGroup == group then
            return true
        end
    end

    return false
end
```

</details>

<details>

<summary>Here is the <code>config.lua</code> file. (QBCore)</summary>

```lua
-----------------------------------------------
-- PPanelAdmin - Main Configuration
-- Configuration principale
-----------------------------------------------

Config = {}

-------------------------------------------------
-- Framework / Framework
-------------------------------------------------
Config.Framework = 'QBCore' 


-------------------------------------------------
-- Langue / Language
-------------------------------------------------
Config.Locale = 'en' -- fr / en 
-- FR: Langue utilisée pour les messages et traductions
-- EN: Language used for messages and translations

-------------------------------------------------
-- Debug Mode / Mode Debug
-------------------------------------------------
Config.Debug = true

-------------------------------------------------
-- QBCore Resource Name / Nom de la ressource QBCore
-------------------------------------------------
Config.QBResource = "qb-core"

-------------------------------------------------
-- Command / Commande
-------------------------------------------------
Config.Command = 'ppadmin'

-------------------------------------------------
-- Keybind Settings / Paramètres de touche
-------------------------------------------------
Config.Keybind = 'F5'
-- FR: Touche pour ouvrir le menu (F5, F6, F7, etc.)
-- EN: Key to open the menu (F5, F6, F7, etc.)
-- Touches disponibles / Available keys: F5, F6, F7, F8, F9, F10, etc.

-------------------------------------------------
-- Notification System / Système de notifications
-------------------------------------------------
Config.Notifs = 'QB' -- / PNotif / Custom / QB
-- FR: Type de système de notifications utilisé
-- EN: Type of notification system used
-- QB: Utilise les notifications QB natives
-- PNotif: Utilise le système PNotif
-- Custom: Utilise un système personnalisé (event 'admin:notify')

-------------------------------------------------
-- Inventory System / Système d'inventaire
-------------------------------------------------
Config.Inventory = 'auto' -- 'auto' = Auto-detect / 'default' = QB Default / 'ox' = ox_inventory / 'qs' = Quasar Inventory / 'qb' = qb-inventory
-- FR: Système d'inventaire utilisé (auto détecte automatiquement)
-- EN: Inventory system used (auto detects automatically)

-------------------------------------------------
-- Item Images Path / Chemin des images d'items
-------------------------------------------------
-- Pour Quasar Inventory, les images doivent être placées dans:
-- [qs-inventory]/html/images/
-- Format: [item_name].png

Config.ItemImagesPath = 'nui://qs-inventory/html/images/'

-------------------------------------------------
-- Search Settings / Paramètres de recherche
-------------------------------------------------
Config.EnableSearch = true
Config.SearchMinChars = 2

-------------------------------------------------
-- Give Settings / Paramètres de don
-------------------------------------------------
Config.MaxAmount = 999999
Config.DefaultAmount = 1

Config.EnableMetadata = true

-------------------------------------------------
-- Player Display Settings / Affichage des joueurs
-------------------------------------------------
Config.ShowPlayerID = true
Config.ShowPlayerIdentifier = true

-------------------------------------------------
-- Discord Webhooks Logs / Logs Discord
-------------------------------------------------
Config.DiscordLogs = {
    enabled = true,

    webhooks = {
        itemGives = '',
        panelAccess = '',
        quotaReset = '',
        accessDenied = ''
    },

    colors = {
        itemGives = 5763719,
        panelAccess = 3447003,
        quotaReset = 10181046,
        accessDenied = 15158332
    },

    logItemGives = true,
    logPanelAccess = true,
    logQuotaReset = true,
    logAccessDenied = true,

    includeSteamInfo = true,
    includeLicenseInfo = true,
    includeDiscordInfo = true,
    includeServerInfo = false,

    thumbnail = 'https://i.imgur.com/YourImageHere.png',

    footer = {
        text = 'PPanelAdmin Logs',
        icon_url = 'https://i.imgur.com/YourIconHere.png'
    }
}

-------------------------------------------------
-- Quota Reset Timer / Timer de réinitialisation du quota
-------------------------------------------------
Config.QuotaResetEnabled = true
-- FR: Active la réinitialisation automatique du quota
-- EN: Enable automatic quota reset

Config.QuotaResetInterval = 24 * 60 * 60 -- en secondes (24 heures par défaut)
-- FR: Intervalle de réinitialisation en secondes
-- EN: Reset interval in seconds
-- Exemples / Examples:
-- 1 heure / 1 hour: 60 * 60 = 3600
-- 12 heures / 12 hours: 12 * 60 * 60 = 43200
-- 24 heures / 24 hours: 24 * 60 * 60 = 86400
-- 7 jours / 7 days: 7 * 24 * 60 * 60 = 604800

-------------------------------------------------
-- Traductions / Locales
-------------------------------------------------
LOCALES = {}

function _U(str, ...)
    if LOCALES[Config.Locale] ~= nil then
        if LOCALES[Config.Locale][str] ~= nil then
            return string.format(LOCALES[Config.Locale][str], ...)
        else
            return 'Translation [' .. str .. '] does not exist'
        end
    else
        return 'Locale [' .. Config.Locale .. '] does not exist'
    end
end

```

</details>

<details>

<summary>Here is the <code>permissions.lua</code> file. (QBCore)</summary>

```lua
-----------------------------------------------
-- PPanelAdmin - Permissions Configuration
-- Configuration des permissions
-----------------------------------------------

Permissions = {}


-------------------------------------------------
-- Admin Permissions (QBCore)
-------------------------------------------------
-- Permissions QBCore (basées sur license)
-- Format: ["license:XXXXXXXXXXXXXXX"] = true
Permissions.AllowedLicenses = {
    -- ["license:XXXXXXXXXXXXXXX"] = true,
    -- ["license:YYYYYYYYYYYYYYY"] = true,
}

-------------------------------------------------
-- Item Restrictions / Restrictions d'items
-------------------------------------------------
-- Items qui ne peuvent pas être donnés
Permissions.RestrictedItems = {
    -- "weapon_specialcarbine_mk2",
    -- "black_money",
}


-------------------------------------------------
-- Amount Limits by License (QBCore)
-------------------------------------------------
Permissions.AmountLimitsByLicense = {
    -- ["license:XXXXXXXXXXXXXXX"] = 100000,
    -- ["license:YYYYYYYYYYYYYYY"] = 50000,
}


-------------------------------------------------
-- Functions / Fonctions
-------------------------------------------------

function Permissions:HasAccess(xPlayer)
    if not xPlayer then return false end

    local license = xPlayer.PlayerData.license
    if self.AllowedLicenses[license] then
        return true
    end

    return false
end

function Permissions:GetMaxAmount(xPlayer)
    if not xPlayer then return Config.DefaultAmount end

    local license = xPlayer.PlayerData.license
    return self.AmountLimitsByLicense[license] or Config.MaxAmount
end

function Permissions:GetAdminRole(xPlayer)
    if not xPlayer then return nil end

    local license = xPlayer.PlayerData.license
    if self.AllowedLicenses[license] then
        return 'admin'
    end

    return nil
end

function Permissions:CanGiveItem(itemName)
    for _, restricted in ipairs(self.RestrictedItems) do
        if restricted == itemName then
            return false
        end
    end
    return true
end

function Permissions:CanUseMetadata(xPlayer)
    if not xPlayer then return false end

    local license = xPlayer.PlayerData.license
    return self.AllowedLicenses[license] or false
end

```

</details>


# Notifications

{% hint style="success" %}
In the PPanelAdmin system, we have integrated the default notifications: ESX notifications for the ESX version, and QB-Core’s native notifications for the QB-Core version.
{% endhint %}

You can easily add your own notification system. To do this, go to `editable/notif/custom.lua` and set up your system using an event.\
Here is the configuration of our notification system integrated into PPanelAdmin.

```lua
Notify = {}

function Notify.Send(playerId, message, title, type, duration)
    if not playerId then
        print('^1[PPanelAdmin] Notify.Send: playerId est nil !^0')
        return
    end

    TriggerClientEvent('pnotif:sendNotification', playerId, {
        title = title or 'Notification',
        message = message or '',
        type = type or 'info',
        duration = duration or 4000
    })
end
```

#### And here is the `custom.lua` file, where you can integrate your own system.

```lua
-----------------------------------------------
-- NOTIFICATION SYSTEM
-- SYSTÈME DE NOTIFICATION
-- Easy integration with any notification system (events/exports)
-- Intégration facile avec n'importe quel système de notification (events/exports)
-----------------------------------------------

Notify = {}

--[[
    FR :
    Ce système de notification est entièrement personnalisable.
    Les développeurs peuvent remplacer ou connecter leur propre
    système de notifications directement au script PPanelAdmin en
    modifiant cette fonction ou en utilisant leurs events/exports.

    EN :
    This notification system is fully customizable.
    Developers can replace or connect their own notification
    system directly to the PPanelAdmin script by editing this function
    or using their own events/exports.
--]]

function Notify.Send(playerId, message, title, type, duration)
    if not playerId then
        print('^1[PPanelAdmin] Notify.Send: playerId is nil!^0')
        return
    end

    -- CUSTOMIZE YOUR NOTIFICATION SYSTEM HERE / PERSONNALISEZ VOTRE SYSTÈME DE NOTIFICATION ICI
    -- Example / Exemple:
    TriggerClientEvent('admin:notify', playerId, {
        title = title or 'Admin Panel',
        message = message or '',
        type = type or 'info',
        duration = duration or 4000
    })
end

```


# Inventory

Our PanelAdmin system already includes several default inventories: QB-Inventory for QB-Core, OX, and Quasar Inventory. You can easily add your own inventory via exports.\
Here is the configuration of the Quasar inventory system integrated into our PPanelAdmin.

QS integration into PPanelAdmin

```lua
function InventoryBridge:GiveItem(xPlayer, itemName, count, metadata)
    local playerId = xPlayer.source
    local success, result = pcall(function()
        return exports['qs-inventory']:AddItem(playerId, itemName, count, nil, metadata)
    end)
    return success and result
end

function InventoryBridge:GetAllItems()
    local items = {}
    local success, qsItems = pcall(function()
        return exports['qs-inventory']:GetItemList()
    end)

    if success and qsItems then
        for itemName, itemData in pairs(qsItems) do
            table.insert(items, {
                name = itemName,
                label = itemData.label or itemName,
                weight = itemData.weight or 0,
                type = itemData.type or 'item',
                unique = itemData.unique or false
            })
        end
    end

    return items
end
```

{% hint style="info" %}
To integrate your inventory, go to `editable/inv/default/main.lua` and modify the code.\
If you need help, feel free to join our Discord.\
Here is the code from `default/main.lua`.
{% endhint %}

```lua
function InventoryBridge:GiveItem(xPlayer, itemName, count, metadata)
    if metadata then
        return false
    end

    local item = xPlayer.getInventoryItem(itemName)
    if not item then
        return false
    end

    if item.limit ~= -1 and (item.count + count) > item.limit then
        return false
    end

    xPlayer.addInventoryItem(itemName, count)
    return true
end

function InventoryBridge:GetAllItems()
    local items = {}

    if ESX and ESX.Items then
        for itemName, itemData in pairs(ESX.Items) do
            table.insert(items, {
                name = itemName,
                label = itemData.label or itemName,
                weight = itemData.weight or 0,
                type = itemData.type or 'item',
                unique = itemData.unique or false
            })
        end
    end

    return items
end

```


# PBlackmarket


# Installation

{% stepper %}
{% step %}

#### Install

Install the resource on your Keymaster after purchasing the script. <mark style="color:$primary;">(</mark>[<mark style="color:$primary;">https://portal.cfx.re/</mark>](https://portal.cfx.re/)<mark style="color:$primary;">)</mark>&#x20;

{% endstep %}

{% step %}

#### Drag And Drop

Please place the Blackmarket resource on your base.

{% endstep %}

{% step %}

### Start

Next, please ensure that the Blackmarket resource is included in your `server.cfg` or `resources.cfg`.

{% endstep %}

{% step %}

### Config System

To configure PBlackmarket, please open the `config.lua` and `permissions.lua` file. Then, you can adjust the system settings as needed.

{% endstep %}
{% endstepper %}

<details>

<summary>Here is the <code>config.lua</code> file. (ESX and QBCore)</summary>

```lua
-----------------------------------------------
-- PBlackMarket - Main Configuration
-- Configuration principale
-----------------------------------------------

Config = {}


-------------------------------------------------
-- Debug Mode / Mode Debug
-------------------------------------------------
Config.Debug = false
-- CLIENT AND SERVER PRINT 

-------------------------------------------------
-- Framework / Framework
-------------------------------------------------
Config.Framework = 'ESX' -- ESX / QBCore
-- FR: Framework utilisé (ESX ou QBCore)
-- EN: Framework used (ESX or QBCore)

-------------------------------------------------
-- Command / Commande
-------------------------------------------------
Config.Command = 'pbadmin'
-- FR: Commande pour ouvrir le menu de gestion du BlackMarket
-- EN: Command to open the BlackMarket management menu

-------------------------------------------------
-- ESX Version / Version ESX
-------------------------------------------------
Config.ESXVersion = 'new' -- 'old' / 'new'
-- FR: Version d'ESX ('old' = getSharedObject via TriggerEvent, 'new' = getSharedObject via export)
-- EN: ESX Version ('old' = getSharedObject via TriggerEvent, 'new' = getSharedObject via export)

-------------------------------------------------
--  Langue / Language
-------------------------------------------------
Config.Locale = 'en' -- fr / en / de / es / ru / zh
-- FR: Langue utilisée pour les messages et traductions
-- EN: Language used for messages and translations

-------------------------------------------------
-- ESX Resource Name / Nom de la ressource ESX
-------------------------------------------------
Config.ESXResource = 'es_extended'

-------------------------------------------------
-- QBCore Resource Name / Nom de la ressource QBCore
-------------------------------------------------
Config.QBResource = 'qb-core'

-------------------------------------------------
-- Inventory System / Système d'inventaire
-------------------------------------------------
Config.Inventory = 'auto' -- 'auto' = Auto-detect / 'default' = ESX/QB Default / 'ox' = ox_inventory / 'qs' = Quasar Inventory / 'qb' = qb-inventory
-- FR: Système d'inventaire utilisé (auto détecte automatiquement)
-- EN: Inventory system used (auto detects automatically)

-------------------------------------------------
-- Notification System / Système de notifications
-------------------------------------------------
Config.Notifs = 'ESX' -- ESX / PNotif / Custom / QB
-- FR: Type de système de notifications utilisé
-- EN: Type of notification system used
-- ESX: Utilise les notifications ESX natives
-- PNotif: Utilise le système PNotif
-- Custom: Utilise un système personnalisé

-------------------------------------------------
-- Interaction System / Système d'interaction
-------------------------------------------------
Config.InteractionSystem = 'DrawMarker' -- DrawMarker / ox_target / Custom
-- FR: Type de système d'interaction utilisé
-- EN: Type of interaction system used
-- DrawMarker: Utilise les marqueurs et la touche E
-- ox_target: Utilise ox_target pour l'interaction
-- Custom: Utilise un système personnalisé

-------------------------------------------------
-- Interaction Settings / Paramètres d'interaction
-------------------------------------------------
Config.InteractionDistance = 2.5
-- FR: Distance maximale pour interagir avec le NPC
-- EN: Maximum distance to interact with NPC

Config.MarkerDrawDistance = 10.0
-- FR: Distance maximale pour voir les marqueurs
-- EN: Maximum distance to see markers

Config.Keybind = 38 -- E key
-- FR: Touche pour interagir (E par défaut)
-- EN: Key to interact (default E)

-- Black Market NPCs
Config.NPCs = {
    {
        name = 'Black Market Dealer',
        model = 'g_m_m_armboss_01',
        coords = vector4(2433.876953, 4969.213379, 42.338501, 218.267715),
        blip = {
            enabled = true,
            sprite = 374,
            color = 1,
            scale = 0.7,
            label = 'Black Market'
        },
        marker = {
            enabled = true,
            type = 27,
            scale = { x = 1.5, y = 1.5, z = 1.0 },
            color = { r = 255, g = 0, b = 0, a = 100 }
        },
        allowedJobs = {}, -- Empty = everyone can access
        allowedGangs = {} -- For QB gangs
    },
    {
        name = 'Weapon Dealer',
        model = 'g_m_m_chigoon_02',
        coords = vector4(707.99, -966.98, 30.41, 0.0),
        blip = {
            enabled = false
        },
        marker = {
            enabled = true,
            type = 27,
            scale = { x = 1.5, y = 1.5, z = 1.0 },
            color = { r = 255, g = 0, b = 0, a = 100 }
        },
        allowedJobs = {'police'},
        allowedGangs = { 'lostmc', 'ballas' }
    }
}

-- Sell Items Configuration
Config.SellItems = {
    enabled = true,
    blackMoneyPercentage = 100,
    sellableItems = {
        'weed', 'coke', 'meth',
        'lockpick', 'advancedlockpick',
        'pistol_ammo', 'smg_ammo', 'rifle_ammo',
        'thermite',
    },
    pricePercentage = 60,
    customPrices = {
        ['weed'] = 300,
        ['coke'] = 600,
        ['meth'] = 900,
        ['lockpick'] = 150,
        ['advancedlockpick'] = 300,
        ['pistol_ammo'] = 50,
        ['smg_ammo'] = 75,
        ['rifle_ammo'] = 100
    }
}

-- Black Market Items
Config.Items = {
    {
        category = 'weapons',
        label = 'Weapons',
        items = {
            {
                name = 'WEAPON_PISTOL',
                label = 'Pistol',
                price = 5000,
                image = 'weapon_pistol.png',
                stock = 10, -- -1 for unlimited
                minRep = 0,  -- Minimum reputation required
                quantity = 1 -- Quantity received when purchasing
            },
            {
                name = 'WEAPON_PISTOL50',
                label = 'Pistol .50',
                price = 12000,
                image = 'weapon_pistol50.png',
                stock = 5,
                minRep = 100,
                quantity = 1
            },
            {
                name = 'WEAPON_SMG',
                label = 'SMG',
                price = 25000,
                image = 'weapon_smg.png',
                stock = 3,
                minRep = 250,
                quantity = 1
            },
            {
                name = 'WEAPON_ASSAULTRIFLE',
                label = 'AK-47',
                price = 45000,
                image = 'weapon_assaultrifle.png',
                stock = 2,
                minRep = 500,
                quantity = 1
            }
        }
    },
    {
        category = 'ammo',
        label = 'Ammunition',
        items = {
            {
                name = 'pistol_ammo',
                label = '9mm Ammo',
                price = 500,
                image = 'pistol_ammo.png',
                stock = -1,
                minRep = 0,
                quantity = 50 -- Receive 50 bullets per purchase
            },
            {
                name = 'smg_ammo',
                label = 'SMG AMMO',
                price = 750,
                image = 'smg_ammo.png',
                stock = -1,
                minRep = 50,
                quantity = 50
            },
            {
                name = 'rifle_ammo',
                label = 'Rifle Ammo',
                price = 1500,
                image = 'rifle_ammo.png',
                stock = -1,
                minRep = 100,
                quantity = 50
            }
        }
    },
    {
        category = 'drugs',
        label = 'Drugs',
        items = {
            {
                name = 'weed',
                label = 'Weed (10g)',
                price = 500,
                image = 'weed.png',
                stock = -1,
                minRep = 0,
                quantity = 10
            },
            {
                name = 'coke',
                label = 'Cocaine (5g)',
                price = 2000,
                image = 'coke_brick.png',
                stock = 20,
                minRep = 200,
                quantity = 5
            },
            {
                name = 'meth',
                label = 'Meth (5g)',
                price = 1500,
                image = 'meth.png',
                stock = 15,
                minRep = 150,
                quantity = 5
            }
        }
    },
    {
        category = 'materials',
        label = 'Materials',
        items = {
            {
                name = 'lockpick',
                label = 'Lockpick',
                price = 150,
                image = 'lockpick.png',
                stock = -1,
                minRep = 0,
                quantity = 1
            },
            {
                name = 'advancedlockpick',
                label = 'Advanced Lockpick',
                price = 500,
                image = 'advancedlockpick.png',
                stock = 10,
                minRep = 100,
                quantity = 1
            },
            {
                name = 'thermite',
                label = 'Thermite',
                price = 5000,
                image = 'thermite.png',
                stock = 5,
                minRep = 300,
                quantity = 1
            }
        }
    }
}

-- Reputation System
Config.Reputation = {
    enabled = true,
    startingRep = 0,
    gainPerPurchase = 10, -- Reputation gained per 1000$ spent
}

-- Purchase Limits
Config.PurchaseLimits = {
    enabled = true,
    resetTime = 86400, -- 24 hours in seconds
    limits = {
        weapons = 2,
        ammo = 5,
        drugs = 3,
        materials = 10
    }
}

-- Money Account
Config.MoneyAccount = 'black_money' -- 'money', 'black_money', 'bank', 'cash' (QB)

-- Database
Config.UseDatabase = true -- Save reputation and purchase history

--[[
    Auto Stock Reset / Réinitialisation Automatique du Stock
    --------------------------------------------------------

    Version Française :
    Système de réinitialisation automatique du stock.

    ⚠️ Important :
    - Lors de la première configuration, modifiez les valeurs AVANT de lancer le script.
    - Si le script est déjà lancé, vous pouvez modifier les paramètres via :
        → la base de données
        → le menu admin /pbadmin en jeu (IG)

    Ce système permet de réinitialiser automatiquement les stocks selon un intervalle défini.

    English Version:
    Automatic stock reset system.

    ⚠️ Important:
    - During the initial setup, edit the values BEFORE starting the script.
    - If the script is already running, you can adjust the settings through:
        → the database
        → the admin menu /pbadmin in-game (IG)

    This system automatically resets the item stock based on a defined interval.
]]
Config.AutoStockReset = {
    enabled = true,  -- Enable/Disable auto reset
    interval = 3600, -- Default: 3600 seconds (1 hour)
    -- Available intervals for admins:
    -- 600 = 10 minutes
    -- 1800 = 30 minutes
    -- 3600 = 1 hour
    -- 21600 = 6 hours
    -- 43200 = 12 hours
    -- 86400 = 24 hours
    -- 604800 = 7 days
    resetOnRestart = false -- Reset stock when server restarts
}

-------------------------------------------------
-- Cart & Delivery System / Système de Panier et Livraison
-------------------------------------------------
Config.Cart = {
    maxCartItems = 50,
    deliveryVehicle = 'burrito3', -- DON'T CHANGE PLS
    deliveryTime = 300,
    deliveryLocations = {
        vector4(-365.419769, 6092.676758, 31.436646, 70.866142),
        vector4(1618.760498, 3780.224121, 34.638062, 269.291351),
        vector4(1729.424194, 3316.074707, 41.209473, 229.606293),
        vector4(2534.241699, 2580.501221, 37.940674, 0.000000),
        vector4(-2220.118652, 2312.399902, 32.498169, 255.118103)
    },
    deliveryBlip = {
        sprite = 478,
        color = 5,
        scale = 1.0,
        label = 'Delivery Point'
    },
    vehicleBlip = {
        sprite = 67,
        color = 5,
        scale = 0.8,
        label = 'Delivery Vehicle'
    }
}

-------------------------------------------------
-- Discord Webhooks Logs / Logs Discord
-------------------------------------------------
Config.DiscordLogs = {
    enabled = true,

    -- INSERT WEBHOOK HERE 
    webhooks = {
        purchases = '',
        sales = '',
        deliveries = '',
        admin = '',
        reputation = ''
    },

    colors = {
        purchases = 3066993,
        sales = 15844367,
        deliveries = 3447003,
        admin = 15158332,
        reputation = 10181046
    },

    logPurchases = true,
    logSales = true,
    logDeliveries = true,
    logAdminActions = true,
    logReputationChanges = true,

    includeSteamInfo = true,
    includeLicenseInfo = true,
    includeDiscordInfo = true,
    includeServerInfo = false,

    thumbnail = 'https://i.imgur.com/YourImageHere.png',

    footer = {
        text = 'PBlackMarket Logs',
        icon_url = 'https://i.imgur.com/YourIconHere.png'
    }
}

-------------------------------------------------
-- Traductions / Locales
-------------------------------------------------
LOCALES = {}

function _U(str, ...)
    if LOCALES[Config.Locale] ~= nil then
        if LOCALES[Config.Locale][str] ~= nil then
            return string.format(LOCALES[Config.Locale][str], ...)
        else
            return 'Translation [' .. str .. '] does not exist'
        end
    else
        return 'Locale [' .. Config.Locale .. '] does not exist'
    end
end

```

</details>

<details>

<summary>Here is the <code>permissions.lua</code> file. (ESX and QBCore)</summary>

```lua
-----------------------------------------------
-- PBlackMarket - Permissions Configuration
-- Configuration des permissions
-----------------------------------------------

Permissions = {}

-------------------------------------------------
-- ESX Permissions / Permissions ESX
-------------------------------------------------
-- FR: Groupes ESX autorisés à accéder au panel admin
-- EN: ESX groups allowed to access the admin panel
Permissions.ESX = {
    allowedGroups = {
        'admin',
        'superadmin',
        'mod'
    }
}

-------------------------------------------------
-- QBCore Permissions / Permissions QBCore
-------------------------------------------------
-- FR: Permissions QBCore autorisées à accéder au panel admin
-- EN: QBCore permissions allowed to access the admin panel
Permissions.QBCore = {
    allowedPermissions = {
        'admin',
        'god'
    }
}

-- FR: Utiliser les licences Ace Permissions (true) ou les permissions QB internes (false)
-- EN: Use Ace Permissions licenses (true) or internal QB permissions (false)
Permissions.QBCore.useAcePermissions = true

-- FR: Licences Ace Permissions autorisées (seulement si useAcePermissions = true)
-- EN: Allowed Ace Permissions licenses (only if useAcePermissions = true)
-- Example: 'license:abc123', 'steam:110000123456789', 'discord:123456789012345678'
Permissions.QBCore.allowedLicenses = {
    --'license:12345',
    -- 'steam:110000123456789',
    -- 'discord:123456789012345678'
}

-------------------------------------------------
-- Custom Check Function / Fonction de vérification personnalisée
-------------------------------------------------
-- FR: Vous pouvez créer votre propre logique de vérification des permissions ici
-- EN: You can create your own permission check logic here

-- Example for ESX:
-- function Permissions.ESX.CustomCheck(xPlayer)
--     return xPlayer.identifier == 'char1:abc123' or xPlayer.job.name == 'admin'
-- end

-- Example for QBCore:
-- function Permissions.QBCore.CustomCheck(Player, source)
--     return Player.PlayerData.citizenid == 'ABC12345' or Player.PlayerData.job.name == 'police'
-- end

```

</details>


# Permissions

{% hint style="success" %}
Our BackMarket script uses the same folder for both QBCore and ESX. config/permissions.lua
{% endhint %}

This is the ESX version, which uses ESX groups to manage the permission system.

```lua
-------------------------------------------------
-- ESX Permissions / Permissions ESX
-------------------------------------------------
-- FR: Groupes ESX autorisés à accéder au panel admin
-- EN: ESX groups allowed to access the admin panel
Permissions.ESX = {
    allowedGroups = {
        'admin',
        'superadmin',
        'mod'
    }
}
```

Here is the QBCore version for permissions. You can use the group system or permissions via the FiveM license, Discord, or Steam.

```lua
-------------------------------------------------
-- QBCore Permissions / Permissions QBCore
-------------------------------------------------
-- FR: Permissions QBCore autorisées à accéder au panel admin
-- EN: QBCore permissions allowed to access the admin panel
Permissions.QBCore = {
    allowedPermissions = {
        'admin',
        'god'
    }
}

-- FR: Utiliser les licences Ace Permissions (true) ou les permissions QB internes (false)
-- EN: Use Ace Permissions licenses (true) or internal QB permissions (false)
Permissions.QBCore.useAcePermissions = true

-- FR: Licences Ace Permissions autorisées (seulement si useAcePermissions = true)
-- EN: Allowed Ace Permissions licenses (only if useAcePermissions = true)
-- Example: 'license:abc123', 'steam:110000123456789', 'discord:123456789012345678'
Permissions.QBCore.allowedLicenses = {
    --'license:12345',
    -- 'steam:110000123456789',
    -- 'discord:123456789012345678'
}
```


# Notifications

{% hint style="success" %}
In the **BlackMarket** system, we have integrated the default notifications: ESX notifications for the ESX version, and QB-Core’s native notifications for the QB-Core version.
{% endhint %}

You can easily add your own notification system. To do this, go to `editable/notif/custom.lua` and set up your system using an event.\
Here is the configuration of our notification system integrated into PLocker.

```lua
-----------------------------------------------
-- PNotif Notification System
-- Système de notifications PNotif
-----------------------------------------------

Notify = {}

function Notify.Send(playerId, message, title, type, duration)
    if not playerId then
        print('^1[PBlackMarket] Notify.Send: playerId est nil !^0')
        return
    end

    TriggerClientEvent('pnotif:sendNotification', playerId, {
        title = title or 'Black Market',
        message = message or '',
        type = type or 'info',
        duration = duration or 4000
    })
end

```

#### And here is the `custom.lua` file, where you can integrate your own system.

```lua
-----------------------------------------------
-- NOTIFICATION SYSTEM
-- SYSTÈME DE NOTIFICATION
-- Easy integration with any notification system (events/exports)
-- Intégration facile avec n'importe quel système de notification (events/exports)
-----------------------------------------------

Notify = {}

--[[
    FR :
    Ce système de notification est entièrement personnalisable.
    Les développeurs peuvent remplacer ou connecter leur propre
    système de notifications directement au script PBlackMarket en
    modifiant cette fonction ou en utilisant leurs events/exports.

    EN :
    This notification system is fully customizable.
    Developers can replace or connect their own notification
    system directly to the PBlackMarket script by editing this function
    or using their own events/exports.
--]]

function Notify.Send(playerId, message, title, type, duration)
    if not playerId then
        print('^1[PBlackMarket] Notify.Send: playerId is nil!^0')
        return
    end

    -- CUSTOMIZE YOUR NOTIFICATION SYSTEM HERE / PERSONNALISEZ VOTRE SYSTÈME DE NOTIFICATION ICI
    -- Example / Exemple:
    TriggerClientEvent('your_custom_notify', playerId, {
        title = title or 'Black Market',
        message = message or '',
        type = type or 'info',
        duration = duration or 4000
    })
end

```


# Target

{% hint style="success" %}
The **PBlackMarket** already includes **ox-target** and **drawmarker**, and you can also add your own target system to the script by editing the following file:\
`editable/interaction/custom.lua`
{% endhint %}

<details>

<summary>Custom target folder.</summary>

{% hint style="info" %}
Here is the custom configuration to add your own target system to the script.
{% endhint %}

```lua
InteractionHandler = {}

function InteractionHandler.Init()
    print('[PBlackMarket] ^3Custom interaction system loaded^7')
    print('[PBlackMarket] ^3Please implement your custom interaction logic here^7')
end

function InteractionHandler.Refresh()
end

function InteractionHandler.Cleanup()
end

```

</details>

<details>

<summary>Ox_target folder.</summary>

{% hint style="info" %}
Here is the **ox\_target** configuration for the script.
{% endhint %}

```lua
InteractionHandler = {}

local targetZones = {}
local isInitialized = false

function InteractionHandler.Init()
    InteractionHandler.Cleanup()
    Citizen.Wait(500)
    InteractionHandler.Refresh()
    isInitialized = true
end

function InteractionHandler.Refresh()
    InteractionHandler.Cleanup()
    Citizen.Wait(200)

    for i, npcConfig in pairs(Config.NPCs) do
        local zoneName = 'blackmarket_npc_' .. i

        if targetZones[i] then
            pcall(function()
                exports.ox_target:removeZone(targetZones[i])
            end)
            targetZones[i] = nil
        end

        local ok = pcall(function()
            exports.ox_target:addSphereZone({
                name = zoneName,
                coords = vector3(npcConfig.coords.x, npcConfig.coords.y, npcConfig.coords.z),
                radius = Config.InteractionDistance,
                debug = false,
                options = {
                    {
                        name = 'open_blackmarket_' .. i,
                        icon = 'fas fa-shopping-bag',
                        label = npcConfig.blip.label or 'Black Market',
                        canInteract = function()
                            return not uiOpen and HasAccess(npcConfig)
                        end,
                        onSelect = function()
                            if not uiOpen and HasAccess(npcConfig) then
                                currentNPC = npcConfig
                                OpenBlackMarket()
                            end
                        end
                    }
                }
            })
        end)

        if ok then
            targetZones[i] = zoneName
        end
    end
end

function InteractionHandler.Cleanup()
    for i, zoneName in pairs(targetZones) do
        pcall(function()
            exports.ox_target:removeZone(zoneName)
        end)
        Citizen.Wait(30)
    end

    targetZones = {}
end

```

</details>

<details>

<summary>Drawmarker folder.</summary>

{% hint style="info" %}
And here is the **drawmarker** configuration.
{% endhint %}

```lua
InteractionHandler = {}

function InteractionHandler.Init()
    Citizen.CreateThread(function()
        local isNearAnyNPC = false

        while true do
            local sleep = 1000
            local playerPed = PlayerPedId()
            local coords = GetEntityCoords(playerPed)
            local foundNearby = false

            for _, npcConfig in pairs(Config.NPCs) do
                local dist = #(coords - vector3(npcConfig.coords.x, npcConfig.coords.y, npcConfig.coords.z))

                if dist < Config.MarkerDrawDistance then
                    foundNearby = true
                    break
                end
            end

            if foundNearby and not isNearAnyNPC then
                isNearAnyNPC = true
                InteractionHandler.StartMarkerThread()
            elseif not foundNearby and isNearAnyNPC then
                isNearAnyNPC = false
            end

            Citizen.Wait(sleep)
        end
    end)
end

function InteractionHandler.StartMarkerThread()
    Citizen.CreateThread(function()
        while true do
            local playerPed = PlayerPedId()
            local coords = GetEntityCoords(playerPed)
            local nearMarker = false
            local nearNPC = false

            for i, npcConfig in pairs(Config.NPCs) do
                local dist = #(coords - vector3(npcConfig.coords.x, npcConfig.coords.y, npcConfig.coords.z))

                if dist < Config.MarkerDrawDistance then
                    nearMarker = true

                    if npcConfig.marker.enabled then
                        DrawMarker(
                            npcConfig.marker.type,
                            npcConfig.coords.x, npcConfig.coords.y, npcConfig.coords.z - 1.0,
                            0.0, 0.0, 0.0,
                            0.0, 0.0, 0.0,
                            npcConfig.marker.scale.x, npcConfig.marker.scale.y, npcConfig.marker.scale.z,
                            npcConfig.marker.color.r, npcConfig.marker.color.g, npcConfig.marker.color.b, npcConfig.marker.color.a,
                            false, false, 2, false, nil, nil, false
                        )
                    end
                end

                if dist < Config.InteractionDistance then
                    nearNPC = true
                    isNearMarker = true
                    currentNPC = npcConfig

                    if not uiOpen then
                        ShowHelpNotification(_U('press_to_open'))
                    end

                    if IsControlJustReleased(0, Config.Keybind) and not uiOpen then
                        if HasAccess(npcConfig) then
                            OpenBlackMarket()
                        end
                    end
                end
            end

            if not nearNPC then
                isNearMarker = false
                currentNPC = nil
            end

            if not nearMarker then
                break
            end

            Citizen.Wait(0)
        end
    end)
end

function InteractionHandler.Refresh()
end

function InteractionHandler.Cleanup()
end
```

</details>


# Inventory

{% hint style="success" %}
Our **BlackMarket** system already includes several default inventories: QB-Inventory for QB-Core, OX Inventory, and Quasar Inventory. You can easily add your own inventory via exports.\
Here is the configuration of the **Quasar** inventory system integrated into our BlackMarket.
{% endhint %}

QS integration into PBlackmarket

```lua
print("^2[PBlackMarket] Inventory QS-INVENTORY loaded ✓^0")

InventoryBridge = {}

function InventoryBridge.AddItem(source, itemName, count)
    return exports['qs-inventory']:AddItem(source, itemName, count)
end

function InventoryBridge.CanCarryItem(source, itemName, count)
    return exports['qs-inventory']:CanCarryItem(source, itemName, count)
end

function InventoryBridge.RemoveItem(source, itemName, count)
    return exports['qs-inventory']:RemoveItem(source, itemName, count)
end

function InventoryBridge.HasItem(source, itemName, count)
    local item = exports['qs-inventory']:GetItemByName(source, itemName)
    if not item then return false end
    return item.amount >= count
end

function InventoryBridge.GetPlayerItems(source, itemList)
    local items = {}

    for _, itemName in ipairs(itemList) do
        local item = exports['qs-inventory']:GetItemByName(source, itemName)
        if item and item.amount > 0 then
            table.insert(items, {
                name = itemName,
                label = item.label or itemName,
                count = item.amount,
                image = itemName .. '.png'
            })
        end
    end

    return items
end

```

{% hint style="info" %}
To integrate your inventory, go to `editable/inv/default/main.lua` and modify the code.\
If you need help, feel free to join our Discord.\
Here is the code from `default/main.lua`.
{% endhint %}

```lua
print("^2[PBlackMarket] Inventory DEFAULT (ESX) loaded ✓^0")

InventoryBridge = {}

local function IsWeapon(itemName)
    return string.sub(string.upper(itemName), 1, 7) == "WEAPON_"
end

function InventoryBridge.AddItem(source, itemName, count)
    if Config.Framework == 'ESX' then
        local xPlayer = ESX.GetPlayerFromId(source)
        if not xPlayer then return false end

        if IsWeapon(itemName) then
            xPlayer.addWeapon(string.upper(itemName), count or 0)
        else
            xPlayer.addInventoryItem(itemName, count)
        end
        return true
    elseif Config.Framework == 'QBCore' then
        local Player = QBCore.Functions.GetPlayer(source)
        if not Player then return false end

        return Player.Functions.AddItem(itemName, count)
    end

    return false
end

function InventoryBridge.CanCarryItem(source, itemName, count)
    if Config.Framework == 'ESX' then
        local xPlayer = ESX.GetPlayerFromId(source)
        if not xPlayer then return false end

        if IsWeapon(itemName) then
            if xPlayer.hasWeapon(string.upper(itemName)) then
                return false
            end
            return true
        end

        local item = xPlayer.getInventoryItem(itemName)
        if not item then return false end

        if item.limit ~= -1 and (item.count + count) > item.limit then
            return false
        end

        return xPlayer.canCarryItem(itemName, count)
    elseif Config.Framework == 'QBCore' then
        local Player = QBCore.Functions.GetPlayer(source)
        if not Player then return false end

        local totalWeight = QBCore.Player.GetTotalWeight(Player.PlayerData.items)
        local itemInfo = QBCore.Shared.Items[itemName:lower()]
        if itemInfo then
            local itemWeight = itemInfo.weight * count
            return (totalWeight + itemWeight) <= QBCore.Config.Player.MaxWeight
        end

        return true
    end

    return true
end

function InventoryBridge.RemoveItem(source, itemName, count)
    if Config.Framework == 'ESX' then
        local xPlayer = ESX.GetPlayerFromId(source)
        if not xPlayer then return false end

        if IsWeapon(itemName) then
            xPlayer.removeWeapon(string.upper(itemName))
        else
            xPlayer.removeInventoryItem(itemName, count)
        end
        return true
    elseif Config.Framework == 'QBCore' then
        local Player = QBCore.Functions.GetPlayer(source)
        if not Player then return false end

        return Player.Functions.RemoveItem(itemName, count)
    end

    return false
end

function InventoryBridge.HasItem(source, itemName, count)
    if Config.Framework == 'ESX' then
        local xPlayer = ESX.GetPlayerFromId(source)
        if not xPlayer then return false end

        if IsWeapon(itemName) then
            return xPlayer.hasWeapon(string.upper(itemName))
        end

        local item = xPlayer.getInventoryItem(itemName)
        if not item then return false end

        return item.count >= count
    elseif Config.Framework == 'QBCore' then
        local Player = QBCore.Functions.GetPlayer(source)
        if not Player then return false end

        local item = Player.Functions.GetItemByName(itemName)
        if not item then return false end

        return item.amount >= count
    end

    return false
end

function InventoryBridge.GetPlayerItems(source, itemList)
    local items = {}

    if Config.Framework == 'ESX' then
        local xPlayer = ESX.GetPlayerFromId(source)
        if not xPlayer then return items end

        for _, itemName in ipairs(itemList) do
            local item = xPlayer.getInventoryItem(itemName)
            if item and item.count > 0 then
                table.insert(items, {
                    name = itemName,
                    label = item.label,
                    count = item.count,
                    image = itemName .. '.png'
                })
            end
        end
    elseif Config.Framework == 'QBCore' then
        local Player = QBCore.Functions.GetPlayer(source)
        if not Player then return items end

        for _, itemName in ipairs(itemList) do
            local item = Player.Functions.GetItemByName(itemName)
            if item and item.amount > 0 then
                table.insert(items, {
                    name = itemName,
                    label = item.label or itemName,
                    count = item.amount,
                    image = itemName .. '.png'
                })
            end
        end
    end

    return items
end

```


# Logs

In our **BlackMarket** system, multiple logs are available and are sent via Discord webhooks.\
Here is the configuration for this.\
The log system allows tracking all BlackMarket-related user actions such as purchases, sales, deliveries, administrative actions, and reputation changes through dedicated Discord webhooks.

```lua
-------------------------------------------------
-- Discord Webhooks Logs / Logs Discord
-------------------------------------------------
Config.DiscordLogs = {
    enabled = true,

    -- INSERT WEBHOOK HERE 
    webhooks = {
        purchases = '',
        sales = '',
        deliveries = '',
        admin = '',
        reputation = ''
    },

    colors = {
        purchases = 3066993,
        sales = 15844367,
        deliveries = 3447003,
        admin = 15158332,
        reputation = 10181046
    },

    logPurchases = true,
    logSales = true,
    logDeliveries = true,
    logAdminActions = true,
    logReputationChanges = true,

    includeSteamInfo = true,
    includeLicenseInfo = true,
    includeDiscordInfo = true,
    includeServerInfo = false,

    thumbnail = 'https://i.imgur.com/YourImageHere.png',

    footer = {
        text = 'PBlackMarket Logs',
        icon_url = 'https://i.imgur.com/YourIconHere.png'
    }
}
```


