# Harness + Seatbelt

## Installation

{% tabs fullWidth="true" %}
{% tab title="QBCore" %}
The script can take control of the already in place `harness` item

This can be enabled or disabled in the config with `Config.Harness.HarnessControl == true`

If you enable this, there are a few steps you need to take as this is handled in `jim-mechanic`.

1. Delete the file `seatbelt.lua` from `qb-smallresources > client`
2. **REMOVE** these 3 events from `qb-smallresources > server > main.lua`:

```lua
QBCore.Functions.CreateUseableItem('harness', function(source, item)
    TriggerClientEvent('seatbelt:client:UseHarness', source, item)
end)

RegisterNetEvent('equip:harness', function(item)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    if not Player then return end
    if not Player.PlayerData.items[item.slot].info.uses then
        Player.PlayerData.items[item.slot].info.uses = Config.HarnessUses - 1
        Player.Functions.SetInventory(Player.PlayerData.items)
    elseif Player.PlayerData.items[item.slot].info.uses == 1 then
        exports['qb-inventory']:RemoveItem(src, 'harness', 1, false, 'equip:harness')
        TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items['harness'], 'remove')
    else
        Player.PlayerData.items[item.slot].info.uses -= 1
        Player.Functions.SetInventory(Player.PlayerData.items)
    end
end)

RegisterNetEvent('seatbelt:DoHarnessDamage', function(hp, data)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    if not Player then return end
    if hp == 0 then
        exports['qb-inventory']:RemoveItem(src, 'harness', 1, data.slot, 'seatbelt:DoHarnessDamage')
    else
        Player.PlayerData.items[data.slot].info.uses -= 1
        Player.Functions.SetInventory(Player.PlayerData.items)
    end
end)
```

***

To make your hud not complain about the harness export you will need to change the name of the export to \`jim-mechanic\`<br>

## PS-HUD

`ps-hud` > `client.lua` > line 80\
REPLACE:

```lua
local hasHarness = exports['qb-smallresources']:HasHarness()
```

WITH:

```lua
local hasHarness = exports['jim-mechanic']:HasHarness()
```

## QB-HUD

REPLACE:

```lua
local function hasHarness(items)
    local ped = PlayerPedId()
    if not IsPedInAnyVehicle(ped, false) then return end

    local _harness = false
    if items then
        for _, v in pairs(items) do
            if v.name == 'harness' then
                _harness = true
            end
        end
    end

    harness = _harness
end
```

WITH:

```lua
local function hasHarness(items) harness = exports["jim-mechanic"]:HasHarness() end
```

To hide the speedometer you will need to remove these html lines:\
`[qb]` > `qb-hud` > `html` > `index.html` remove:

```html
<div class="responsive" id="speedometer">
    <q-circular-progress id="Speedo" class="q-ml-xl" style="transform: rotate(-150deg); opacity: 60%;" :value="speedometer" :thickness="0.21" color="gauge" :min="0" :max="100"></q-circular-progress>
    <q-circular-progress id="Speedo" class="q-ml-xl" style="transform: rotate(-150deg); left: -50%;" show-value :value="speed" :thickness="0.21" color="gauge" :min="0" :max="600">
    <speed id="Speed">{{(speed)}}</speed>
</div>
<div class="responsive" id="fuelgauge">
    <q-circular-progress id="FuelGaugeBackground" class="q-ml-xl" style="transform: rotate(-125deg); opacity: 60%;" :value="fuelgauge" :thickness="0.21" color="gauge" :min="0" :max="100"></q-circular-progress>
    <q-circular-progress id="FuelGaugeValue" class="q-ml-xl" style="transform: rotate(-125deg); left: -50%;" show-value :value="fuel" :thickness="0.21" :style="{color: fuelColor}">
    <q-icon id="FuelGaugeIcon" name="fas fa-gas-pump" style="transform: rotate(125deg);" color="white"/>
</div>
<div class="responsive" id="altitudegauge" v-if="showAltitude">
    <q-circular-progress id="Altimeter" class="q-ml-xl" style="transform: rotate(-135deg); opacity: 60%;" :value="altitudegauge" size="70px" :thickness="0.21" color="gauge" :min="0" :max="100"></q-circular-progress>
    <q-circular-progress id="AltimeterValue" class="q-ml-xl" style="transform: rotate(-135deg); left: -50%;" show-value :value="altitude" size="70px" :thickness="0.21" color="gauge" :min="0" :max="750">
    <altitude id="Alt">{{(altitude)}}</altitude>
</div>
<transition name="fade">
<div class="responsive" id="seatbelt" v-if="showSeatbelt">
    <q-circular-progress id="SeatbeltLocation" class="q-ml-xl" style="transform: rotate(-125deg); opacity: 60%;" size="70px" :thickness="0.21" color="gauge" :min="0" :max="100"></q-circular-progress>
    <q-circular-progress id="SeatbeltLocation" class="q-ml-xl" style="transform: rotate(-125deg); left: -40%;" show-value size="70px" :thickness="0.21" color="gauge" :min="0" :max="750">
    <q-icon id="SeatbeltIcon" name="fas fa-user-slash" style="transform: rotate(125deg);" :value="seatbelt" size="21px" :style="{color: seatbeltColor}"/>
</div>
```

### QB-RADIAL

Search for:

```lua
local HasHarnass = exports['qb-smallresources']:HasHarness()
```

and replace with:

```lua
local HasHarnass = exports['jim-mechanic']:HasHarness()
```

***

{% endtab %}

{% tab title="QBOX" %}
The script is designed to take control of the already in place `harness` item

This can be enabled or disabled in the config of `jim-mechanic` with `Config.Harness.HarnessControl == true`

If you wish to use this, there are a few steps you need to take as this is handled in `jim-mechanic`.

1. Delete the resource: `qbx_seatbelt`
2. In `[qbx]` > `qbx_hud` > `html` > `index.html` (around line 311) remove this:

```html
  <div class="responsive" id="speedometer">
      <q-circular-progress class="q-ml-xl" style="transform: rotate(-150deg); opacity: 60%;" :value="speedometer" size="70px" :thickness="0.21" color="gauge" :min="0" :max="100"></q-circular-progress>
      <q-circular-progress class="q-ml-xl" style="transform: rotate(-150deg); left: -50%;" show-value :value="speed" size="70px" :thickness="0.21" color="gauge" :min="0" :max="600">
      <speed>{{(speed)}}</speed>
  </div>
  <div class="responsive" id="fuelgauge">
      <q-circular-progress class="q-ml-xl" style="transform: rotate(-125deg); opacity: 60%;" :value="fuelgauge" size="36px" :thickness="0.21" color="gauge" :min="0" :max="100"></q-circular-progress>
      <q-circular-progress class="q-ml-xl" style="transform: rotate(-125deg); left: -50%;" show-value :value="fuel" size="36px" :thickness="0.21" :style="{color: fuelColor}">
      <q-icon name="fas fa-gas-pump" style="transform: rotate(125deg);" size="14px" color="white"/>
  </div>
  <div class="responsive" id="altitudegauge" v-if="showAltitude">
      <q-circular-progress class="q-ml-xl" style="transform: rotate(-135deg); opacity: 60%;" :value="altitudegauge" size="70px" :thickness="0.21" color="gauge" :min="0" :max="100"></q-circular-progress>
      <q-circular-progress class="q-ml-xl" style="transform: rotate(-135deg); left: -50%;" show-value :value="altitude" size="70px" :thickness="0.21" color="gauge" :min="0" :max="750">
      <altitude>{{(altitude)}}</altitude>
  </div>
  <transition name="fade">
  <div class="responsive" id="seatbelt" v-if="showSeatbelt">
      <q-circular-progress class="q-ml-xl" style="transform: rotate(-125deg); opacity: 60%;" size="70px" :thickness="0.21" color="gauge" :min="0" :max="100"></q-circular-progress>
      <q-circular-progress class="q-ml-xl" style="transform: rotate(-125deg); left: -40%;" show-value size="70px" :thickness="0.21" color="gauge" :min="0" :max="750">
      <q-icon name="fas fa-user-slash" style="transform: rotate(125deg);" :value="seatbelt" size="21px" :style="{color: seatbeltColor}"/>
  </div>
  </transition>
```

{% endtab %}

{% tab title="ESX" %}
\--
{% endtab %}
{% endtabs %}

## Configuration

The configuration is handled by the file `modifiers_conf.lua`&#x20;

{% code fullWidth="true" %}

```lua
Config.Harness = {
    HarnessControl = true,			-- Enable harness AND seatbelt features of the script, requires edits to smallresources and hud scripts
                                    -- Disable to
    JobOnly = true,					-- Only allow job roles to add a Harness to vehicle, otherwise any one can add them

    oldPreventLeave = true,         -- If this is enabled, then disable the F button from being used while in a car
                                    -- If disabled, check for if the player is leaving the car and put them back in
                                        -- old system is more of a client strain, but more effective
                                        -- new system is less strain, but looks less pretty


    seatbeltEasyLeave = true,		-- if true players can exit vehicle before removing SEATBELT
    harnessEasyLeave = true,		-- if true players can exit vehicles before removing HARNESS

    progOn = true,					-- if true add a progressBar to buckle harness
    progOff = true,					-- if true add a progressBar to unbuckle harness

    seatbeltNotify = false,			-- if true, show a notification when seatbelt is put on or off

    timeOn = 3000,					-- Time for the progress bar to put on harness
    timeOff = 2000,					-- Time for the progress bar to put on harness

    diableCrashEjection = false,    -- If true, disable crash ejection

    minimumSpeed = 22.5,			-- Minimum speed for crash logic to be triggered - Default: 20.0 (50 mph)
    minimumSeatBeltSpeed = 45.0, 	-- Minimuim speed for ejecting with a seatbelt attached Default: 160.0 (100 mph)
    minimumDamage = 15.0, 			-- Minimum body damage for ejecting a player (default 15 = .15%)

    harnessEjection = false,        -- Set this to true to allow ejection with a harness on
    harnessSpeed = 67.5,           -- Minimum speed to eject with harness on Default: 200.0 (150 mph)

    crashKill = false,				-- Set to true if you want ejecting when crashing to kill/injure

    AltEjection = true,			    -- Enabling this may make some varibles above not be used
                                    -- Attempts to use in game engine logic for crashes and its more optimizied
                                    -- If any issues just disable this

}
```

{% endcode %}

***


---

# 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://jixelpatterns.gitbook.io/docs/paid-assets/jim-mechanic/harness-+-seatbelt.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.
