Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
feat: server logo + id + improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
demxnn committed Feb 18, 2022
1 parent fa6b7af commit 8cf8893
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 31 deletions.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# DxHUD
# dx_hud

This started as a fork of Cosmo HUD but ended up being a complete rewrite.
DxHUD is an HUD for FiveM and ESX Legacy.
dx_hud is an HUD for FiveM and ESX Legacy.

## Requirements

Expand All @@ -15,15 +15,22 @@ DxHUD is an HUD for FiveM and ESX Legacy.

## Useful Snippets

You may want to set every ped maximum health to the same amount.
Insert the snippet below in a loop that runs every tick and you're done.
### I won't provide any support for the snippets below, it's up to you to understand if you need it or not or if you have any conflicts aswell.

If you want to equal health among peds, run this client-side every tick.
```lua
if GetEntityMaxHealth(ESX.PlayerData.ped) ~= 200 then
SetEntityMaxHealth(ESX.PlayerData.ped, 200)
SetEntityHealth(ESX.PlayerData.ped, 200)
if GetEntityMaxHealth(PlayerPedId()) ~= 200 then
SetEntityMaxHealth(PlayerPedId(), 200)
SetEntityHealth(PlayerPedId(), 200)
end
```

If you want to disable health regen, run this client-side every tick.
```lua
SetPlayerHealthRechargeMultiplier(PlayerId(), 0.0)
SetPlayerHealthRechargeLimit(PlayerId(), 0.0)
```

## Download & Installation


Expand Down Expand Up @@ -58,7 +65,7 @@ ensure dx_hud
<br>
<table><tr><td><h3 align='center'>Legal Notices</h2></tr></td>
<tr><td>
DxHUD for ESX Legacy
dx_hud for ESX Legacy

Copyright © 2022 [Demxn](https://github.com/0xDEMXN)

Expand Down
38 changes: 20 additions & 18 deletions client.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local playerId = PlayerId()

CreateThread(function()
while true do
if ESX.PlayerLoaded then
local GeneralLoop = function()
CreateThread(function()
while ESX.PlayerLoaded do
local ped = PlayerPedId()

local underwaterTime = GetPlayerUnderwaterTimeRemaining(playerId) * 10
Expand Down Expand Up @@ -33,17 +33,16 @@ CreateThread(function()
DisplayRadar(dx.persistentRadar or isDriving)
SetRadarZoom(1150)
SendNUIMessage({showUi = not IsPauseMenuActive()})
else
SendNUIMessage({showUi = false})
end

Wait(dx.generalRefreshRate)
end
end)
Wait(dx.generalRefreshRate)
end
SendNUIMessage({showUi = false})
end)
end

CreateThread(function()
while true do
if ESX.PlayerLoaded then
local StatusLoop = function()
CreateThread(function()
while ESX.PlayerLoaded do
local hunger, thirst, stress = false, false, false
local statusReady = false

Expand All @@ -65,11 +64,11 @@ CreateThread(function()
thirst = thirst,
stress = dx.showStress and stress,
})
end

Wait(dx.statusRefreshRate)
end
end)
Wait(dx.statusRefreshRate)
end
end)
end

if dx.circleMap then
CreateThread(function()
Expand All @@ -83,9 +82,9 @@ if dx.circleMap then
SetMinimapComponentPosition('minimap_mask', 'L', 'B', 0.06, 0.05, 0.132, 0.260)
SetMinimapComponentPosition('minimap_blur', 'L', 'B', 0.005, -0.01, 0.166, 0.257)

Wait(1000)
Wait(500)
SetRadarBigmapEnabled(true, false)
Wait(1000)
Wait(500)
SetRadarBigmapEnabled(false, false)

local minimap = RequestScaleformMovie("minimap")
Expand All @@ -107,6 +106,9 @@ end)
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function()
ESX.PlayerLoaded = true
GeneralLoop()
StatusLoop()
SendNUIMessage({playerId = GetPlayerServerId(playerId)})
end)

RegisterNetEvent('esx:onPlayerLogout')
Expand Down
7 changes: 5 additions & 2 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
fx_version 'cerulean'
game 'gta5'
author '0xDEMXN'
version '1.0.5'
version '1.0.6'

lua54 'yes'
use_fxv2_oal 'yes'

shared_scripts {
'@es_extended/imports.lua'
Expand All @@ -16,7 +19,7 @@ files {
'html/ui.html',
'html/script.js',
'html/style.css',
'html/loading-bar.js',
'html/logo.png',
}

ui_page 'html/ui.html'
Expand Down
Binary file added html/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,15 @@ window.addEventListener("message", function (event) {
VoiceIndicator.animate(data.voiceRange / 100);
}

if (data.playerId) {
document.getElementById("ID").textContent = data.playerId;
}

if (data.showUi == true) {
document.querySelector(".container").style.display = "block";
document.querySelector(".Container").style.display = "block";
document.querySelector(".Logo").style.display = "block";
} else if (data.showUi == false) {
document.querySelector(".container").style.display = "none";
document.querySelector(".Container").style.display = "none";
document.querySelector(".Logo").style.display = "none";
}
});
20 changes: 20 additions & 0 deletions html/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ body {
font-size: .8rem;
}

#ID {
color: #fff;
font-size: 1.5rem;
font-family: sans-serif;
font-weight: 700;
height: 2.5rem;
margin: 0 .5rem;
text-shadow: 1px 1px 10px #000;
text-align: center;
line-height: 2.5rem;
}

.Logo {
position: absolute;
top: 1.5rem;
right: 4rem;
max-width: 130px;
opacity: .7;
}

.flash {
-webkit-animation: flash 1s;
animation: flash 1s;
Expand Down
5 changes: 4 additions & 1 deletion html/ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@
<div id="SpeedIndicator" class="Icon" style="display: none;">
<i id="SpeedIcon" class="fas fa-tachometer-alt"></i>
</div>
</div>

<div id="ID"></div>
</div>
</div>
<div class="Logo" style="display:none;"><img src="logo.png"></div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/progressbar.js/0.6.1/progressbar.min.js"
integrity="sha512-7IoDEsIJGxz/gNyJY/0LRtS45wDSvPFXGPuC7Fo4YueWMNOmWKMAllEqo2Im3pgOjeEwsOoieyliRgdkZnY0ow=="
crossorigin="anonymous"></script>
Expand Down

0 comments on commit 8cf8893

Please sign in to comment.