Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create esx_hud #82

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 27 additions & 19 deletions client/player/status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ if not Config.Disable.Status then
local playerId = PlayerId()

AddEventHandler("esx_status:onTick", function(data)
local hunger, thirst
local hunger, thirst, stress
for i = 1, #data do
if data[i].name == "thirst" then
thirst = math.floor(data[i].percent)
end
if data[i].name == "hunger" then
hunger = math.floor(data[i].percent)
end
if data[i].name == "stress" then
stress = math.floor(data[i].percent)
end
end

local ped = PlayerPedId()
Expand All @@ -19,26 +22,31 @@ if not Config.Disable.Status then
values.armorBar = GetPedArmour(ped)
values.drinkBar = thirst
values.foodBar = hunger
values.stressBar = stress
end)

function HUD:StatusThread()
values = {}
CreateThread(function()
while ESX.PlayerLoaded do
local oxygen, stamina
oxygen = math.floor(GetPlayerUnderwaterTimeRemaining(playerId) * 10)
stamina = math.floor(100 - GetPlayerSprintStaminaRemaining(playerId))
if stamina == 0 then
stamina = 1
end
if stamina == 100 then
stamina = 0
end
values.oxygenBar = IsPedSwimmingUnderWater(PlayerPedId()) and oxygen or 0
values.staminaBar = stamina
SendNUIMessage({ type = "STATUS_HUD", value = values })
Wait(200)
values = {}
CreateThread(function()
while ESX.PlayerLoaded do
local oxygen, stamina, drunk
oxygen = math.floor(GetPlayerUnderwaterTimeRemaining(playerId) * 10)
stamina = math.floor(100 - GetPlayerSprintStaminaRemaining(playerId))
if stamina == 0 then
stamina = 1
end
if stamina == 100 then
stamina = 0
end
end)
end

-- Add drunk status calculation here
drunk = math.floor(ESX.Game.GetPlayerDrunkLevel(playerId) or 0) -- Assuming there is a method to get the player's drunk level

values.oxygenBar = IsPedSwimmingUnderWater(PlayerPedId()) and oxygen or 0
values.staminaBar = stamina
values.drunkBar = drunk -- Add drunk level to the values table
SendNUIMessage({ type = "STATUS_HUD", value = values })
Wait(200)
end
end)
end
1 change: 1 addition & 0 deletions esx_hud
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
added the function of the stress icon and the drunk icon
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ game 'gta5'
lua54 'yes'

description 'The default HUD resource for ESX-Legacy.'
version '1.7.0'
version '1.8.0'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have automatic github actions, and change the version number if we released new version, please revert to old. (1.7.0)


shared_scripts {
'@es_extended/imports.lua',
Expand Down
1 change: 1 addition & 0 deletions shared/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Config = {
armorBar = "blue",
drinkBar = "lightblue",
foodBar = "yellow",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where drunk bar?

stressBar = "purple",
},
Speedo = {
["segment-color"] = "#eee",
Expand Down
22 changes: 22 additions & 0 deletions web/DefaultDatas.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const progressColors = {
foodBar: "yellow",
oxygenBar: "green",
staminaBar: "purple",
stressBar: "orange"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where drunk bar?

};

const vehDefaultData = {
Expand Down Expand Up @@ -64,6 +65,7 @@ const progressLevels = {
foodBar: 80,
oxygenBar: 100,
staminaBar: 100,
stressBar: 50, // Tambahkan nilai sesuai kebutuhan
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment, where drunkBar?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment please

};

const defaultIndicators = {
Expand Down Expand Up @@ -128,6 +130,18 @@ const progressDefaultCircles = [
color: "green",
icon: StaminaIcon,
},
{
name: "stressBar",
progressLevel: 100,
color: "orange",
icon: StressIcon, // Pastikan Anda memiliki ikon untuk stress
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

},
{
name: "drunkBar",
progressLevel: 100,
color: "purple",
icon: DrunkIcon, // Pastikan Anda memiliki ikon untuk drunk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

},
];

const speedoDefaultColors = [
Expand Down Expand Up @@ -256,6 +270,14 @@ const allColors = {
name: "staminaBar",
color: "purple",
},
{
name: "stressBar",
color: "orange",
},
{
name: "drunkBar",
color: "pink",
},
],
Speedo: [
{
Expand Down
12 changes: 12 additions & 0 deletions web/src/assets/Contexts/HudStorage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ const initialState = {
progressLevel: 100,
color: "green",
icon: StaminaIcon
},
{
name: "stressBar",
progressLevel: 100,
color: "orange",
icon: StressIcon // Pastikan Anda memiliki ikon untuk stress
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

},
{
name: "drunkBar",
progressLevel: 100,
color: "purple",
icon: DrunkIcon // Pastikan Anda memiliki ikon untuk drunk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

}
],
speedo:{
Expand Down
8 changes: 8 additions & 0 deletions web/src/assets/Contexts/SettingsStorage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ const initialState = {
{
name: "staminaBar",
color: "green"
},
{
name: "stressBar",
color: "orange"
},
{
name: "drunkBar",
color: "purple"
}
],
infoColors: [
Expand Down
27 changes: 20 additions & 7 deletions web/src/assets/translate.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"foodbar": "Food bar",
"oxygenbar": "Oxygen bar",
"staminabar": "Stamina bar",
"stressbar": "Stress bar",
"drunkbar": "Drunk bar",
"circlewidth": "Status circle width"
},
"Speedo": {
Expand Down Expand Up @@ -82,8 +84,9 @@
"drinkbar": "Trinken",
"foodbar": "Essen",
"oxygenbar": "Luft",
"staminabar": "Ausdauer",
"circlewidth": "Status Kreisbreite"
"stressbar": "Stressbar",
"dronkenbar": "Dronkenbar",
"circlewidth": "Status cirkelbreedte"
},
"Speedo": {
"segment-color": "Segmentfarbe",
Expand Down Expand Up @@ -150,7 +153,9 @@
"foodbar": "Étel státusz",
"oxygenbar": "Oxigén státusz",
"staminabar": "Stamina státusz",
"circlewidth": "Státusz kör vastagsága"
"stressbar": "Stress bar",
"drunkbar": "Drunk bar",
"circlewidth": "Állapot körszélesség"
Rangerhitam12 marked this conversation as resolved.
Show resolved Hide resolved
},
"Speedo": {
"segment-color": "Sebességmérő színe",
Expand Down Expand Up @@ -217,7 +222,9 @@
"foodbar": "Traka hrane",
"oxygenbar": "Traka vazduha",
"staminabar": "Traka izdrzljivosti",
"circlewidth": "Sirina statusnog kruga"
"stressbar": "Traka stresa",
"drunkbar": "Bar za pijance",
"circlewidth": "Širina kruga statusa"
},
"Speedo": {
"segment-color": "boja segmenta",
Expand Down Expand Up @@ -284,7 +291,9 @@
"foodbar": "Honger bar",
"oxygenbar": "Zuurstof bar",
"staminabar": "Stamina bar",
"circlewidth": "Breedte status cirkel"
"stressbar": "Stressbar",
"dronkenbar": "Dronkenbar",
"circlewidth": "Status cirkelbreedte"
},
"Speedo": {
"segment-color": "kleursegment",
Expand Down Expand Up @@ -350,7 +359,9 @@
"foodbar": "Barra Fame",
"oxygenbar": "Barra ossigeno",
"staminabar": "Barra Stamina",
"circlewidth": "Larghezza cerchio status"
"stressbar": "Barra dello stress",
"drunkbar": "Bar degli ubriachi",
"circlewidth": "Larghezza del cerchio di stato"
},
"Speedo": {
"segment-color": "Colore segmento",
Expand Down Expand Up @@ -417,7 +428,9 @@
"foodbar": "Barre de faim",
"oxygenbar": "Barre d'oxygène",
"staminabar": "Barre d'endurance",
"circlewidth": "Largeur du cercle"
"stressbar": "Barra dello stress",
"drunkbar": "Bar degli ubriachi",
"circlewidth": "Larghezza del cerchio di stato"
},
"Speedo": {
"segment-color": "Couleur segment",
Expand Down