# DXS Gang System

<figure><img src="/files/cVkZTKeZpj4uhHpVNr1F" alt=""><figcaption></figcaption></figure>

### Dependencies

* es\_extended
* oxmysql
* esx\_menu\_default
* esx\_menu\_list
* esx\_context
* baseevents
* ox\_inventory (optional for stash/inventory integration)

### Installation

1. Place the resource in your resources folder.
2. Import `dxs_gangsystem.sql` into your database.
3. Add the resource to your server.cfg:

   ```cfg
   ensure DXS_GangSystem
   ```
4. Configure `config.lua` to your liking.

### Configuration

#### Discord Webhooks

Enable logging to track zone changes and gang activities:

```lua
Config.Webhooks = {
    Enabled = true,
    Url = 'YOUR_WEBHOOK_URL',
    Color = 3447003, -- Embed color
    Name = 'DXS Gang Logs'
}
```

#### Main Options

Edit `config.lua`:

* `Config.Locale`: Language ('en', 'fr', 'ar').
* `Config.Debug`: Toggle debug prints.
* `Config.SprayCooldown`: Time in seconds between sprays (Anti-spam).
* `Config.EnableOfflineProtection`: Enable/disable protection for offline gangs.
* `Config.MinOnlineForRaid`: Minimum members required online for a zone to be vulnerable.
* `Config.RequiredInfluence`: Influence required for Stash, Garage, etc.
* `Config.ZoneKillInfluenceGain` / `Config.ZoneDeathInfluenceLoss`: Influence modifiers.
* `Config.SprayBlacklistedAreas`: List of world areas where sprays are completely blocked.

Example for blacklisted areas:

```lua
Config.SprayBlacklistedAreas = {
    {
        coords = { x = 123.4, y = -567.8, z = 28.0 },
        radius = 80.0
    },
    {
        coords = { x = 200.0, y = 300.0, z = 30.0 },
        radius = 50.0
    }
}
```

Spray/cleanup settings:

* `Config.SprayItem` / `Config.SprayRemoverItem`: Items required to place/remove sprays.
* `Config.SpraysToCapture`: Sprays needed to fully capture a zone (100% influence).
* `Config.SprayTime` / `Config.CleanTime`: Progress duration (ms) for spraying/cleaning.
* `Config.SprayRewardInfluence`: Influence gained per successful spray.
* `Config.SprayRemoveInfluenceLoss`: Influence lost when a rival removes your spray.

### Commands

* `/gangmenu` (or whatever `Config.BossMenuCommand` is set to) - Open boss tablet for your gang (boss only).
* `/fixgangs` - Force refresh gangs/zones/sprays from the server.
* `/spray <text>` - Place a gang spray (requires `Config.SprayItem` and spray permission).
* `/refreshsprays` - Reload sprays from the database.
* `/clearsprays` - Delete all sprays from the database (admin/console).
* `/setupzones` - One-time helper to check/create initial zones (currently informational only).
* `/creategang` - Open gang creation menu (admin, or user with `Config.GangCreateItem`).
* `/gangs` - Open gang management tablet (admin).

### Notes

* **Optimization**: The zone decay system now runs every 30 minutes (configurable) and caches active gangs to ensure zero lag even with many zones.
* **Facility Rules**: Facilities (boss menu, stash, garage, crafting) are only available while the owning gang has the required influence in that zone; if influence drops to 0, all facilities and sprays in that zone are removed.
* **Permissions**: Facility placement (Set Stash, Set Garage, Set Crafting Table, Set Boss Menu) and usage (stash, garage, society money, member management, etc.) are controlled by per-member permissions inside the boss tablet, not just grade.
* **Zone Growth**: Sprays increase influence and grow zones directionally from the side where the spray is placed; removing enemy sprays decreases their influence and can destroy their zone and facilities when it hits 0%.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dxs-scripts.gitbook.io/home/documentation/fivem/dxs-gang-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
