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 20 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
16 changes: 14 additions & 2 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,13 +22,16 @@ if not Config.Disable.Status then
values.armorBar = GetPedArmour(ped)
values.drinkBar = thirst
values.foodBar = hunger
if not Config.Disable.Stress then
values.stressBar = stress
end
end)

function HUD:StatusThread()
values = {}
CreateThread(function()
while ESX.PlayerLoaded do
local oxygen, stamina
local oxygen, stamina, drunk
oxygen = math.floor(GetPlayerUnderwaterTimeRemaining(playerId) * 10)
stamina = math.floor(100 - GetPlayerSprintStaminaRemaining(playerId))
if stamina == 0 then
Expand All @@ -34,8 +40,14 @@ if not Config.Disable.Status then
if stamina == 100 then
stamina = 0
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
Expand Down
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
10 changes: 9 additions & 1 deletion shared/config.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Config = {
CVConfig = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

fix please typo

Locale = GetConvar("esx:locale", "en"), -- If you want to change UI language texts you can do it here: web/src/assets/translate.json !!IMPORTANT that this can only be modified with the unbuilt version.
Colors = {
Info = {
Expand All @@ -11,6 +11,8 @@ 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",
drunkBar = "pink",
},
Speedo = {
["segment-color"] = "#eee",
Expand Down Expand Up @@ -62,3 +64,9 @@ Config = {
PassengerSpeedo = false, -- if this true , you can see speedometer if you don't driver
},
}
Config = {}
Config.Disable = {
Status = false,
Stress = true, -- Add this line
Drunk = true -- Add this line
}
24 changes: 24 additions & 0 deletions web/DefaultDatas.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const progressColors = {
foodBar: "yellow",
oxygenBar: "green",
staminaBar: "purple",
stressBar: "orange",
drunkBar: "pink"
};

const vehDefaultData = {
Expand Down Expand Up @@ -64,6 +66,8 @@ 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

drunkBar: 0, // Nilai untuk kondisi pemain tidak mabuk
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 +132,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 +272,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
28 changes: 21 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 @@ -83,7 +85,9 @@
"foodbar": "Essen",
"oxygenbar": "Luft",
"staminabar": "Ausdauer",
"circlewidth": "Status Kreisbreite"
"stressbar": "Stressbalken",
"drunkbar": "Betrunkenheitsbalken",
"circlewidth": "Statuskreisbreite"
},
"Speedo": {
"segment-color": "Segmentfarbe",
Expand Down Expand Up @@ -150,7 +154,9 @@
"foodbar": "Étel státusz",
"oxygenbar": "Oxigén státusz",
"staminabar": "Stamina státusz",
"circlewidth": "Státusz kör vastagsága"
"stressbar": "Stressz státusz",
"drunkbar": "Részeg státusz",
"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 +223,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 +292,9 @@
"foodbar": "Honger bar",
"oxygenbar": "Zuurstof bar",
"staminabar": "Stamina bar",
"circlewidth": "Breedte status cirkel"
"stressbar": "Stressbar",
"drunkbar": "Dronkenbar",
"circlewidth": "Status cirkelbreedte"
},
"Speedo": {
"segment-color": "kleursegment",
Expand Down Expand Up @@ -350,7 +360,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 @@ -400,7 +412,7 @@
"passengerspeedo":"Contakm per passeggero ON/OFF"
}
},
"fr": {
"fr": {
"General": {
"status": "Status",
"speedo": "Compteur de vitesse",
Expand All @@ -417,7 +429,9 @@
"foodbar": "Barre de faim",
"oxygenbar": "Barre d'oxygène",
"staminabar": "Barre d'endurance",
"circlewidth": "Largeur du cercle"
"stressbar": "Barre anti-stress",
"drunkbar": "Bar ivre",
"circlewidth": "Largeur du cercle d'état"
},
"Speedo": {
"segment-color": "Couleur segment",
Expand Down