Skip to content

Commit

Permalink
Merge pull request #914 from bitpredator/dev
Browse files Browse the repository at this point in the history
refactor: hud reconstruction
  • Loading branch information
bitpredator authored Dec 7, 2024
2 parents 077e639 + df25ba3 commit bd4c907
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 537 deletions.
3 changes: 0 additions & 3 deletions server-data/resources/[bpt_addons]/bpt_hud/client/carhud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ CreateThread(function()

-- Display Location and time when in any vehicle or on foot (if enabled)
if pedInVeh or locationAlwaysOn then
-- Get time and display
DrawTxt(timeText, 4, locationColorText, 0.4, screenPosX, screenPosY + 0.048)

-- Display remainder of HUD when engine is on and vehicle is not a bicycle
local vehicleClass = GetVehicleClass(vehicle)
if pedInVeh and GetIsVehicleEngineRunning(vehicle) and vehicleClass ~= 13 then
Expand Down
135 changes: 135 additions & 0 deletions server-data/resources/[bpt_addons]/bpt_hud/client/hud.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
ESX = exports["es_extended"]:getSharedObject()
PlayerData = {}

local ShowHUD = true
HUD = {}


RegisterNetEvent("esx:playerLoaded")
AddEventHandler("esx:playerLoaded", function(xPlayer)
ESX.PlayerLoaded = true
ESX.PlayerData = xPlayer

Cash = ESX.PlayerData.money
end)

RegisterNetEvent("esx:playerLoaded")
AddEventHandler("esx:playerLoaded", function(xPlayer)
ESX.PlayerLoaded = true
ESX.PlayerData = xPlayer

Cash = ESX.PlayerData.money

PlayerData = xPlayer
if PlayerData.job.grade_name == "boss" then
Boss = true
else
Boss = false
end
end)

function Roundxx(num, numDecimalPlaces)
local mult = 10 ^ (numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end

function DrawRct2(x, y, width, height, r, g, b, a)
DrawRect(x + width / 4, y + height / 1, width, height, r, g, b, a)
end

function DrawTxt3(x, y, width, height, scale, text, r, g, b, a)
SetTextFont(6)
SetTextProportional(0)
SetTextScale(scale, scale)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0, 255)
SetTextEdge(2, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x - width / 5.5, y - height / 20000)
end

RegisterNetEvent("sendWeight")
AddEventHandler("sendWeight", function(mm)
Weight = mm
end)

RegisterNetEvent("showhud:toggle")
AddEventHandler("showhud:toggle", function(m)
ShowHUD = m
end)

local rdy = true
function ShowHud()
ShowHUD = not ShowHUD
end

RegisterNetEvent("esx:playerLoaded")
AddEventHandler("esx:playerLoaded", function()
rdy = true
end)

local faimVal = 0
local soifVal = 0
Citizen.CreateThread(function()
while true do
Citizen.Wait(5000)

TriggerEvent("bpt_status:getStatus", "hunger", function(status)
faimVal = status.val / 1000000 * 100
end)
TriggerEvent("bpt_status:getStatus", "thirst", function(status)
soifVal = status.val / 1000000 * 100
end)
end
end)

Citizen.CreateThread(function()
Hea = 200
while true do
Citizen.Wait(0)
if rdy then
if ShowHUD then
local myPed = GetPlayerPed(-1)
local veh = GetVehiclePedIsIn(myPed, true)
local health = GetEntityHealth(myPed) - 100
local armor = GetPedArmour(myPed)
local vitesse = GetEntitySpeed(veh) * 3.6
local plate = GetVehicleNumberPlateText(veh)
if health < 0 then
health = GetEntityHealth(myPed)
end
local armor = GetPedArmour(myPed)
DrawTxt3(0.200, 0.963, 1.0, 1.0, 0.40, "" .. "❤️", 255, 255, 255, 255) -- -20
DrawTxt3(0.220, 0.963, 1.0, 1.0, 0.50, "" .. math.ceil(health) .. "", 255, 255, 255, 255)

DrawTxt3(0.250, 0.963, 1.0, 1.0, 0.40, "" .. "🛡", 255, 255, 255, 255)
DrawTxt3(0.270, 0.963, 1.0, 1.0, 0.50, "" .. math.ceil(armor) .. "", 255, 255, 255, 255)

DrawTxt3(0.290, 0.963, 1.0, 1.0, 0.40, "" .. "🍔", 255, 255, 255, 255)
DrawTxt3(0.310, 0.963, 1.0, 1.0, 0.50, "" .. math.ceil(faimVal) .. "", 255, 255, 255, 255)

DrawTxt3(0.330, 0.963, 1.0, 1.0, 0.40, "" .. "🥤", 255, 255, 255, 255)
DrawTxt3(0.350, 0.963, 1.0, 1.0, 0.50, "" .. math.ceil(soifVal) .. "", 255, 255, 255, 255)
end
end
end
end)

function DrawTxt(text, font, centre, x, y, scale, r, g, b, a)
SetTextFont(font)
SetTextProportional(false)
SetTextScale(scale, scale)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow(0)
SetTextOutline(0)
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x, y)
end

SendNUIMessage({ hud = ShowHUD })
35 changes: 0 additions & 35 deletions server-data/resources/[bpt_addons]/bpt_hud/client/status.lua

This file was deleted.

3 changes: 0 additions & 3 deletions server-data/resources/[bpt_addons]/bpt_hud/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ ui_page("html/ui.html")
shared_script("@es_extended/imports.lua")

files({
"html/*.css",
"html/*.js",
"html/*.png",
"html/ui.html",
})

client_scripts({
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit bd4c907

Please sign in to comment.