# Vehicle Rentals

<figure><img src="https://686536647-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvXGRk0kmhwggVh0ryaOs%2Fuploads%2FhmRDR8ALDaCiv1ioB3kV%2Fvehiclerentals.jpg?alt=media&#x26;token=169c916a-27d6-4af0-ae64-1bc7c54a9947" alt=""><figcaption></figcaption></figure>

### <mark style="color:blue;">Sql</mark>

There are 2 sql files included, the file named Sql is just the entire qb/qbx-garages sql updated with my additions.The other is the sql that would alter the current database table to include my additions. (just felt to include both for whatever reason).

<div align="center" data-full-width="true"><figure><img src="https://686536647-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvXGRk0kmhwggVh0ryaOs%2Fuploads%2FfwYJU6P5WTdGG5iOXS5A%2FAnnotation%202024-07-08%20142514.png?alt=media&#x26;token=ebc0a5a4-edd4-491d-bd87-fbd6588d011a" alt=""><figcaption></figcaption></figure></div>

## <mark style="color:orange;">Ox Inventory</mark>

Add the following in **ox\_inventory > data > items.lua**

```lua
["rental_paper"] = {
	label = "Rental Paper",
	weight = 0,
	stack = false,
	close = true,
	description = 'Proof of rental agreement',
},
```

#### <mark style="color:orange;">Item Images</mark>

* Copy the image/s within kevin-rentals > images
* Paste the image/s in ox\_inventory > web > images

## <mark style="color:red;">QB Inventory</mark>

Add the following to **qb-core > shared > items.lua**

{% code overflow="wrap" %}

```lua
rental_paper                     = { name = 'rental_paper', label = 'Rental Paper', weight = 0, type = 'item', image = 'rental_paper.png', unique = true, useable = true, shouldClose = true, description = 'Proof of rental agreement' },

```

{% endcode %}

## <mark style="color:yellow;">PS Inventory</mark>

If using ps inventory add the following snippet in ps-inventory > js > app.js around line 449

```lua
} else if (itemData.name == "rental_paper") {
    $(".item-info-title").html("<p>" + itemData.label + "</p>");
    $(".item-info-description").html(
        "<p><strong>Owner: </strong><span>" +
        (itemData.info.owner || "Unknown") +
        "</span></p><p><strong>Plate: </strong><span>" +
        (itemData.info.plate || "N/A") +
        "</span></p><p><strong>Vehicle: </strong><span>" +
        (itemData.info.vehicle || "N/A") +
        "</span></p><p><strong>Rental Date: </strong><span>" +
        (itemData.info.date || "N/A") +
        "</span></p><p><strong>Duration: </strong><span>" +
        (itemData.info.duration || "N/A") +
        "</span></p>"
    );
```

#### <mark style="color:red;">Item Images</mark>

* Copy the image/s within kevin-rentals > images
* Paste the images in qb inventory > html > images

***

## Creating new locations

```lua
        -- Example of a rental location created for mechanics
        {
            job = {
                 type = 'mechanic',
                 grade = 1
            },
            blip = {
                use = true,
                sprite = 560,
                color = 83,
                scale = 0.8,
                label = 'LS Mechanic Rentals',
            },
            icon = 'fa-solid fa-tools',
            ped = {
                model = `s_m_y_xmech_01`,
                coords = vector4(420.9, -1632.64, 29.25, 108.42),
                scenario = 'WORLD_HUMAN_CLIPBOARD',
            },
            vehicles = {
                {
                    hash = `towtruck`,
                    rentalCost = 120,
                    minRentalDays = 1,
                    maxRentalDays = 7,
                    fuelLevel = 100.0,
                    image = 'https://r2.fivemanage.com/CikOOzU9PmR8OMM0GvFLL/image/towtruck.png' -- The image of the vehicle
                },
            },
            coords = {
                vector4(419.17, -1629.9, 29.26, 320.22),
                vector4(416.74, -1628.19, 29.26, 319.72),
            }
        },
```

* gang: `array`
  * name: `string` The name of the gang
  * grade: `number` The grade of the gang
* job: `table`
  * type: `string` The type of the job (e.g., 'mechanic')
  * grade: `number` The grade of the job
* blip: `table`
  * use: `boolean` Whether to use the blip (true/false)
  * sprite: `number` The sprite ID for the blip
  * color: `number` The color ID for the blip
  * scale: `number` The scale of the blip
  * label: `number` The label for the blip
* warpPlayer: `boolean` Warps the player into the vehicle
* icon: `string` The icon for the rental location (FontAwesome icon class)
* ped: `table`
  * model: `hash` The model hash for the NPC
  * coords: `vector4` The coordinates and heading for the NPC (vector4)
  * scenario: `string` The scenario the NPC will perform
* vehicles: `table`
  * hash: `hash` The vehicle hash
  * rentalCost: `number` The price of the vehicle rental
  * minRentalDays: `number` The minimum rental days
  * maxRentalDays: `number` The maximum rental days
  * fuelLevel: `number` The fuel level of the vehicle
  * image: `string` The image URL of the vehicle
* coords: `table` List of coordinates for vehicle spawn points (vector4)

## Exports

Checks if a vehicle is a rental vehicle and returns a boolean

<pre class="language-lua"><code class="lang-lua"><strong>exports['kevin-rentals']:isRentalVehicle(plate, hash)
</strong></code></pre>

### Useage

```lua
-- Export Useage [client/server]
local isRental = exports['kevin-rentals']:isRentalVehicle('45IRT635', `75131841`)
if isRental then
    print('This vehicle is a rental and cant be sold')
    return
end
```
