# Campement

### ⚡ Installation

* **Apply the SQL:**\
  Run the `camps.sql` file on your database.
* **Inventory Integration:**\
  You can use `item_camp_kit.sql` and `camp_kit.png` to add the camp starter item to your inventory system.

***

### 🏕️ Creating a Camp

There are four ways to create the base of a camp:

1. **With an Inventory Item**\
   Use the item `"camp_kit"` (or any item you set in `Config.ItemName`).
2. **From Client-side Event**

   ```lua
   TriggerServerEvent("botivrp-placecraft:CreateCamp", storageModel, pedCoords)
   -- Example:
   TriggerServerEvent("botivrp-placecraft:CreateCamp", "s_re_rcboatbox01x", GetEntityCoords(PlayerPedId()))
   ```
3. **From Server-side Event**

   ```lua
   TriggerClientEvent("BotivRP:CreateCampBase", source)
   ```
4. **Linking With Inventory (example with VORP)**

   ```lua
   local VORPInv = exports.vorp_inventory:vorp_inventoryApi()
   VORPInv.RegisterUsableItem("camp_base", function(data)
       VORPInv.subItem(data.source, "camp_base", 1)
       TriggerClientEvent("BotivRP:CreateCampBase", data.source)
       VORPInv.CloseInv(data.source)
   end)
   ```

***

### 📦 What Spawns in the World?

* **Two objects** appear near your player: a storage chest and a box of books.
  * **Storage Chest:**
    * Manages the camp’s storage.
    * Can be upgraded to increase storage capacity and camp radius (reflects camp’s overall level).
    * Can be lockpicked by non-members (if enabled). You may display an alert when a loot attempt is made.
  * **Book Box:**
    * Used to access the camp management menu.
    * Cannot be moved and remains at the center of the camp.

***

### ⚠️ Item Names & "label unknown"

If you see **"label unknown"** messages, it means you are using item names that don’t exist in your items database.\
**Solution:**\
Make sure every item listed matches an entry in your database:

```lua
items = {
    { quantity = 8, name = "nails" },
    { quantity = 10, name = "plank" }
}
```

***

### ⚙️ Configuration Highlights

**Example from `config.lua`:**

```lua
Config.DEBUG            = false
Config.ItemName         = "camp_kit"  -- Name of the item to start a camp. Empty "" to disable.
Config.PropCampCenter   = "p_bookbox01x" -- Center object (cannot move/delete)
Config.MaxMembers       = 5 -- Maximum members per camp
Config.CampTimeOut      = 20160 -- 2 weeks (minutes) until deletion if no member connects
Config.DistanceBtwCamp  = 100.0 -- Minimum distance between camps
Config.EnableCollision  = false -- Allow collision with tents/campfires (not recommended)
Config.ResourceRecovery = 100 -- % of resources recovered when dismantling
Config.canLockPick      = false -- Allow camp lockpicking by outsiders
Config.lockPickEvent    = "qbr-lockpick:client:openLockpick"
Config.ItemLockPick     = "lockpick"
Config.AlertLockPick    = false -- Alert members when lockpicking
-- Key bindings and other options below...
```

**Camp levels:**

```lua
Config.CampParametersPerLvl = {
    [0] = { stock_size = 35, camp_radius = 10.0 },
    [1] = { stock_size = 80, camp_radius = 20.0 },
    [2] = { stock_size = 140, camp_radius = 30.0 },
    [3] = { stock_size = 230, camp_radius = 40.0 },
    [4] = { stock_size = 350, camp_radius = 50.0 },
    [5] = { stock_size = 500, camp_radius = 60.0 },
}
```

**Other features:**

* Camp blip on map (`Config.AddBlips = true`)
* Zone blacklists
* Object recipes (craft requirements)
* Random camp names (Config.Adjectives / Config.Nouns)
* Translatable labels and menu (Config.Txt)
* Member rights and permissions (`Config.GROUP_RIGHT`)

***

### 📌 Notes

* The **book box** is the camp’s core and cannot be moved or deleted.
* Camps can be upgraded, customized, and managed by their owners/members.
* Item names for crafting and upgrades **must exist** in your items database.
* You can blacklist camp creation in certain zones.
