# JS\_HUD

## Installation

* Download the newest Version of the Script from your [Keymaster](https://keymaster.fivem.net/login?return_url=/) Account.
* Drag and Drop the Script into your resource Folder.
* Change `esx_status:load` in `esx_status/client/main.lua`

```lua
-- Replace your esx_status:load with following code

RegisterNetEvent('esx_status:load')
AddEventHandler('esx_status:load', function(status)
	ESX.PlayerLoaded = true
	TriggerEvent('esx_status:loaded')
	for i=1, #Status, 1 do
		for j=1, #status, 1 do
			if Status[i].name == status[j].name then
				Status[i].set(status[j].val)
			end
		end
	end

	if Config.Display then TriggerEvent('esx_status:setDisplay', 0.5) end

	CreateThread(function()
		local data = {}
		while ESX.PlayerLoaded do
			for i=1, #Status do
				Status[i].onTick()
				table.insert(data, {
					name = Status[i].name,
					val = Status[i].val,
					percent = (Status[i].val / 1000000) * 100
				})
			end

			if Config.Display then
				local fullData = data
				for i=1, #data, 1 do
					fullData[i].color = Status[i].color
					fullData[i].visible = Status[i].visible(Status[i])
				end
				SendNUIMessage({
					update = true,
					status = fullData
				})
				
			end

			TriggerEvent('JS_HUD:updateBasics', GetStatusData(true)) -- This line is important

			TriggerEvent('esx_status:onTick', data)
			table.wipe(data)
			Wait(Config.TickTime)
		end
	end)
end)
```

* Add `start JS_HUD` to your Server Configuration File.
* Configure the `JS_HUD/configurations/config.lua` the way you like.&#x20;

***

## Configuration

Change the Language of the Script

```lua
Config.Locale = "en" -- Already available de/en/fr
```

Change the Range of the Talking Mode

```lua
Config.TalkingRange = {
    normal = 8.0, -- in Meters
    whisper = 2.5,
    shout = 15.0,
}
```

Decide to use the Keymapping method, so every User can change their Keys themselfe or if disabled you can choose fixed keys.

```lua
Config.UseKeymapping = true -- true/false
```

If you have disabled `Config.UseKeymapping` you can select the fixed Keys here.

```lua
Config.NormalKeys = {
    ChangeTalkingRange = Keys["."],
    ToggleCarlock = Keys["L"],
}
```

If you have enabled `Config.UseKeymapping` you can select the fixed Keys here.

```lua
Config.KeymappingKeys = {
    ChangeTalkingRange = "PERIOD",
    ToggleCarlock = "L",
}
```

Decide whether to use the integrated Carlock System or to use your own one.&#x20;

```lua
Config.UseCustomCarlock = false
```

If you want to use your own Carlock System you can decide whether you use it by triggering its Event or by using an export

```lua
-- If you want to use the Export you have to leave Config.CustomCarlockEvent = "" like (empty)

Config.CustomCarlockEvent = "" -- Enter your event name here  
-- TriggerClientEvent("YOURNAME") <-- INFO: The Event Name will be triggered like this

Config.CustomCarlockExport = function() 
    exports.YOURRESOURCE:YOURFUNCTION()
end   -- Enter your export name here ! Only if you leave the event above blank 
```
