# Camper System

### Overview

The **NTEAM Camper** script allows players to interact with campers as mobile stash units, customizable with XP-based rewards, NPC robbery mechanics, and breakable doors that require repair. The script supports both **ESX** and **QBCore** frameworks and is designed with modular exports for stash, outfit, dispatch, and minigames.

### Dependencies

This script requires the following dependencies:

* [`ox_lib`](https://overextended.github.io/ox_lib/) – for notifications, skill checks, and UI.
* [`ox_target`](https://overextended.github.io/ox_target/) – for target interaction or you can integrate any target system

#### Inventory Integration

By default, this script is configured to use [`ox_inventory`](https://overextended.github.io/ox_inventory/). However, the relevant sections (like `RegisterStash` and `OpenStash`) are left open in the code, allowing developers to easily switch to a different inventory system by modifying those specific functions.

Ensure you have all dependencies started **before** this resource in your `server.cfg`:

```cfg
ensure ox_lib
ensure ox_target
ensure ox_inventory -- optional, only if using ox_inventory
ensure nteam_camper
```

***

***

### 🔧 Configuration

#### Framework

```lua
Config.FrameWork = 'ESX' -- or 'QB'
```

Choose your server's framework.

#### General Labels

```lua
Config.OpenStash = 'Opening Stash'
Config.OpenOutfit = 'Opening Outfits'
Config.HandBrake = 'HandBrake'
Config.msg1 = 'There is no player nearby'
```

Used for in-game UI messages.

#### Target System

```lua
Config.Target = 'ox_target'
```

Specify your targeting system.

#### Camper Stash Coordinates

```lua
Config.StashCoords = vector3(1339.1172, 3105.7683, -92.1408)
```

Location where stash interaction happens.

***

### 📦 Stash System

#### Register & Open Camper Stash

```lua
RegisterStash(plate)
OpenStash(plate)
```

Stash is registered and opened using vehicle plate. Inventory uses `ox_inventory` stash type: `Camper-<plate>`.

#### Stash UI Options

* Change Password
* Open Stash

#### UI Export Example

```lua
lib.registerContext({ ... })
lib.showContext('camper_stash_options')
```

***

### 🎭 Outfits

```lua
outfit()
```

Placeholder for custom outfit system event. Customize it to integrate with your preferred outfit handler.

***

### 🧪 Taskbar & Notifications

#### Taskbar

```lua
lib.progressBar({...})
```

Custom progress bar that must return `true` to continue logic.

#### Notifications

```lua
lib.notify({title, description, type})
```

Standard LibNotify setup. You can modify type for success/info/error.

***

### 🧠 Minigames

```lua
MinigameDoors()
StashMiniGame()
```

Use `lib.skillCheck()` with simple `WASD` controls. Can be extended with difficulty or patterns.

***

### 🚨 Dispatch Event

```lua
Dispatch(data)
```

Optional hook. Can be used to send data to external dispatch or logging system.

***

### 🐱‍👤 NPC Robbery System

#### Loot Tables

```lua
Config.NpcRobberyItems = {
  [1] = {{item = 'water', amount = 1}},
  ...
}
```

You can define up to 10 item pools. Each item pool has a probability in `Config.ItemChances`.

#### Item Chances

```lua
Config.ItemChances = {
  [1] = 10,
  [2] = 20,
  ...
}
```

**Total must equal 100%**.

***

### 🧬 XP System

```lua
Config.XpSystem = {
  [1] = { maxXp = 10, xpGain = 0.1, extraReward = 0 },
  ...
}
```

Define leveling system:

* `maxXp`: threshold to reach the level.
* `xpGain`: XP per NPC robbery.
* `extraReward`: Bonus items given.

***

### 🔧 Breakable Camper Doors

```lua
Config.DoorCounter = 30
Config.CamperFixJob = {['mechanic'] = 0}
Config.RepairTime = 20000
```

After 30 failed hack attempts, camper doors break. Requires a mechanic to repair with a 20s taskbar.

***

### 🛡️ Protection System (NPC Defense)

```lua
Config.Npc = true
Config.NpcChance = 50
Config.NpcWeapon = 'WEAPON_PISTOL'
Config.NpcCoords = vector4(...)
```

Chance for NPC to spawn inside the camper to defend it. Spawns with specified weapon.

***

### 📌 Customization

To integrate with your server:

* Adjust **target**, **notification**, and **inventory** exports.
* Replace taskbar, skillcheck, and notification systems if needed.
* Expand stash and outfit logic for compatibility with third-party UIs.

***

### 🔄Camper System update 1.0.1

* Added support for changing the camper vehicle model via configuration.
* Enabled compatibility with alternative target systems by allowing replacement of ox\_target through the Config.Target setting.
* Additional language translations have been added at the bottom of config.lua to support localization.
* New Integration Event:\
  Introduced a server-side event that allows automatic assignment of vehicle ownership upon purchase or rental:\
  \
  \&#xNAN;*Server-side usage:*`TriggerEvent('nteam_camper:server:AddRentedOrBuyVehicle', source)`

&#x20;      *Client-to-server usage:*`TriggerServerEvent('nteam_camper:server:AddRentedOrBuyVehicle', source)`

*This event ensures that when a player buys or rents a camper, the vehicle is immediately recognized as owned by them. This allows instant access to ownership-based features such as entering the camper, inviting other players, and using the interior—without requiring a server restart or player relog.*

***

🔚 Credits & Contact\
\
This system was built by **NTEAM Development**. For inquiries, support, or updates, please visit our official **Discord** channels.


---

# 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://nteamdev.gitbook.io/nteam-development/camper-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.
