> For the complete documentation index, see [llms.txt](https://rex-studio.gitbook.io/rex-studio-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rex-studio.gitbook.io/rex-studio-docs/fivem-low-cost/vehicle-rental.md).

# VEHICLE RENTAL

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

### 📖 Description

Vehicle rental script for FiveM compatible with **ESX** and **QB-Core**. This script allows players to rent vehicles at different locations on the map, with an automatic hourly billing system and damage management.

### ✨ Features

* ✅ Compatible with ESX and QB-Core
* ✅ Modern and intuitive NUI interface
* ✅ Automatic hourly billing system
* ✅ Damage management with financial penalties
* ✅ Vehicle return system
* ✅ Map blips for rental locations
* ✅ NPCs with customizable props
* ✅ Support for multiple simultaneous locations
* ✅ Maximum 10 vehicles per location
* ✅ Automatic license plate generation

### 🚀 Installation

#### Prerequisites

* ESX or QB-Core framework installed and functional
* FiveM Server with base resources

#### Installation Steps

1. **Download the script** and place it in your `resources` folder
2. **Rename the folder** to `rental` (or your preferred name)
3. **Configure the framework** in `shared/_main.lua` :

   ```lua
   ConfigShared.Core = "ESX" -- or "QB-Core"
   ```
4. **Add the script** to your `server.cfg` :

   ```
   ensure rental
   ```
5. **Restart your server**

### ⚙️ Configuration

#### Framework Configuration

Open `shared/_main.lua` to configure your framework:

```lua
ConfigShared.Core = "ESX" -- "ESX" or "QB-Core"
ConfigShared.CoreExport = function()
    return exports['es_extended']:getSharedObject()
    -- or for QB-Core:
    -- return exports['qb-core']:GetCoreObject()
end
ConfigShared.Debug = true -- Enable debug messages
```

#### Location Configuration

All main configurations are located in `shared/config.lua`:

**General Settings**

```lua
Config = {
    Fee = 150,              -- Price per rental hour
    SetBlip = true,         -- Show blips on map
    MaxTime = 10,           -- Maximum time before billing (in seconds)
    Locations = {
        -- Your locations here
    }
}
```

**Location Structure**

```lua
["LOCATION_NAME"] = {
    coords = {
        model = "s_f_y_baywatch_01",              -- NPC model (Ped)
        rent = vector3(x, y, z),                   -- NPC position
        spawn = vector3(x, y, z),                  -- Vehicle spawn position
        teleport = vector3(x, y, z),               -- Teleport position after return
        heading = 190.0                            -- NPC orientation
    },
    spawn2 = {
        pos = vector3(x, y, z)                     -- Alternative spawn position
    },
    prop = {
        model = "prop_surf_board_01",              -- Prop model (nil to disable)
        coordEntity = vector3(0, 0, 0),           -- Offset from entity center
        coordAxis = vector3(-80, 0, 0),           -- Axis rotation
    },
    Vehicles = {
        {name = "seashark", label = "Seashark", price = 500},
        -- Maximum 10 vehicles
    },
    Blip = {
        sprite = 409,                              -- Blip sprite
        color = 36,                                -- Blip color
        name = "Rental Test 1"                     -- Blip name
    }
}
```

#### Text Configuration

Texts are configurable in `shared/dialogue.lua`:

```lua
Config.Dialogue = {
    Location = "Press [~o~E~s~] to Rent",
    Return = "Press [~o~E~s~] to Return the Rental",
    MessageLocation = "You are renting equipment...",
    VehicleBlocked = "A vehicle is blocking the exit...",
    Bill = "The rental service has charged you...",
    NoReturn = "You have not returned your last rental...",
    Damage = "You have damaged the equipment...",
    GoodReturn = "Thank you for your return..."
}
```

### 🎮 Usage

#### For Players

1. **Approach** a rental NPC (visible on the map with a blip)
2. **Press E** to open the rental menu
3. **Select a vehicle** from the list
4. **Pay** the rental price
5. **Pick up your vehicle** at the indicated spawn point
6. **Return the vehicle** at the return point before the time expires

#### Billing System

* **Automatic billing**: If the player exceeds the allowed time, they are automatically billed
* **Damage management**: Vehicle damage is charged upon return
* **Payment priority**: The system first withdraws from the bank, then from cash

### 📁 File Structure

```
rental/
├── client/
│   ├── _main.lua          # Main client script
│   └── function.lua        # Client functions
├── server/
│   └── _main.lua          # Main server script
├── shared/
│   ├── _main.lua          # Framework configuration
│   ├── config.lua         # Location configuration
│   ├── dialogue.lua       # Texts and dialogues
│   └── function.lua       # Shared functions
├── html/
│   ├── index.html         # NUI interface
│   ├── css/
│   │   └── style.css      # CSS styles
│   ├── js/
│   │   └── index.js       # JavaScript script
│   └── img/               # Vehicle images
└── fxmanifest.lua         # FiveM manifest
```

### 🔧 Customization

#### Adding a New Location

1. Open `shared/config.lua`
2. Add a new entry in `Config.Locations`:

```lua
["MY_NEW_LOCATION"] = {
    coords = {
        model = "a_m_y_cyclist_01",
        rent = vector3(-1204.074707, -1554.830811, 4.359009),
        spawn = vector3(-1204.048340, -1542.659302, 4.291626),
        teleport = vector3(-1205.525269, -1551.942871, 4.359009-0.97),
        heading = 0.0
    },
    spawn2 = {
        pos = vector3(-1204.048340, -1542.659302, 4.291626)
    },
    prop = {
        model = nil,
        coordEntity = vector3(0, 0, 0),
        coordAxis = vector3(0, 0, 0),
    },
    Vehicles = {
        {name = "zentorno", label = "Zentorno", price = 800},
    },
    Blip = {
        sprite = 409,
        color = 36,
        name = "My Rental"
    }
}
```

#### Changing NPC Models

Check the list of Ped models at: <https://wiki.rage.mp/index.php?title=Peds>

#### Changing Props

Check prop models at: <https://gtahash.ru/>

#### Modifying Blips

Check blip sprites and colors at: <https://wiki.rage.mp/index.php?title=Blips>

### 🐛 Troubleshooting

#### Menu doesn't open

* Check that the script is started (`ensure rental`)
* Check for errors in the F8 console
* Make sure you are close enough to the NPC (< 2.5 units)

#### Vehicle doesn't spawn

* Check that the spawn point is not blocked
* Check that the vehicle name is correct
* Check for errors in the server console

#### Billing doesn't work

* Check the framework configuration in `shared/_main.lua`
* Check that the player has enough money
* Enable debug to see logs: `ConfigShared.Debug = true`

### 📝 Important Notes

* ⚠️ **Maximum 10 vehicles** per location in configuration
* ⚠️ The system checks rentals every **30 seconds**
* ⚠️ Make sure spawn coordinates are **free and accessible**
* ⚠️ The script automatically generates plates in **"LOC XXX"** format

***

**Note**: This script is compatible with ESX and QB-Core frameworks. Make sure to properly configure the framework in `shared/_main.lua` before use.
