diff --git a/ESX/trew_hud_ui/LICENSE b/ESX/esx_trew_hud/LICENSE similarity index 100% rename from ESX/trew_hud_ui/LICENSE rename to ESX/esx_trew_hud/LICENSE diff --git a/ESX/esx_trew_hud/README.md b/ESX/esx_trew_hud/README.md new file mode 100644 index 0000000..967ec79 --- /dev/null +++ b/ESX/esx_trew_hud/README.md @@ -0,0 +1,56 @@ +
2023 Remaster By Mycroft
+ +One of the most, if not **the most**, popular hud for FiveM brought back with a new life - running with 0.03-0.05ms resmon and 2023 Resource support! + +## Major Changes + +```diff ++ PMA Voice Support ++ ESX Legacy Support ++ Rewrote major sections ++ Completely Optimised ++ Better Font ++ Completely Client-Sided ++ Added Player Id to HUD ++ Added QBCore Support (Including Stress and Crypto!) +- Removed Unused Code +- Removed Unused Files +- Removed vRP support +``` + +# Preview + +[![Preview](https://i.imgur.com/kerhT5C.png)](https://streamable.com/rhrrn6) + +## Installation + +1. Extract/Open the .zip. +2. Place `trew_hud-remastered` in your resources directory. +3. Add `ensure trew_hud-remastered` to your server.cfg + +### ESX + +#### Requirements + +- [ESX Legacy](https://github.com/esx-framework/esx_core) +- [ESX Society](https://github.com/esx-framework/esx_society) +- [ESX Addon Account](https://github.com/esx-framework/esx_addonaccount) + +#### Optional + +- [esx_basicneeds](https://github.com/esx-framework/esx_basicneeds) +- [esx_status](https://github.com/esx-framework/esx_status) + +### QBCore + +#### Requirements + +- [QBCore](https://github.com/qbcore-framework/qb-core) +- [qb-management](https://github.com/qbcore-framework/qb-management) + +## Commands + +**/toggleui** +Enables/Disables HUD information elements, like _and job all types money_. Useful for streamers. + +_**Usage example:**_ /toggleui diff --git a/ESX/esx_trew_hud/client/client.lua b/ESX/esx_trew_hud/client/client.lua new file mode 100644 index 0000000..fde0230 --- /dev/null +++ b/ESX/esx_trew_hud/client/client.lua @@ -0,0 +1,651 @@ +local zones = json.decode('{"HAWICK":"Hawick","ELYSIAN":"Elysian Island","SANDY":"Sandy Shores","DESRT":"Grand Senora Desert","LEGSQU":"Legion Square","MTCHIL":"Mount Chiliad","PALMPOW":"Palmer-Taylor Power Station","CCREAK":"Cassidy Creek","PROL":"North Yankton","PBLUFF":"Pacific Bluffs","MIRR":"Mirror Park","RICHM":"Richman","ZQ_UAR":"Davis Quartz","EAST_V":"East Vinewood","LAGO":"Lago Zancudo","BRADT":"Braddock Tunnel","NCHU":"North Chumash","CYPRE":"Cypress Flats","GALFISH":"Galilee","ZP_ORT":"Port of South Los Santos","PALETO":"Paleto Bay","BURTON":"Burton","GRAPES":"Grapeseed","DELSOL":"La Puerta","ALAMO":"Alamo Sea","DELPE":"Del Perro","ARMYB":"Fort Zancudo","STAD":"Maze Bank Arena","MORN":"Morningwood","CANNY":"Raton Canyon","ISHeist":"Cayo Perico Island","TEXTI":"Textile City","ALTA":"Alta","DTVINE":"Downtown Vinewood","HARMO":"Harmony","MURRI":"Murrieta Heights","KOREAT":"Little Seoul","GALLI":"Galileo Park","DOWNT":"Downtown","ZANCUDO":"Zancudo River","WVINE":"West Vinewood","BAYTRE":"Baytree Canyon","WINDF":"Ron Alternates Wind Farm","VINE":"Vinewood","EBURO":"El Burro Heights","DAVIS":"Davis","STRAW":"Strawberry","TONGVAV":"Tongva Valley","PALHIGH":"Palomino Highlands","TONGVAH":"Tongva Hills","CALAFB":"Calafia Bridge","CHAMH":"Chamberlain Hills","PBOX":"Pillbox Hill","MTJOSE":"Mount Josiah","TERMINA":"Terminal","HUMLAB":"Humane Labs and Research","PALFOR":"Paleto Forest","PALCOV":"Paleto Cove","TATAMO":"Tataviam Mountains","LDAM":"Land Act Dam","MOVIE":"Richards Majestic","VCANA":"Vespucci Canals","HORS":"Vinewood Racetrack","SKID":"Mission Row","CHU":"Chumash","SANCHIA":"San Chianski Mountain Range","CHIL":"Vinewood Hills","ROCKF":"Rockford Hills","RTRAK":"Redwood Lights Track","RGLEN":"Richman Glen","CMSW":"Chiliad Mountain State Wilderness","PROCOB":"Procopio Beach","RANCHO":"Rancho","GREATC":"Great Chaparral","BRADP":"Braddock Pass","ELGORL":"El Gordo Lighthouse","VESP":"Vespucci","OCEANA":"Pacific Ocean","JAIL":"Bolingbroke Penitentiary","OBSERV":"Galileo Observatory","BEACH":"Vespucci Beach","BHAMCA":"Banham Canyon","GOLF":"GWC and Golfing Society","SLAB":"Stab City","LACT":"Land Act Reservoir","LMESA":"La Mesa","DELBE":"Del Perro Beach","BANNING":"Banning","MTGORDO":"Mount Gordo","LOSPUER":"La Puerta","NOOSE":"N.O.O.S.E","AIRP":"Los Santos International Airport"}') + +local AllWeapons = json.decode('{"melee":{"dagger":"0x92A27487","bat":"0x958A4A8F","bottle":"0xF9E6AA4B","crowbar":"0x84BD7BFD","unarmed":"0xA2719263","flashlight":"0x8BB05FD7","golfclub":"0x440E4788","hammer":"0x4E875F73","hatchet":"0xF9DCBF2D","knuckle":"0xD8DF3C3C","knife":"0x99B507EA","machete":"0xDD5DF8D9","switchblade":"0xDFE37640","nightstick":"0x678B81B1","wrench":"0x19044EE0","battleaxe":"0xCD274149","poolcue":"0x94117305","stone_hatchet":"0x3813FC08"},"handguns":{"pistol":"0x1B06D571","pistol_mk2":"0xBFE256D4","combatpistol":"0x5EF9FEC4","appistol":"0x22D8FE39","stungun":"0x3656C8C1","pistol50":"0x99AEEB3B","snspistol":"0xBFD21232","snspistol_mk2":"0x88374054","heavypistol":"0xD205520E","vintagepistol":"0x83839C4","flaregun":"0x47757124","marksmanpistol":"0xDC4DB296","revolver":"0xC1B3C3D1","revolver_mk2":"0xCB96392F","doubleaction":"0x97EA20B8","raypistol":"0xAF3696A1"},"smg":{"microsmg":"0x13532244","smg":"0x2BE6766B","smg_mk2":"0x78A97CD0","assaultsmg":"0xEFE7E2DF","combatpdw":"0xA3D4D34","machinepistol":"0xDB1AA450","minismg":"0xBD248B55","raycarbine":"0x476BF155"},"shotguns":{"pumpshotgun":"0x1D073A89","pumpshotgun_mk2":"0x555AF99A","sawnoffshotgun":"0x7846A318","assaultshotgun":"0xE284C527","bullpupshotgun":"0x9D61E50F","musket":"0xA89CB99E","heavyshotgun":"0x3AABBBAA","dbshotgun":"0xEF951FBB","autoshotgun":"0x12E82D3D"},"assault_rifles":{"assaultrifle":"0xBFEFFF6D","assaultrifle_mk2":"0x394F415C","carbinerifle":"0x83BF0278","carbinerifle_mk2":"0xFAD1F1C9","advancedrifle":"0xAF113F99","specialcarbine":"0xC0A3098D","specialcarbine_mk2":"0x969C3D67","bullpuprifle":"0x7F229F94","bullpuprifle_mk2":"0x84D6FAFD","compactrifle":"0x624FE830"},"machine_guns":{"mg":"0x9D07F764","combatmg":"0x7FD62962","combatmg_mk2":"0xDBBD7280","gusenberg":"0x61012683"},"sniper_rifles":{"sniperrifle":"0x5FC3C11","heavysniper":"0xC472FE2","heavysniper_mk2":"0xA914799","marksmanrifle":"0xC734385A","marksmanrifle_mk2":"0x6A6C02E0"},"heavy_weapons":{"rpg":"0xB1CA77B1","grenadelauncher":"0xA284510B","grenadelauncher_smoke":"0x4DD2DC56","minigun":"0x42BF8A85","firework":"0x7F7497E5","railgun":"0x6D544C99","hominglauncher":"0x63AB0442","compactlauncher":"0x781FE4A","rayminigun":"0xB62D1F67"},"throwables":{"grenade":"0x93E220BD","bzgas":"0xA0973D5E","smokegrenade":"0xFDBC8A50","flare":"0x497FACC3","molotov":"0x24B17070","stickybomb":"0x2C3731D9","proxmine":"0xAB564B93","snowball":"0x787F0BB","pipebomb":"0xBA45E8B8","ball":"0x23C9F95C"},"misc":{"petrolcan":"0x34A67B97","fireextinguisher":"0x60EC506","parachute":"0xFBAB5776"}}') +local vehiclesCars = {0,1,2,3,4,5,6,7,8,9,10,11,12,17,18,19,20}; +local isTalking = false +local Playerid = PlayerId() +local ServerId = 0 +function Startup() + ServerId = GetPlayerServerId(Playerid) + SendNUIMessage({ action = 'ui', config = Config.ui }) + SendNUIMessage({ action = 'setFont', url = Config.font.url, name = Config.font.name }) + SendNUIMessage({ action = 'setLogo', value = Config.serverLogo }) + SendNUIMessage({ action = 'setVoiceDistance', value = LocalPlayer.state.proximity and LocalPlayer.state.proximity.mode or "Normal" }) + SendNUIMessage({ action = 'setMoney', id = 'plyId', value = tostring(ServerId) }) +end + +AddEventHandler('esx:onPlayerSpawn', function() + Startup() +end) + +-- Vehicle Info +local vehicleCruiser +local vehicleSignalIndicator = 'off' +local seatbeltEjectSpeed = 45.0 +local seatbeltEjectAccel = 100.0 +local seatbeltIsOn = false +local currSpeed = 0.0 +local prevVelocity = {x = 0.0, y = 0.0, z = 0.0} + +CreateThread(function() + Startup() + while true do + Wait(200) + local player = ESX.PlayerData.ped + local vehicle = GetVehiclePedIsIn(player, false) + local position = GetEntityCoords(player) + local vehicleIsOn = GetIsVehicleEngineRunning(vehicle) + local vehicleInfo + + if IsPauseMenuActive() then -- ESC Key + if not isPauseMenu then + isPauseMenu = not isPauseMenu + SendNUIMessage({ action = 'toggleUi', value = false }) + end + else + if isPauseMenu then + isPauseMenu = not isPauseMenu + SendNUIMessage({ action = 'toggleUi', value = true }) + end + end + if IsPedInAnyVehicle(player, false) and vehicleIsOn then + local vehicleClass = GetVehicleClass(vehicle) + + if not Config.ui.showMinimapOnFoot and Config.ui.showMinimapInVehicle then + DisplayRadar(true) + end + + -- Vehicle Speed + local vehicleSpeedSource = GetEntitySpeed(vehicle) + local vehicleSpeed + if Config.vehicle.speedUnit == 'MPH' then + vehicleSpeed = math.ceil(vehicleSpeedSource * 2.237) + else + vehicleSpeed = math.ceil(vehicleSpeedSource * 3.6) + end + + -- Vehicle Gradient Speed + local vehicleNailSpeed + + if vehicleSpeed > Config.vehicle.maxSpeed then + vehicleNailSpeed = math.ceil( 280 - math.ceil( math.ceil(Config.vehicle.maxSpeed * 205) / Config.vehicle.maxSpeed) ) + else + vehicleNailSpeed = math.ceil( 280 - math.ceil( math.ceil(vehicleSpeed * 205) / Config.vehicle.maxSpeed) ) + end + + -- Vehicle Fuel and Gear + local vehicleFuel + vehicleFuel = GetVehicleFuelLevel(vehicle) + + local vehicleGear = GetVehicleCurrentGear(vehicle) + + if (vehicleSpeed == 0 and vehicleGear == 0) or (vehicleSpeed == 0 and vehicleGear == 1) then + vehicleGear = 'N' + elseif vehicleSpeed > 0 and vehicleGear == 0 then + vehicleGear = 'R' + end + + -- Vehicle Lights + local vehicleVal,vehicleLights,vehicleHighlights = GetVehicleLightsState(vehicle) + local vehicleIsLightsOn + if vehicleLights == 1 and vehicleHighlights == 0 then + vehicleIsLightsOn = 'normal' + elseif (vehicleLights == 1 and vehicleHighlights == 1) or (vehicleLights == 0 and vehicleHighlights == 1) then + vehicleIsLightsOn = 'high' + else + vehicleIsLightsOn = 'off' + end + + -- Vehicle Siren + local vehicleSiren + + if IsVehicleSirenOn(vehicle) then + vehicleSiren = true + else + vehicleSiren = false + end + + -- Vehicle Seatbelt + if has_value(vehiclesCars, vehicleClass) and vehicleClass ~= 8 then + + local prevSpeed = currSpeed + currSpeed = vehicleSpeedSource + + SetPedConfigFlag(ESX.PlayerData.ped, 32, true) + + if not seatbeltIsOn then + local vehIsMovingFwd = GetEntitySpeedVector(vehicle, true).y > 1.0 + local vehAcc = (prevSpeed - currSpeed) / GetFrameTime() + if (vehIsMovingFwd and (prevSpeed > (seatbeltEjectSpeed/2.237)) and (vehAcc > (seatbeltEjectAccel*9.81))) then + + SetEntityCoords(player, position.x, position.y, position.z - 0.47, true, true, true) + SetEntityVelocity(player, prevVelocity.x, prevVelocity.y, prevVelocity.z) + SetPedToRagdoll(player, 1000, 1000, 0, 0, 0, 0) + else + -- Update previous velocity for ejecting player + prevVelocity = GetEntityVelocity(vehicle) + end + + else + + DisableControlAction(0, 75) + + end + end + + vehicleInfo = { + action = 'updateVehicle', + status = true, + speed = vehicleSpeed, + nail = vehicleNailSpeed, + gear = vehicleGear, + fuel = vehicleFuel, + lights = vehicleIsLightsOn, + signals = vehicleSignalIndicator, + cruiser = vehicleCruiser, + type = vehicleClass, + siren = vehicleSiren, + seatbelt = {}, + + config = { + speedUnit = Config.vehicle.speedUnit, + maxSpeed = Config.vehicle.maxSpeed + } + } + + vehicleInfo['seatbelt']['status'] = seatbeltIsOn + else + vehicleCruiser = false + vehicleNailSpeed = 0 + vehicleSignalIndicator = 'off' + + seatbeltIsOn = false + + vehicleInfo = { + action = 'updateVehicle', + + status = false, + nail = vehicleNailSpeed, + seatbelt = { status = seatbeltIsOn }, + cruiser = vehicleCruiser, + signals = vehicleSignalIndicator, + type = 0, + } + + if not Config.ui.showMinimapOnFoot then + DisplayRadar(false) + end + + end + + SendNUIMessage(vehicleInfo) + + if Config.ui.showLocation then + local player = ESX.PlayerData.ped + local position = GetEntityCoords(player) + local zoneNameFull = zones[GetNameOfZone(position.x, position.y, position.z)] + local streetName = GetStreetNameFromHashKey(GetStreetNameAtCoord(position.x, position.y, position.z)) + + local locationMessage = nil + + if zoneNameFull then + locationMessage = streetName .. ', ' .. zoneNameFull + else + locationMessage = streetName + end + + locationMessage = string.format( + Locales[Config.Locale]['you_are_on_location'], + locationMessage + ) + + SendNUIMessage({ action = 'setText', id = 'location', value = locationMessage }) + end + + if Config.ui.showVoice then + if NetworkIsPlayerTalking(Playerid) and not isTalking then + isTalking = not isTalking + SendNUIMessage({ action = 'isTalking', value = isTalking }) + elseif not NetworkIsPlayerTalking(Playerid) and isTalking then + isTalking = not isTalking + SendNUIMessage({ action = 'isTalking', value = isTalking }) + end + end + end +end) + +CreateThread(function() + + while true do + Wait(2000) + + local playerStatus + local showPlayerStatus = 0 + playerStatus = { action = 'setStatus', status = {} } + + if Config.ui.showHealth then + showPlayerStatus = (showPlayerStatus+1) + + playerStatus.isdead = ESX.PlayerData.dead + + playerStatus['status'][showPlayerStatus] = { + name = 'health', + value = GetEntityHealth(ESX.PlayerData.ped) - 100 + } + + end + + if Config.ui.showDate then + SendNUIMessage({ action = 'setText', id = 'date', value = trewDate() }) + end + + if Config.ui.showArmor then + showPlayerStatus = (showPlayerStatus+1) + + playerStatus['status'][showPlayerStatus] = { + name = 'armor', + value = GetPedArmour(ESX.PlayerData.ped), + } + end + + if Config.ui.showStamina then + showPlayerStatus = (showPlayerStatus+1) + + playerStatus['status'][showPlayerStatus] = { + name = 'stamina', + value = 100 - GetPlayerSprintStaminaRemaining(Playerid), + } + end + + if showPlayerStatus > 0 then + SendNUIMessage(playerStatus) + end + + if ESX.PlayerData.job then + local job + local blackMoney + local bank + local money + + if ESX.PlayerData.job.label == ESX.PlayerData.job.grade_label then + job = ESX.PlayerData.job.grade_label + else + job = ESX.PlayerData.job.label .. ': ' .. ESX.PlayerData.job.grade_label + end + + for i=1, #ESX.PlayerData.accounts, 1 do + if ESX.PlayerData.accounts[i].name == 'black_money' then + blackMoney = ESX.PlayerData.accounts[i].money + elseif ESX.PlayerData.accounts[i].name == 'bank' then + bank = ESX.PlayerData.accounts[i].money + elseif ESX.PlayerData.accounts[i].name == 'money' then + money = ESX.PlayerData.accounts[i].money + end + end + + SendNUIMessage({ action = 'setText', id = 'job', value = job }) + SendNUIMessage({ action = 'setMoney', id = 'wallet', value = money }) + SendNUIMessage({ action = 'setMoney', id = 'bank', value = bank }) + SendNUIMessage({ action = 'setMoney', id = 'blackMoney', value = blackMoney }) + + if ESX.PlayerData.job.grade_name and ESX.PlayerData.job.grade_name == 'boss' then + if (Config.ui.showSocietyMoney) then + SendNUIMessage({ action = 'element', task = 'enable', value = 'society' }) + end + ESX.TriggerServerCallback('esx_society:getSocietyMoney', function(money) + SendNUIMessage({ action = 'setMoney', id = 'society', value = money }) + end, ESX.PlayerData.job.name) + else + SendNUIMessage({ action = 'element', task = 'disable', value = 'society' }) + end + end + + local playerStatus + local showPlayerStatus = 0 + playerStatus = { action = 'setStatus', status = {} } + + if Config.ui.showHunger then + showPlayerStatus = (showPlayerStatus+1) + + TriggerEvent('esx_status:getStatus', 'hunger', function(status) + playerStatus['status'][showPlayerStatus] = { + name = 'hunger', + value = math.floor(100-status.getPercent()) + } + end) + + end + + if Config.ui.showThirst then + showPlayerStatus = (showPlayerStatus+1) + + TriggerEvent('esx_status:getStatus', 'thirst', function(status) + playerStatus['status'][showPlayerStatus] = { + name = 'thirst', + value = math.floor(100-status.getPercent()) + } + end) + end + + if showPlayerStatus > 0 then + SendNUIMessage(playerStatus) + end + + if Config.ui.showVoice then + AddEventHandler('pma-voice:setTalkingMode', function() + SendNUIMessage({ action = 'setVoiceDistance', value = LocalPlayer.state.proximity and LocalPlayer.state.proximity.mode or "Normal" }) + end) + end + end +end) + +-- Weapons +if Config.ui.showWeapons then + CreateThread(function() + while true do + local Sleep = 800 + + local player = ESX.PlayerData.ped + local status = {} + + if IsPedArmed(player, 7) then + Sleep = 100 + local weapon = GetSelectedPedWeapon(player) + local ammoTotal = GetAmmoInPedWeapon(player,weapon) + local bool,ammoClip = GetAmmoInClip(player,weapon) + local ammoRemaining = math.floor(ammoTotal - ammoClip) + + status['armed'] = true + + for key,value in pairs(AllWeapons) do + + for keyTwo,valueTwo in pairs(AllWeapons[key]) do + if weapon == joaat('weapon_'..keyTwo) then + status['weapon'] = keyTwo + + + if key == 'melee' then + SendNUIMessage({ action = 'element', task = 'disable', value = 'weapon_bullets' }) + SendNUIMessage({ action = 'element', task = 'disable', value = 'bullets' }) + else + if keyTwo == 'stungun' then + SendNUIMessage({ action = 'element', task = 'disable', value = 'weapon_bullets' }) + SendNUIMessage({ action = 'element', task = 'disable', value = 'bullets' }) + else + SendNUIMessage({ action = 'element', task = 'enable', value = 'weapon_bullets' }) + SendNUIMessage({ action = 'element', task = 'enable', value = 'bullets' }) + end + end + + end + end + + end + + SendNUIMessage({ action = 'setText', id = 'weapon_clip', value = ammoClip }) + SendNUIMessage({ action = 'setText', id = 'weapon_ammo', value = ammoRemaining }) + + else + if status['armed'] then + status['armed'] = false + SendNUIMessage({ action = 'updateWeapon', status = status }) + end + end + + SendNUIMessage({ action = 'updateWeapon', status = status }) + Wait(Sleep) + end + end) +end + +ESX.RegisterInput("cruise", "[HUD] Cruise Control", "keyboard", Config.vehicle.keys.cruiser, function() + local player = ESX.PlayerData.ped + local vehicle = GetVehiclePedIsIn(player, false) + local vehicleSpeedSource = GetEntitySpeed(vehicle) + if GetPedInVehicleSeat(vehicle, -1) ~= player then + return + end + if vehicleCruiser == 'on' then + vehicleCruiser = 'off' + SetEntityMaxSpeed(vehicle, GetVehicleHandlingFloat(vehicle,"CHandlingData","fInitialDriveMaxFlatVel")) + + else + vehicleCruiser = 'on' + SetEntityMaxSpeed(vehicle, vehicleSpeedSource) + end +end) + +ESX.RegisterInput("seatbelt", "[HUD] Seatbelt", "keyboard", Config.vehicle.keys.seatbelt, function() + local player = ESX.PlayerData.ped + local vehicle = GetVehiclePedIsIn(player, false) + local vehicleClass = GetVehicleClass(vehicle) + if not (IsPedInAnyVehicle(player, false) and GetIsVehicleEngineRunning(vehicle)) then + return + end + if has_value(vehiclesCars, vehicleClass) ~= true and vehicleClass == 8 then + return + end + seatbeltIsOn = not seatbeltIsOn +end) + +ESX.RegisterInput("leftindicator", "[HUD] Left Indicator", "keyboard", Config.vehicle.keys.signalLeft, function() + local player = ESX.PlayerData.ped + local vehicle = GetVehiclePedIsIn(player, false) + local vehicleClass = GetVehicleClass(vehicle) + if has_value(vehiclesCars, vehicleClass) ~= true then + return + end + if vehicleSignalIndicator == 'off' then + vehicleSignalIndicator = 'left' + else + vehicleSignalIndicator = 'off' + end + + TriggerEvent('trew_hud_ui:setCarSignalLights', vehicleSignalIndicator) +end) + +ESX.RegisterInput("rightindicator", "[HUD] Right Indicator", "keyboard", Config.vehicle.keys.signalRight, function() + local player = ESX.PlayerData.ped + local vehicle = GetVehiclePedIsIn(player, false) + local vehicleClass = GetVehicleClass(vehicle) + if has_value(vehiclesCars, vehicleClass) ~= true then + return + end + if vehicleSignalIndicator == 'off' then + vehicleSignalIndicator = 'right' + else + vehicleSignalIndicator = 'off' + end + + TriggerEvent('trew_hud_ui:setCarSignalLights', vehicleSignalIndicator) +end) + +ESX.RegisterInput("bothindicator", "[HUD] Both Indicators", "keyboard", Config.vehicle.keys.signalBoth, function() + local player = ESX.PlayerData.ped + local vehicle = GetVehiclePedIsIn(player, false) + local vehicleClass = GetVehicleClass(vehicle) + if has_value(vehiclesCars, vehicleClass) ~= true then + return + end + if vehicleSignalIndicator == 'off' then + vehicleSignalIndicator = 'both' + else + vehicleSignalIndicator = 'off' + end + + TriggerEvent('trew_hud_ui:setCarSignalLights', vehicleSignalIndicator) +end) + +AddEventHandler('trew_hud_ui:setCarSignalLights', function(status) + local driver = GetVehiclePedIsIn(ESX.PlayerData.ped, false) + local hasTrailer,vehicleTrailer = GetVehicleTrailerVehicle(driver) + local leftLight + local rightLight + + if status == 'left' then + leftLight = false + rightLight = true + if hasTrailer then driver = vehicleTrailer end + elseif status == 'right' then + leftLight = true + rightLight = false + if hasTrailer then driver = vehicleTrailer end + + elseif status == 'both' then + leftLight = true + rightLight = true + if hasTrailer then driver = vehicleTrailer end + + else + leftLight = false + rightLight = false + if hasTrailer then driver = vehicleTrailer end + + end + + SetVehicleIndicatorLights(driver, 0, leftLight) + SetVehicleIndicatorLights(driver, 1, rightLight) +end) + +function trewDate() + local timeString = nil + local weekDay = Translate('weekDay_' .. GetClockDayOfWeek()) + local month = Translate('month_' .. GetClockMonth()) + local day = Translate('day_' .. GetClockDayOfMonth()) + local year = GetClockYear() + local hour = GetClockHours() + local minutes = GetClockMinutes() + local time = nil + local AmPm = '' + + + if Config.date.AmPm then + if hour >= 13 and hour <= 24 then + hour = hour - 12 + AmPm = 'PM' + else + if hour == 0 or hour == 24 then + hour = 12 + end + AmPm = 'AM' + end + + end + + if hour <= 9 then + hour = '0' .. hour + end + if minutes <= 9 then + minutes = '0' .. minutes + end + + time = hour .. ':' .. minutes .. ' ' .. AmPm + + local date_format = Locales[Config.Locale]['date_format'][Config.date.format] + + if Config.date.format == 'default' then + timeString = string.format( + date_format, + day, month, year + ) + elseif Config.date.format == 'simple' then + timeString = string.format( + date_format, + day, month + ) + + elseif Config.date.format == 'simpleWithHours' then + timeString = string.format( + date_format, + time, day, month + ) + elseif Config.date.format == 'withWeekday' then + timeString = string.format( + date_format, + weekDay, day, month, year + ) + elseif Config.date.format == 'withHours' then + timeString = string.format( + date_format, + time, day, month, year + ) + elseif Config.date.format == 'withWeekdayAndHours' then + timeString = string.format( + date_format, + time, weekDay, day, month, year + ) + end + + return timeString +end + +function has_value(tab, val) + for index, value in ipairs(tab) do + if value == val then + return true + end + end + + return false +end + +local toggleui = false +RegisterCommand('toggleui', function() + if not toggleui then + SendNUIMessage({ action = 'element', task = 'disable', value = 'job' }) + SendNUIMessage({ action = 'element', task = 'disable', value = 'society' }) + SendNUIMessage({ action = 'element', task = 'disable', value = 'bank' }) + SendNUIMessage({ action = 'element', task = 'disable', value = 'blackMoney' }) + SendNUIMessage({ action = 'element', task = 'disable', value = 'wallet' }) + else + if (Config.ui.showJob) then + SendNUIMessage({ action = 'element', task = 'enable', value = 'job' }) + end + if (Config.ui.showSocietyMoney) then + SendNUIMessage({ action = 'element', task = 'enable', value = 'society' }) + end + if (Config.ui.showBankMoney) then + SendNUIMessage({ action = 'element', task = 'enable', value = 'bank' }) + end + if (Config.ui.showBlackMoney) then + SendNUIMessage({ action = 'element', task = 'enable', value = 'blackMoney' }) + end + if (Config.ui.showWalletMoney) then + SendNUIMessage({ action = 'element', task = 'enable', value = 'wallet' }) + end + end + + toggleui = not toggleui +end) + +exports('createStatus', function(args) + local statusCreation = { action = 'createStatus', status = args['status'], color = args['color'], icon = args['icon'] } + SendNUIMessage(statusCreation) +end) + +exports('setStatus', function(args) + local playerStatus = { action = 'setStatus', status = { + { name = args['name'], value = args['value'] } + }} + SendNUIMessage(playerStatus) +end) + +if not Config.ui.showMinimapHealth then + Citizen.CreateThread(function() + local minimap = RequestScaleformMovie("minimap") + SetBigmapActive(true, false) + Wait(0) + SetBigmapActive(false, false) + while true do + local Sleep = 500 + if not IsRadarHidden() then + Sleep = 0 + BeginScaleformMovieMethod(minimap, "SETUP_HEALTH_ARMOUR") + ScaleformMovieMethodAddParamInt(3) + EndScaleformMovieMethod() + end + Wait(Sleep) + end + + end) +end diff --git a/ESX/esx_trew_hud/config.lua b/ESX/esx_trew_hud/config.lua new file mode 100644 index 0000000..24dc9c4 --- /dev/null +++ b/ESX/esx_trew_hud/config.lua @@ -0,0 +1,56 @@ +Config = {} + +Config.Locale = 'en' + +Config.serverLogo = 'https://i.imgur.com/9a3Tj94.png' + +Config.font = { + name = 'Signika Negative', + url = 'https://fonts.googleapis.com/css2?family=Signika+Negative&display=swap' +} + +Config.date = { + format = 'default', + AmPm = false +} + +Config.vehicle = { + speedUnit = 'MPH', + maxSpeed = 180, + + keys = { + seatbelt = 'K', + cruiser = 'CAPS', + signalLeft = 'LEFT', + signalRight = 'RIGHT', + signalBoth = 'DOWN', + } +} + +Config.ui = { + showServerLogo = false, + + showJob = true, + + showWalletMoney = true, + showBankMoney = true, + showBlackMoney = false, + showSocietyMoney = true, + + showDate = true, + showLocation = true, + showVoice = true, + + showHealth = true, + showArmor = true, + showStamina = true, + showHunger = true, + showThirst = true, + showID = true, + + showMinimapOnFoot = false, + showMinimapInVehicle = true, + showMinimapHealth = false, + + showWeapons = true, +} \ No newline at end of file diff --git a/VRPEX/trew_hud_ui/fxmanifest.lua b/ESX/esx_trew_hud/fxmanifest.lua similarity index 93% rename from VRPEX/trew_hud_ui/fxmanifest.lua rename to ESX/esx_trew_hud/fxmanifest.lua index 18a1d07..c54a7ab 100644 --- a/VRPEX/trew_hud_ui/fxmanifest.lua +++ b/ESX/esx_trew_hud/fxmanifest.lua @@ -1,5 +1,11 @@ -fx_version 'cerulean' -games {'gta5'} +fx_version 'adamant' + +game 'gta5' + +description 'Trew HUD UI' + +version '2.0.0' +lua54 'yes' ui_page 'html/ui.html' @@ -114,18 +120,18 @@ files { 'html/sounds/car-indicators.ogg', } -client_scripts { - "@vrp/lib/utils.lua", - 'locales/languages.lua', +shared_scripts { + '@es_extended/imports.lua', + '@es_extended/locale.lua', + 'locales/*.lua', 'config.lua', +} + +client_scripts { 'client/client.lua', - 'client/hansolo.lua' } -server_scripts { - "@vrp/lib/utils.lua", - 'locales/languages.lua', - 'config.lua', - 'server/server.lua', - 'server/milleniumfalcon.lua' +dependencies { + 'es_extended', + 'esx_society' } diff --git a/VRP/trew_hud_ui/html/app.js b/ESX/esx_trew_hud/html/app.js similarity index 96% rename from VRP/trew_hud_ui/html/app.js rename to ESX/esx_trew_hud/html/app.js index bd90754..a9349ae 100644 --- a/VRP/trew_hud_ui/html/app.js +++ b/ESX/esx_trew_hud/html/app.js @@ -1,496 +1,497 @@ -function rgba(hex,opacity){ - hex = hex.replace('#',''); - redColor = parseInt(hex.substring(0,2), 16); - greenColor = parseInt(hex.substring(2,4), 16); - blueColor = parseInt(hex.substring(4,6), 16); - - result = 'rgba('+redColor+','+greenColor+','+blueColor+','+opacity/100+')'; - return result; -} - -var loadJS = function(url, implementationCode, location) { - var scriptTag = document.createElement('script'); - scriptTag.src = url; - - scriptTag.onload = implementationCode; - scriptTag.onreadystatechange = implementationCode; - - location.appendChild(scriptTag); -}; - - - -function ajaxio(method,url,type=null,data=null) { - return new Promise((resolve, reject) => { - const req = new XMLHttpRequest(); - req.open(method, url, true); - - if (method == 'POST') { - if (type == 'json' && data != null) { - req.setRequestHeader('Content-Type', 'application/json'); - var data = JSON.stringify(data); - } - else { req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } - } - - req.onload = () => req.status === 200 ? resolve(req.response) : reject(Error(req.statusText)); - req.onerror = (e) => reject(Error(`Network Error: ${e}`)); - - if (method == 'POST') { req.send(data); } - else { req.send(); } - }); -} - - -Object.prototype.addMultiListener = function(eventNames, listener) { - var events = eventNames.split(' '); - - if (NodeList.prototype.isPrototypeOf(this) == true) { - for (var x=0, xLen=this.length; xUser Interface created originally for ESX and then adapted for VRP/VRPEX.
- -trew_hud_ui
in your resources directory.start trew_hud_ui
to your server.cfg
-
- TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F', function(status)
- return true
- end, function(status)
- status.remove(1000)
- end)
-
- TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1', function(status)
- return true
- end, function(status)
- status.remove(750)
- end)
-
-
-
- for this one
- -
-
- TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F', function(status)
- return false
- end, function(status)
- status.remove(1000)
- end)
-
- TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1', function(status)
- return false
- end, function(status)
- status.remove(750)
- end)
-
-
-
-
- - Inside config.lua you will see a Config.vRP with certain items needed to set up properly, like black money. Since black money is considered an item on VRP/VRPEX versions, you need to put the ID of said item on this configuration. On most VRP versions, the ID is dirty_money. -
- -
- Config.vRP
- Special settings for vRP/vRPEX
-
- Config.Locale
- The language. Default is en.
-
- Config.serverLogo
- Logo for your server. It’s suggested that you upload a PNG file to websites like imgur.com and then paste the link there.
-
- Config.font
- Font configuration for the UI. Default is Montserrat and the link points up to Google Fonts. It’s suggested that you look up for a font there and place the name and the link on it’s location.
-
- Config.date
- Date format for the GPS location.
-
format:
-AmPm: set it to true if you want to use AM/PM time format, false if you don’t.
-
- Config.voice
- Voice settings for the UI. OneSync compatible
-
levels:
-keys:
-
- Config.vehicle
- Vehicle and speedometer settings
-
- Config.ui
- Display or hide elements of the HUD
-
-
- Check by the thirst indicator - -- You can create custom indicators for status you already have, like stress status, drunken, shit, piss, you name it! You would just have to use the new exports functions. I would recommend you create a new script with the code and load it below trew_hud_ui on your server.cfg. -
- -
- exports.trew_hud_ui.createStatus
- Creates a new indicator after the existing ones.
-
Example:
-
-
- local STRESS_ACTIVE = false
-
- AddEventHandler('playerSpawned', function()
-
- if STRESS_ACTIVE == false then
- exports.trew_hud_ui:createStatus({
- status = 'stress',
- color = '#FF0090',
- icon = '<i class="fas fa-brain"></i>'
- });
- STRESS_ACTIVE = true
- end
-
- end)
-
-
-
- Usage:
-
- exports.trew_hud_ui.setStatus
- It is what makes the status update. It should be set on a Wait() timer to update on whenever your custom status is. The example below ticks while getting from a custom status registered on esx_status.
-
Example:
-
-
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1000)
-
- local STRESS_STATUS
-
- TriggerEvent('esx_status:getStatus', 'stress', function(status)
- STRESS_STATUS = status.getPercent()
- end)
-
- exports.trew_hud_ui:setStatus({
- name = 'stress',
- value = STRESS_STATUS
- });
- end
- end)
-
-
-
- Usage:
-
- /toggleui
- Enables/Disables HUD information elements, like and job all types money. Useful for streamers.
-
Usage example: /toggleui
- - -This HUD is the product of 4 months of work, craft and creativity. While now I'm giving it for free, if you want to help, consider donating any ammount you want to. It will be really appreciated. :)
- - -2023 Remaster By Mycroft
+ +One of the most, if not **the most**, popular hud for FiveM brought back with a new life - running with 0.03-0.05ms resmon and 2023 Resource support! + +## Major Changes + +```diff ++ PMA Voice Support ++ ESX Legacy Support ++ Rewrote major sections ++ Completely Optimised ++ Better Font ++ Completely Client-Sided ++ Added Player Id to HUD ++ Added QBCore Support (Including Stress and Crypto!) +- Removed Unused Code +- Removed Unused Files +- Removed vRP support +``` + +# Preview + +[![Preview](https://i.imgur.com/kerhT5C.png)](https://streamable.com/rhrrn6) + +## Installation + +1. Extract/Open the .zip. +2. Place `trew_hud-remastered` in your resources directory. +3. Add `ensure trew_hud-remastered` to your server.cfg + +### ESX + +#### Requirements + +- [ESX Legacy](https://github.com/esx-framework/esx_core) +- [ESX Society](https://github.com/esx-framework/esx_society) +- [ESX Addon Account](https://github.com/esx-framework/esx_addonaccount) + +#### Optional + +- [esx_basicneeds](https://github.com/esx-framework/esx_basicneeds) +- [esx_status](https://github.com/esx-framework/esx_status) + +### QBCore + +#### Requirements + +- [QBCore](https://github.com/qbcore-framework/qb-core) +- [qb-management](https://github.com/qbcore-framework/qb-management) + +## Commands + +**/toggleui** +Enables/Disables HUD information elements, like _and job all types money_. Useful for streamers. + +_**Usage example:**_ /toggleui diff --git a/QBCore/qb_trew_hud/client/client.lua b/QBCore/qb_trew_hud/client/client.lua new file mode 100644 index 0000000..4f3a93f --- /dev/null +++ b/QBCore/qb_trew_hud/client/client.lua @@ -0,0 +1,656 @@ +local zones = json.decode('{"HAWICK":"Hawick","ELYSIAN":"Elysian Island","SANDY":"Sandy Shores","DESRT":"Grand Senora Desert","LEGSQU":"Legion Square","MTCHIL":"Mount Chiliad","PALMPOW":"Palmer-Taylor Power Station","CCREAK":"Cassidy Creek","PROL":"North Yankton","PBLUFF":"Pacific Bluffs","MIRR":"Mirror Park","RICHM":"Richman","ZQ_UAR":"Davis Quartz","EAST_V":"East Vinewood","LAGO":"Lago Zancudo","BRADT":"Braddock Tunnel","NCHU":"North Chumash","CYPRE":"Cypress Flats","GALFISH":"Galilee","ZP_ORT":"Port of South Los Santos","PALETO":"Paleto Bay","BURTON":"Burton","GRAPES":"Grapeseed","DELSOL":"La Puerta","ALAMO":"Alamo Sea","DELPE":"Del Perro","ARMYB":"Fort Zancudo","STAD":"Maze Bank Arena","MORN":"Morningwood","CANNY":"Raton Canyon","ISHeist":"Cayo Perico Island","TEXTI":"Textile City","ALTA":"Alta","DTVINE":"Downtown Vinewood","HARMO":"Harmony","MURRI":"Murrieta Heights","KOREAT":"Little Seoul","GALLI":"Galileo Park","DOWNT":"Downtown","ZANCUDO":"Zancudo River","WVINE":"West Vinewood","BAYTRE":"Baytree Canyon","WINDF":"Ron Alternates Wind Farm","VINE":"Vinewood","EBURO":"El Burro Heights","DAVIS":"Davis","STRAW":"Strawberry","TONGVAV":"Tongva Valley","PALHIGH":"Palomino Highlands","TONGVAH":"Tongva Hills","CALAFB":"Calafia Bridge","CHAMH":"Chamberlain Hills","PBOX":"Pillbox Hill","MTJOSE":"Mount Josiah","TERMINA":"Terminal","HUMLAB":"Humane Labs and Research","PALFOR":"Paleto Forest","PALCOV":"Paleto Cove","TATAMO":"Tataviam Mountains","LDAM":"Land Act Dam","MOVIE":"Richards Majestic","VCANA":"Vespucci Canals","HORS":"Vinewood Racetrack","SKID":"Mission Row","CHU":"Chumash","SANCHIA":"San Chianski Mountain Range","CHIL":"Vinewood Hills","ROCKF":"Rockford Hills","RTRAK":"Redwood Lights Track","RGLEN":"Richman Glen","CMSW":"Chiliad Mountain State Wilderness","PROCOB":"Procopio Beach","RANCHO":"Rancho","GREATC":"Great Chaparral","BRADP":"Braddock Pass","ELGORL":"El Gordo Lighthouse","VESP":"Vespucci","OCEANA":"Pacific Ocean","JAIL":"Bolingbroke Penitentiary","OBSERV":"Galileo Observatory","BEACH":"Vespucci Beach","BHAMCA":"Banham Canyon","GOLF":"GWC and Golfing Society","SLAB":"Stab City","LACT":"Land Act Reservoir","LMESA":"La Mesa","DELBE":"Del Perro Beach","BANNING":"Banning","MTGORDO":"Mount Gordo","LOSPUER":"La Puerta","NOOSE":"N.O.O.S.E","AIRP":"Los Santos International Airport"}') +local QBCore = exports['qb-core']:GetCoreObject() +local AllWeapons = json.decode('{"melee":{"dagger":"0x92A27487","bat":"0x958A4A8F","bottle":"0xF9E6AA4B","crowbar":"0x84BD7BFD","unarmed":"0xA2719263","flashlight":"0x8BB05FD7","golfclub":"0x440E4788","hammer":"0x4E875F73","hatchet":"0xF9DCBF2D","knuckle":"0xD8DF3C3C","knife":"0x99B507EA","machete":"0xDD5DF8D9","switchblade":"0xDFE37640","nightstick":"0x678B81B1","wrench":"0x19044EE0","battleaxe":"0xCD274149","poolcue":"0x94117305","stone_hatchet":"0x3813FC08"},"handguns":{"pistol":"0x1B06D571","pistol_mk2":"0xBFE256D4","combatpistol":"0x5EF9FEC4","appistol":"0x22D8FE39","stungun":"0x3656C8C1","pistol50":"0x99AEEB3B","snspistol":"0xBFD21232","snspistol_mk2":"0x88374054","heavypistol":"0xD205520E","vintagepistol":"0x83839C4","flaregun":"0x47757124","marksmanpistol":"0xDC4DB296","revolver":"0xC1B3C3D1","revolver_mk2":"0xCB96392F","doubleaction":"0x97EA20B8","raypistol":"0xAF3696A1"},"smg":{"microsmg":"0x13532244","smg":"0x2BE6766B","smg_mk2":"0x78A97CD0","assaultsmg":"0xEFE7E2DF","combatpdw":"0xA3D4D34","machinepistol":"0xDB1AA450","minismg":"0xBD248B55","raycarbine":"0x476BF155"},"shotguns":{"pumpshotgun":"0x1D073A89","pumpshotgun_mk2":"0x555AF99A","sawnoffshotgun":"0x7846A318","assaultshotgun":"0xE284C527","bullpupshotgun":"0x9D61E50F","musket":"0xA89CB99E","heavyshotgun":"0x3AABBBAA","dbshotgun":"0xEF951FBB","autoshotgun":"0x12E82D3D"},"assault_rifles":{"assaultrifle":"0xBFEFFF6D","assaultrifle_mk2":"0x394F415C","carbinerifle":"0x83BF0278","carbinerifle_mk2":"0xFAD1F1C9","advancedrifle":"0xAF113F99","specialcarbine":"0xC0A3098D","specialcarbine_mk2":"0x969C3D67","bullpuprifle":"0x7F229F94","bullpuprifle_mk2":"0x84D6FAFD","compactrifle":"0x624FE830"},"machine_guns":{"mg":"0x9D07F764","combatmg":"0x7FD62962","combatmg_mk2":"0xDBBD7280","gusenberg":"0x61012683"},"sniper_rifles":{"sniperrifle":"0x5FC3C11","heavysniper":"0xC472FE2","heavysniper_mk2":"0xA914799","marksmanrifle":"0xC734385A","marksmanrifle_mk2":"0x6A6C02E0"},"heavy_weapons":{"rpg":"0xB1CA77B1","grenadelauncher":"0xA284510B","grenadelauncher_smoke":"0x4DD2DC56","minigun":"0x42BF8A85","firework":"0x7F7497E5","railgun":"0x6D544C99","hominglauncher":"0x63AB0442","compactlauncher":"0x781FE4A","rayminigun":"0xB62D1F67"},"throwables":{"grenade":"0x93E220BD","bzgas":"0xA0973D5E","smokegrenade":"0xFDBC8A50","flare":"0x497FACC3","molotov":"0x24B17070","stickybomb":"0x2C3731D9","proxmine":"0xAB564B93","snowball":"0x787F0BB","pipebomb":"0xBA45E8B8","ball":"0x23C9F95C"},"misc":{"petrolcan":"0x34A67B97","fireextinguisher":"0x60EC506","parachute":"0xFBAB5776"}}') +local vehiclesCars = {0,1,2,3,4,5,6,7,8,9,10,11,12,17,18,19,20}; +local isTalking = false +local Playerid = PlayerId() +local ServerId = 0 +function Startup() + ServerId = GetPlayerServerId(Playerid) + SendNUIMessage({ action = 'ui', config = Config.ui }) + SendNUIMessage({ action = 'setFont', url = Config.font.url, name = Config.font.name }) + SendNUIMessage({ action = 'setLogo', value = Config.serverLogo }) + SendNUIMessage({ action = 'setVoiceDistance', value = LocalPlayer.state.proximity and LocalPlayer.state.proximity.mode or "Normal" }) + SendNUIMessage({ action = 'setMoney', id = 'plyId', value = tostring(ServerId) }) +end + +function trewDate() + local timeString = nil + local weekDay = Translate('weekDay_' .. GetClockDayOfWeek()) + local month = Translate('month_' .. GetClockMonth()) + local day = Translate('day_' .. GetClockDayOfMonth()) + local year = GetClockYear() + local hour = GetClockHours() + local minutes = GetClockMinutes() + local time = nil + local AmPm = '' + + + if Config.date.AmPm then + if hour >= 13 and hour <= 24 then + hour = hour - 12 + AmPm = 'PM' + else + if hour == 0 or hour == 24 then + hour = 12 + end + AmPm = 'AM' + end + + end + + if hour <= 9 then + hour = '0' .. hour + end + if minutes <= 9 then + minutes = '0' .. minutes + end + + time = hour .. ':' .. minutes .. ' ' .. AmPm + + local date_format = Locales[Config.Locale]['date_format'][Config.date.format] + + if Config.date.format == 'default' then + timeString = string.format( + date_format, + day, month, year + ) + elseif Config.date.format == 'simple' then + timeString = string.format( + date_format, + day, month + ) + + elseif Config.date.format == 'simpleWithHours' then + timeString = string.format( + date_format, + time, day, month + ) + elseif Config.date.format == 'withWeekday' then + timeString = string.format( + date_format, + weekDay, day, month, year + ) + elseif Config.date.format == 'withHours' then + timeString = string.format( + date_format, + time, day, month, year + ) + elseif Config.date.format == 'withWeekdayAndHours' then + timeString = string.format( + date_format, + time, weekDay, day, month, year + ) + end + + return timeString +end + +function has_value(tab, val) + for index, value in ipairs(tab) do + if value == val then + return true + end + end + + return false +end + + +RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() + Startup() +end) + +-- Vehicle Info +local vehicleCruiser +local vehicleSignalIndicator = 'off' +local seatbeltEjectSpeed = 45.0 +local seatbeltEjectAccel = 100.0 +local seatbeltIsOn = false +local currSpeed = 0.0 +local prevVelocity = {x = 0.0, y = 0.0, z = 0.0} + +-- From ESX Legacy/ESX Infinity +function RegisterInput(command_name, label, input_group, key, on_press) + RegisterCommand(command_name, on_press) + RegisterKeyMapping(command_name, label, input_group, key) + TriggerEvent('chat:removeSuggestion', '/'.. command_name) +end + +CreateThread(function() + Startup() + while not LocalPlayer.state.isLoggedIn do + Wait(0) + end + while true do + Wait(200) + local player = PlayerPedId() + local vehicle = GetVehiclePedIsIn(player, false) + local position = GetEntityCoords(player) + local vehicleIsOn = GetIsVehicleEngineRunning(vehicle) + local vehicleInfo + + if IsPauseMenuActive() then -- ESC Key + if not isPauseMenu then + isPauseMenu = not isPauseMenu + SendNUIMessage({ action = 'toggleUi', value = false }) + end + else + if isPauseMenu then + isPauseMenu = not isPauseMenu + SendNUIMessage({ action = 'toggleUi', value = true }) + end + end + if IsPedInAnyVehicle(player, false) and vehicleIsOn then + local vehicleClass = GetVehicleClass(vehicle) + + if not Config.ui.showMinimapOnFoot and Config.ui.showMinimapInVehicle then + DisplayRadar(true) + end + + -- Vehicle Speed + local vehicleSpeedSource = GetEntitySpeed(vehicle) + local vehicleSpeed + if Config.vehicle.speedUnit == 'MPH' then + vehicleSpeed = math.ceil(vehicleSpeedSource * 2.237) + else + vehicleSpeed = math.ceil(vehicleSpeedSource * 3.6) + end + + -- Vehicle Gradient Speed + local vehicleNailSpeed + + if vehicleSpeed > Config.vehicle.maxSpeed then + vehicleNailSpeed = math.ceil( 280 - math.ceil( math.ceil(Config.vehicle.maxSpeed * 205) / Config.vehicle.maxSpeed) ) + else + vehicleNailSpeed = math.ceil( 280 - math.ceil( math.ceil(vehicleSpeed * 205) / Config.vehicle.maxSpeed) ) + end + + -- Vehicle Fuel and Gear + local vehicleFuel + vehicleFuel = GetVehicleFuelLevel(vehicle) + + local vehicleGear = GetVehicleCurrentGear(vehicle) + + if (vehicleSpeed == 0 and vehicleGear == 0) or (vehicleSpeed == 0 and vehicleGear == 1) then + vehicleGear = 'N' + elseif vehicleSpeed > 0 and vehicleGear == 0 then + vehicleGear = 'R' + end + + -- Vehicle Lights + local vehicleVal,vehicleLights,vehicleHighlights = GetVehicleLightsState(vehicle) + local vehicleIsLightsOn + if vehicleLights == 1 and vehicleHighlights == 0 then + vehicleIsLightsOn = 'normal' + elseif (vehicleLights == 1 and vehicleHighlights == 1) or (vehicleLights == 0 and vehicleHighlights == 1) then + vehicleIsLightsOn = 'high' + else + vehicleIsLightsOn = 'off' + end + + -- Vehicle Siren + local vehicleSiren + + if IsVehicleSirenOn(vehicle) then + vehicleSiren = true + else + vehicleSiren = false + end + + -- Vehicle Seatbelt + if has_value(vehiclesCars, vehicleClass) and vehicleClass ~= 8 then + + local prevSpeed = currSpeed + currSpeed = vehicleSpeedSource + + SetPedConfigFlag(PlayerPedId(), 32, true) + + if not seatbeltIsOn then + local vehIsMovingFwd = GetEntitySpeedVector(vehicle, true).y > 1.0 + local vehAcc = (prevSpeed - currSpeed) / GetFrameTime() + if (vehIsMovingFwd and (prevSpeed > (seatbeltEjectSpeed/2.237)) and (vehAcc > (seatbeltEjectAccel*9.81))) then + + SetEntityCoords(player, position.x, position.y, position.z - 0.47, true, true, true) + SetEntityVelocity(player, prevVelocity.x, prevVelocity.y, prevVelocity.z) + SetPedToRagdoll(player, 1000, 1000, 0, 0, 0, 0) + else + -- Update previous velocity for ejecting player + prevVelocity = GetEntityVelocity(vehicle) + end + + else + + DisableControlAction(0, 75) + + end + end + + vehicleInfo = { + action = 'updateVehicle', + status = true, + speed = vehicleSpeed, + nail = vehicleNailSpeed, + gear = vehicleGear, + fuel = vehicleFuel, + lights = vehicleIsLightsOn, + signals = vehicleSignalIndicator, + cruiser = vehicleCruiser, + type = vehicleClass, + siren = vehicleSiren, + seatbelt = {}, + + config = { + speedUnit = Config.vehicle.speedUnit, + maxSpeed = Config.vehicle.maxSpeed + } + } + + vehicleInfo['seatbelt']['status'] = seatbeltIsOn + else + vehicleCruiser = false + vehicleNailSpeed = 0 + vehicleSignalIndicator = 'off' + + seatbeltIsOn = false + + vehicleInfo = { + action = 'updateVehicle', + + status = false, + nail = vehicleNailSpeed, + seatbelt = { status = seatbeltIsOn }, + cruiser = vehicleCruiser, + signals = vehicleSignalIndicator, + type = 0, + } + + if not Config.ui.showMinimapOnFoot then + DisplayRadar(false) + end + + end + + SendNUIMessage(vehicleInfo) + + if Config.ui.showLocation then + local player = PlayerPedId() + local position = GetEntityCoords(player) + local zoneNameFull = zones[GetNameOfZone(position.x, position.y, position.z)] + local streetName = GetStreetNameFromHashKey(GetStreetNameAtCoord(position.x, position.y, position.z)) + + local locationMessage = nil + + if zoneNameFull then + locationMessage = streetName .. ', ' .. zoneNameFull + else + locationMessage = streetName + end + + locationMessage = string.format( + Locales[Config.Locale]['you_are_on_location'], + locationMessage + ) + + SendNUIMessage({ action = 'setText', id = 'location', value = locationMessage }) + end + + if Config.ui.showVoice then + if NetworkIsPlayerTalking(Playerid) and not isTalking then + isTalking = not isTalking + SendNUIMessage({ action = 'isTalking', value = isTalking }) + elseif not NetworkIsPlayerTalking(Playerid) and isTalking then + isTalking = not isTalking + SendNUIMessage({ action = 'isTalking', value = isTalking }) + end + end + end +end) + +CreateThread(function() + while not LocalPlayer.state.isLoggedIn do + Wait(0) + end + while true do + Wait(2000) + local PlayerData = QBCore.Functions.GetPlayerData() + local playerStatus + local showPlayerStatus = 0 + playerStatus = { action = 'setStatus', status = {} } + + if Config.ui.showHealth then + showPlayerStatus = (showPlayerStatus+1) + + playerStatus.isdead = IsPedDeadOrDying(PlayerPedId(), true) + + playerStatus['status'][showPlayerStatus] = { + name = 'health', + value = GetEntityHealth(PlayerPedId()) - 100 + } + + end + + if Config.ui.showDate then + SendNUIMessage({ action = 'setText', id = 'date', value = trewDate() }) + end + + if Config.ui.showArmor then + showPlayerStatus = (showPlayerStatus+1) + + playerStatus['status'][showPlayerStatus] = { + name = 'armor', + value = GetPedArmour(PlayerPedId()), + } + end + + if Config.ui.showStamina then + showPlayerStatus = (showPlayerStatus+1) + + playerStatus['status'][showPlayerStatus] = { + name = 'stamina', + value = 100 - GetPlayerSprintStaminaRemaining(Playerid), + } + end + + if showPlayerStatus > 0 then + SendNUIMessage(playerStatus) + end + + if PlayerData and PlayerData.job then + local job + local Crypto = PlayerData.money.crypto + local bank = PlayerData.money.bank + local money = PlayerData.money.cash + + if PlayerData.job.label == PlayerData.job.grade.name then + job = PlayerData.job.grade.name + else + job = PlayerData.job.label .. ': ' .. PlayerData.job.grade.name + end + + SendNUIMessage({ action = 'setText', id = 'job', value = job }) + SendNUIMessage({ action = 'setMoney', id = 'wallet', value = money }) + SendNUIMessage({ action = 'setMoney', id = 'bank', value = bank }) + SendNUIMessage({ action = 'setMoney', id = 'blackMoney', value = Crypto }) + + if PlayerData.job.isboss then + if (Config.ui.showSocietyMoney) then + SendNUIMessage({ action = 'element', task = 'enable', value = 'society' }) + end + QBCore.Functions.TriggerCallback('qb-bossmenu:server:GetAccount', function(cb) + SendNUIMessage({ action = 'setMoney', id = 'society', value = tostring(cb) }) + end, PlayerData.job.name) + else + SendNUIMessage({ action = 'element', task = 'disable', value = 'society' }) + end + end + + local playerStatus + local showPlayerStatus = 0 + playerStatus = { action = 'setStatus', status = {} } + + if Config.ui.showHunger then + showPlayerStatus = (showPlayerStatus+1) + playerStatus['status'][showPlayerStatus] = { + name = 'hunger', + value = math.floor(PlayerData.metadata["hunger"]) + } + end + + if Config.ui.showThirst then + showPlayerStatus = (showPlayerStatus+1) + playerStatus['status'][showPlayerStatus] = { + name = 'thirst', + value = math.floor(PlayerData.metadata["thirst"]) + } + end + + if Config.ui.showStress then + showPlayerStatus = (showPlayerStatus+1) + playerStatus['status'][showPlayerStatus] = { + name = 'stress', + value = math.floor(PlayerData.metadata["stress"] > 1 and (PlayerData.metadata["stress"] / PlayerData.metadata["stress"]) * 100 or 1) + } + end + + if showPlayerStatus > 0 then + SendNUIMessage(playerStatus) + end + + if Config.ui.showVoice then + AddEventHandler('pma-voice:setTalkingMode', function() + SendNUIMessage({ action = 'setVoiceDistance', value = LocalPlayer.state.proximity and LocalPlayer.state.proximity.mode or "Normal" }) + end) + end + end +end) + +-- Weapons +if Config.ui.showWeapons then + CreateThread(function() + while not LocalPlayer.state.isLoggedIn do + Wait(0) + end + while true do + local Sleep = 800 + + local player = PlayerPedId() + local status = {} + + if IsPedArmed(player, 7) then + Sleep = 100 + local weapon = GetSelectedPedWeapon(player) + local ammoTotal = GetAmmoInPedWeapon(player,weapon) + local bool,ammoClip = GetAmmoInClip(player,weapon) + local ammoRemaining = math.floor(ammoTotal - ammoClip) + + status['armed'] = true + + for key,value in pairs(AllWeapons) do + + for keyTwo,valueTwo in pairs(AllWeapons[key]) do + if weapon == joaat('weapon_'..keyTwo) then + status['weapon'] = keyTwo + + + if key == 'melee' then + SendNUIMessage({ action = 'element', task = 'disable', value = 'weapon_bullets' }) + SendNUIMessage({ action = 'element', task = 'disable', value = 'bullets' }) + else + if keyTwo == 'stungun' then + SendNUIMessage({ action = 'element', task = 'disable', value = 'weapon_bullets' }) + SendNUIMessage({ action = 'element', task = 'disable', value = 'bullets' }) + else + SendNUIMessage({ action = 'element', task = 'enable', value = 'weapon_bullets' }) + SendNUIMessage({ action = 'element', task = 'enable', value = 'bullets' }) + end + end + + end + end + + end + + SendNUIMessage({ action = 'setText', id = 'weapon_clip', value = ammoClip }) + SendNUIMessage({ action = 'setText', id = 'weapon_ammo', value = ammoRemaining }) + + else + if status['armed'] then + status['armed'] = false + SendNUIMessage({ action = 'updateWeapon', status = status }) + end + end + + SendNUIMessage({ action = 'updateWeapon', status = status }) + Wait(Sleep) + end + end) +end + +RegisterInput("cruise", "Cruise Control", "keyboard", Config.vehicle.keys.cruiser, function() + local player = PlayerPedId() + local vehicle = GetVehiclePedIsIn(player, false) + local vehicleSpeedSource = GetEntitySpeed(vehicle) + if GetPedInVehicleSeat(vehicle, -1) ~= player then + return + end + if vehicleCruiser == 'on' then + vehicleCruiser = 'off' + SetEntityMaxSpeed(vehicle, GetVehicleHandlingFloat(vehicle,"CHandlingData","fInitialDriveMaxFlatVel")) + + else + vehicleCruiser = 'on' + SetEntityMaxSpeed(vehicle, vehicleSpeedSource) + end +end) + +RegisterInput("seatbelt", "Seatbelt", "keyboard", Config.vehicle.keys.seatbelt, function() + local player = PlayerPedId() + local vehicle = GetVehiclePedIsIn(player, false) + local vehicleClass = GetVehicleClass(vehicle) + if not (IsPedInAnyVehicle(player, false) and GetIsVehicleEngineRunning(vehicle)) then + return + end + if has_value(vehiclesCars, vehicleClass) ~= true and vehicleClass == 8 then + return + end + seatbeltIsOn = not seatbeltIsOn +end) + +RegisterInput("leftindicator", "Left Indicator", "keyboard", Config.vehicle.keys.signalLeft, function() + local player = PlayerPedId() + local vehicle = GetVehiclePedIsIn(player, false) + local vehicleClass = GetVehicleClass(vehicle) + if has_value(vehiclesCars, vehicleClass) ~= true then + return + end + if vehicleSignalIndicator == 'off' then + vehicleSignalIndicator = 'left' + else + vehicleSignalIndicator = 'off' + end + + TriggerEvent('trew_hud_ui:setCarSignalLights', vehicleSignalIndicator) +end) + +RegisterInput("rightindicator", "Right Indicator", "keyboard", Config.vehicle.keys.signalRight, function() + local player = PlayerPedId() + local vehicle = GetVehiclePedIsIn(player, false) + local vehicleClass = GetVehicleClass(vehicle) + if has_value(vehiclesCars, vehicleClass) ~= true then + return + end + if vehicleSignalIndicator == 'off' then + vehicleSignalIndicator = 'right' + else + vehicleSignalIndicator = 'off' + end + + TriggerEvent('trew_hud_ui:setCarSignalLights', vehicleSignalIndicator) +end) + +RegisterInput("bothindicator", "Both Indicators", "keyboard", Config.vehicle.keys.signalBoth, function() + local player = PlayerPedId() + local vehicle = GetVehiclePedIsIn(player, false) + local vehicleClass = GetVehicleClass(vehicle) + if has_value(vehiclesCars, vehicleClass) ~= true then + return + end + if vehicleSignalIndicator == 'off' then + vehicleSignalIndicator = 'both' + else + vehicleSignalIndicator = 'off' + end + + TriggerEvent('trew_hud_ui:setCarSignalLights', vehicleSignalIndicator) +end) + +AddEventHandler('trew_hud_ui:setCarSignalLights', function(status) + local driver = GetVehiclePedIsIn(PlayerPedId(), false) + local hasTrailer,vehicleTrailer = GetVehicleTrailerVehicle(driver) + local leftLight + local rightLight + + if status == 'left' then + leftLight = false + rightLight = true + if hasTrailer then driver = vehicleTrailer end + elseif status == 'right' then + leftLight = true + rightLight = false + if hasTrailer then driver = vehicleTrailer end + + elseif status == 'both' then + leftLight = true + rightLight = true + if hasTrailer then driver = vehicleTrailer end + else + leftLight = false + rightLight = false + if hasTrailer then driver = vehicleTrailer end + end + + SetVehicleIndicatorLights(driver, 0, leftLight) + SetVehicleIndicatorLights(driver, 1, rightLight) +end) + +local toggleui = false +RegisterCommand('toggleui', function() + if not toggleui then + SendNUIMessage({ action = 'element', task = 'disable', value = 'job' }) + SendNUIMessage({ action = 'element', task = 'disable', value = 'society' }) + SendNUIMessage({ action = 'element', task = 'disable', value = 'bank' }) + SendNUIMessage({ action = 'element', task = 'disable', value = 'blackMoney' }) + SendNUIMessage({ action = 'element', task = 'disable', value = 'wallet' }) + else + if (Config.ui.showJob) then + SendNUIMessage({ action = 'element', task = 'enable', value = 'job' }) + end + if (Config.ui.showSocietyMoney) then + SendNUIMessage({ action = 'element', task = 'enable', value = 'society' }) + end + if (Config.ui.showBankMoney) then + SendNUIMessage({ action = 'element', task = 'enable', value = 'bank' }) + end + if (Config.ui.showCrypto) then + SendNUIMessage({ action = 'element', task = 'enable', value = 'blackMoney' }) + end + if (Config.ui.showWalletMoney) then + SendNUIMessage({ action = 'element', task = 'enable', value = 'wallet' }) + end + end + + toggleui = not toggleui +end) + +exports('createStatus', function(args) + local statusCreation = { action = 'createStatus', status = args['status'], color = args['color'], icon = args['icon'] } + SendNUIMessage(statusCreation) +end) + +exports('setStatus', function(args) + local playerStatus = { action = 'setStatus', status = { + { name = args['name'], value = args['value'] } + }} + SendNUIMessage(playerStatus) +end) + +if Config.ui.showMinimapHealth then + Citizen.CreateThread(function() + local minimap = RequestScaleformMovie("minimap") + SetBigmapActive(true, false) + Wait(0) + SetBigmapActive(false, false) + while true do + local Sleep = 500 + if not IsRadarHidden() then + Sleep = 0 + BeginScaleformMovieMethod(minimap, "SETUP_HEALTH_ARMOUR") + ScaleformMovieMethodAddParamInt(3) + EndScaleformMovieMethod() + end + Wait(Sleep) + end + + end) +end \ No newline at end of file diff --git a/ESX/trew_hud_ui/config.lua b/QBCore/qb_trew_hud/config.lua similarity index 56% rename from ESX/trew_hud_ui/config.lua rename to QBCore/qb_trew_hud/config.lua index ae1c909..d807abb 100644 --- a/ESX/trew_hud_ui/config.lua +++ b/QBCore/qb_trew_hud/config.lua @@ -1,12 +1,12 @@ Config = {} -Config.Locale = 'br' +Config.Locale = 'en' -Config.serverLogo = 'https://i.imgur.com/AcgDL9f.png' +Config.serverLogo = 'https://i.imgur.com/9a3Tj94.png' Config.font = { - name = 'Montserrat', - url = 'https://fonts.googleapis.com/css?family=Montserrat:300,400,700,900&display=swap' + name = 'Signika Negative', + url = 'https://fonts.googleapis.com/css2?family=Signika+Negative&display=swap' } Config.date = { @@ -14,24 +14,9 @@ Config.date = { AmPm = false } -Config.voice = { - - levels = { - default = 5.0, - shout = 12.0, - whisper = 1.0, - current = 0 - }, - - keys = { - distance = '~', - } -} - - Config.vehicle = { - speedUnit = 'KMH', - maxSpeed = 240, + speedUnit = 'MPH', + maxSpeed = 180, keys = { seatbelt = 'K', @@ -43,13 +28,13 @@ Config.vehicle = { } Config.ui = { - showServerLogo = true, + showServerLogo = false, showJob = true, showWalletMoney = true, showBankMoney = true, - showBlackMoney = true, + showCrypto = false, showSocietyMoney = true, showDate = true, @@ -61,8 +46,12 @@ Config.ui = { showStamina = true, showHunger = true, showThirst = true, + showStress = true, + showID = true, - showMinimap = false, + showMinimapOnFoot = false, + showMinimapInVehicle = true, + showMinimapHealth = false, showWeapons = true, } \ No newline at end of file diff --git a/ESX/trew_hud_ui/fxmanifest.lua b/QBCore/qb_trew_hud/fxmanifest.lua similarity index 92% rename from ESX/trew_hud_ui/fxmanifest.lua rename to QBCore/qb_trew_hud/fxmanifest.lua index 8bc556f..bb02edb 100644 --- a/ESX/trew_hud_ui/fxmanifest.lua +++ b/QBCore/qb_trew_hud/fxmanifest.lua @@ -4,7 +4,8 @@ game 'gta5' description 'Trew HUD UI' -version '1.3.0' +version '2.0.1' +lua54 'yes' ui_page 'html/ui.html' @@ -119,26 +120,17 @@ files { 'html/sounds/car-indicators.ogg', } -client_scripts { - '@es_extended/locale.lua', - 'locales/br.lua', - 'locales/en.lua', - 'locales/es.lua', +shared_scripts { + 'translation.lua', + 'locales/*.lua', 'config.lua', - 'client/client.lua', - 'client/hansolo.lua' } -server_scripts { - '@es_extended/locale.lua', - 'locales/br.lua', - 'locales/en.lua', - 'locales/es.lua', - 'config.lua', - 'server/server.lua', - 'server/milleniumfalcon.lua' +client_scripts { + 'client/client.lua', } dependencies { - 'es_extended' + 'qb-core', + 'qb-management' } diff --git a/ESX/trew_hud_ui/html/app.js b/QBCore/qb_trew_hud/html/app.js similarity index 96% rename from ESX/trew_hud_ui/html/app.js rename to QBCore/qb_trew_hud/html/app.js index bd90754..8a2235e 100644 --- a/ESX/trew_hud_ui/html/app.js +++ b/QBCore/qb_trew_hud/html/app.js @@ -1,496 +1,498 @@ -function rgba(hex,opacity){ - hex = hex.replace('#',''); - redColor = parseInt(hex.substring(0,2), 16); - greenColor = parseInt(hex.substring(2,4), 16); - blueColor = parseInt(hex.substring(4,6), 16); - - result = 'rgba('+redColor+','+greenColor+','+blueColor+','+opacity/100+')'; - return result; -} - -var loadJS = function(url, implementationCode, location) { - var scriptTag = document.createElement('script'); - scriptTag.src = url; - - scriptTag.onload = implementationCode; - scriptTag.onreadystatechange = implementationCode; - - location.appendChild(scriptTag); -}; - - - -function ajaxio(method,url,type=null,data=null) { - return new Promise((resolve, reject) => { - const req = new XMLHttpRequest(); - req.open(method, url, true); - - if (method == 'POST') { - if (type == 'json' && data != null) { - req.setRequestHeader('Content-Type', 'application/json'); - var data = JSON.stringify(data); - } - else { req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } - } - - req.onload = () => req.status === 200 ? resolve(req.response) : reject(Error(req.statusText)); - req.onerror = (e) => reject(Error(`Network Error: ${e}`)); - - if (method == 'POST') { req.send(data); } - else { req.send(); } - }); -} - - -Object.prototype.addMultiListener = function(eventNames, listener) { - var events = eventNames.split(' '); - - if (NodeList.prototype.isPrototypeOf(this) == true) { - for (var x=0, xLen=this.length; x2023 Remaster By Mycroft
-User Interface created originally for ESX and then adapted for VRP/VRPEX. +One of the most, if not **the most**, popular hud for FiveM brought back with a new life - running with 0.03-0.05ms resmon and 2023 Resource support! -# PROJECT DISCONTINUED +## Major Changes -It was nice to play GTA5 RP and learn LUA in order to code the Trew HUD UI, but after so many struggles with not only the FiveM community and with the thing itself, I decided that I will no longer improve this project. It's been 6 months since the last time I played GTA5 RP and it makes no sense to continue this. - -If you want to fork this project or send pull request, feel free to do it. It has been a nice ride. :) BALLAS FOREVER! - -## Demo - click on the image below. -[![TREW HUD UI DEMO](https://i.imgur.com/DyaZ6Jl.png)](https://youtu.be/u1QTJ5aHcGA) +```diff ++ PMA Voice Support ++ ESX Legacy Support ++ Rewrote major sections ++ Completely Optimised ++ Better Font ++ Completely Client-Sided ++ Added Player Id to HUD ++ Added QBCore Support (Including Stress and Crypto!) +- Removed Unused Code +- Removed Unused Files +- Removed vRP support +``` +# Preview +[![Preview](https://i.imgur.com/kerhT5C.png)](https://streamable.com/rhrrn6) ## Installation -1. Extract the .zip or Open the .zip. -2. Place `trew_hud_ui` in your resources directory. -3. Add `start trew_hud_ui` to your server.cfg - - - -## Special Instructions for the ESX version - -### Requirements - -- [es_extended](https://github.com/ESX-Org/es_extended) -- [esx_society](https://github.com/ESX-Org/esx_society) -- [esx_addonaccount](https://github.com/ESX-Org/esx_addonaccount) - - -### Optional - -- [esx_basicneeds](https://github.com/ESX-Org/esx_basicneeds) -- [esx_status](https://github.com/ESX-Org/esx_status) -- [LegacyFuel](https://github.com/InZidiuZ/LegacyFuel) (it should be started **BEFORE** the trew\_hud\_ui) - - -### What you can disable - -- [RadarWhileDriving](https://github.com/Flatracer/RadarWhileDriving) - - -### Post Installation - -- Go to **es_extended** _config.lua_ and turn **Config.EnableHud** to _false_ -- If needed, go to **esx_basicneeds** _main.lua_ and replace this code - - - TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F', function(status) - return true - end, function(status) - status.remove(1000) - end) - TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1', function(status) - return true - end, function(status) - status.remove(750) - end) - -for this one - -- - TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F', function(status) - return false - end, function(status) - status.remove(1000) - end) - TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1', function(status) - return false - end, function(status) - status.remove(750) - end) - - - - -## Special Instructions for the VRP/VRPEX versions - -Inside **config.lua** you will see a _Config.vRP_ with certain items needed to set up properly, like black money. Since black money is considered an item on VRP/VRPEX versions, you need to put the ID of said item on this configuration. On most VRP versions, the ID is **dirty_money**. +1. Extract/Open the .zip. +2. Place `trew_hud-remastered` in your resources directory. +3. Add `ensure trew_hud-remastered` to your server.cfg -**Config.vRP** -Special settings for vRP/vRPEX +### ESX -- **items** - - _blackMoney:_ The item ID for Black Money. - - - +#### Requirements -## Config.lua settings +- [ESX Legacy](https://github.com/esx-framework/esx_core) +- [ESX Society](https://github.com/esx-framework/esx_society) +- [ESX Addon Account](https://github.com/esx-framework/esx_addonaccount) -**Config.Locale** -The language. Default is _en_. - -**Config.serverLogo** -Logo for your server. It’s suggested that you upload a **PNG** file to websites like **[imgur.com](http://imgur.com)** and then paste the link there. - -**Config.font** -Font configuration for the UI. Default is _Montserrat_ and the link points up to _Google Fonts_. It’s suggested that you look up for a font there and place the name and the link on it’s location. - -- **name**: The name of the font -- **link**: CSS Stylesheet file link for the font - -**Config.date** -Date format for the GPS location. - -- **format**: - - - _default:_ It’s the default format; - - _withWeekDay:_ Format that shows week day names, like _monday, tuesday, wednesday_, etc; - - _withHours:_ Format that shows the current time in game; - - _withWeekAndHours:_ A mix of _withWeekDay_ and _withHours_. - - _simple:_ Format that shows only day and month; - - _simpleWithHours:_ Same as _simple_, but also showing the time. -- **AmPm**: set it to _true_ if you want to use AM/PM time format, _false_ if you don’t. - - -**Config.voice** -Voice settings for the UI. OneSync compatible - -- **levels**: - - - _default:_ Distance in meters for a default distance. **Default** is _5.0_; - - _shout:_ Distance in meters for a shout distance. **Default** is _12.0_; - - _whisper:_ Distance in meters for a whisper distance. **Default** is _1.0_; - - _current:_ It’s **important** that this is left unchanged. -- **keys**: - - - _distance:_ Distance in meters for a default distance. **Default** is _HOME_. - -**Config.vehicle** -Vehicle and speedometer settings - -- **speedUnit**: It should be set either _KMH_ or _MPH_. **Default** is _KMH_; -- **maxSpeed**: The top speed the Speedometer is allowed to go. Default is _240_; -- **keys**: - - _seatbelt:_ Buckle/unbuckle seatbelt. **Default** is _K_; - - _cruiser:_ Activate/deactivate cruiser speed. **Default** is _CAPS_; - - _signalLeft:_ Activate/deactivate car left signal. **Default** is _LEFT_; - - _signalRight:_ Activate/deactivate car right signal. **Default** is _RIGHT_; - - _signalBoth:_ Activate/deactivate car danger signal. **Default** is _DOWN_; - -**Config.ui** -Display or hide elements of the HUD - -- **showJob**: Displays the job name. **Default** is _true_; -- **showWalletMoney**: Displays the money on your wallet. **Default** is _true_; -- **showBankMoney**: Displays the money on your bank account. **Default** is _true_; -- **showBlackMoney**: Displays the black money you have. **Default** is _true_; -- **showSocietyMoney**: If you are the boss of a job, it displays the money you have in the society vault. **Default** is _true_; **(Society money only works on ESX)** -- **showDate**: Displays the date. **Default** is _true_; -- **showLocation**: Displays the location. **Default** is _true_; -- **showHealth**: Displays your health. **Default** is _true_; -- **showArmor**: Displays your armor. **Default** is _true_; -- **showStamina**: Displays your stamina. **Default** is _true_; -- **showHunger**: Displays hunger. **Default** is _true_; -- **showThirst**: Displays thirst. **Default** is _true_; -- **showMinimap**: Displays the minimap while off the vehicle. **Default** is _false_; -- **showVoice**: Displays/use the voice controller. **Default** is _true_; -- **showWeapons**: Displays the weapons you have on your hand, with ammo. **Default** is _true_; - -## Adding Custom Status - click on the image below. - -[![TREW HUD UI STATUS CREATION](https://i.imgur.com/O1Cuz4I.png)](https://streamable.com/kzns5) -**Check by the thirst indicator** - -You can create custom indicators for status you already have, like stress status, drunken, shit, piss, you name it! You would just have to use the new **exports** functions. I would recommend you create a new script with the code and load it below **trew\_hud\_ui** on your server.cfg. +#### Optional +- [esx_basicneeds](https://github.com/esx-framework/esx_basicneeds) +- [esx_status](https://github.com/esx-framework/esx_status) +### QBCore -**exports.trew\_hud\_ui.createStatus** -Creates a new indicator after the existing ones. - -**Example:** - - local STRESS_ACTIVE = false - - AddEventHandler('playerSpawned', function() - - if STRESS_ACTIVE == false then - exports.trew_hud_ui:createStatus({ - status = 'stress', - color = '#FF0090', - icon = '' - }); - STRESS_ACTIVE = true - end - - end) - - -**Usage:** - -- **status**: The status ID. It's purely to identify it; -- **color**: The color you want for the status; -- **icon**: The HTML code for the icon. You can search on [FontAwesome](https://fontawesome.com/) for an icon and when you find one of your liking, change it there. +#### Requirements +- [QBCore](https://github.com/qbcore-framework/qb-core) +- [qb-management](https://github.com/qbcore-framework/qb-management) - -**exports.trew\_hud\_ui.setStatus** -It is what makes the status update. It should be set on a Wait() timer to update on whenever your custom status is. The example below ticks while getting from a custom status registered on **esx_status**. - -**Example:** - - Citizen.CreateThread(function() - while true do - Citizen.Wait(1000) - - local STRESS_STATUS - - TriggerEvent('esx_status:getStatus', 'stress', function(status) - STRESS_STATUS = status.getPercent() - end) - - exports.trew_hud_ui:setStatus({ - name = 'stress', - value = STRESS_STATUS - }); - end - end) - - -**Usage:** - -- **name**: The name of the status. It should be correspondent with the ID when you created it; -- **value**: The percentage value for the status, from 0 to 100. - -## Chat commands +## Commands **/toggleui** Enables/Disables HUD information elements, like _and job all types money_. Useful for streamers. _**Usage example:**_ /toggleui - -## Donate - -This HUD is the product of 4 months of work, craft and creativity. While now I'm giving it for free, if you want to help, consider donating any ammount you want to. It will be really appreciated. :) - -[![](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=S735RJA49KSJ8¤cy_code=USD&source=url) diff --git a/VRP/trew_hud_ui/LICENSE b/VRP/trew_hud_ui/LICENSE deleted file mode 100644 index f288702..0000000 --- a/VRP/trew_hud_ui/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc.User Interface created originally for ESX and then adapted for VRP/VRPEX.
- -trew_hud_ui
in your resources directory.start trew_hud_ui
to your server.cfg
-
- TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F', function(status)
- return true
- end, function(status)
- status.remove(1000)
- end)
-
- TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1', function(status)
- return true
- end, function(status)
- status.remove(750)
- end)
-
-
-
- for this one
- -
-
- TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F', function(status)
- return false
- end, function(status)
- status.remove(1000)
- end)
-
- TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1', function(status)
- return false
- end, function(status)
- status.remove(750)
- end)
-
-
-
-
- - Inside config.lua you will see a Config.vRP with certain items needed to set up properly, like black money. Since black money is considered an item on VRP/VRPEX versions, you need to put the ID of said item on this configuration. On most VRP versions, the ID is dirty_money. -
- -
- Config.vRP
- Special settings for vRP/vRPEX
-
- Config.Locale
- The language. Default is en.
-
- Config.serverLogo
- Logo for your server. It’s suggested that you upload a PNG file to websites like imgur.com and then paste the link there.
-
- Config.font
- Font configuration for the UI. Default is Montserrat and the link points up to Google Fonts. It’s suggested that you look up for a font there and place the name and the link on it’s location.
-
- Config.date
- Date format for the GPS location.
-
format:
-AmPm: set it to true if you want to use AM/PM time format, false if you don’t.
-
- Config.voice
- Voice settings for the UI. OneSync compatible
-
levels:
-keys:
-
- Config.vehicle
- Vehicle and speedometer settings
-
- Config.ui
- Display or hide elements of the HUD
-
-
- Check by the thirst indicator - -- You can create custom indicators for status you already have, like stress status, drunken, shit, piss, you name it! You would just have to use the new exports functions. I would recommend you create a new script with the code and load it below trew_hud_ui on your server.cfg. -
- -
- exports.trew_hud_ui.createStatus
- Creates a new indicator after the existing ones.
-
Example:
-
-
- local STRESS_ACTIVE = false
-
- AddEventHandler('playerSpawned', function()
-
- if STRESS_ACTIVE == false then
- exports.trew_hud_ui:createStatus({
- status = 'stress',
- color = '#FF0090',
- icon = '<i class="fas fa-brain"></i>'
- });
- STRESS_ACTIVE = true
- end
-
- end)
-
-
-
- Usage:
-
- exports.trew_hud_ui.setStatus
- It is what makes the status update. It should be set on a Wait() timer to update on whenever your custom status is. The example below ticks while getting from a custom status registered on esx_status.
-
Example:
-
-
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1000)
-
- local STRESS_STATUS
-
- TriggerEvent('esx_status:getStatus', 'stress', function(status)
- STRESS_STATUS = status.getPercent()
- end)
-
- exports.trew_hud_ui:setStatus({
- name = 'stress',
- value = STRESS_STATUS
- });
- end
- end)
-
-
-
- Usage:
-
- /toggleui
- Enables/Disables HUD information elements, like and job all types money. Useful for streamers.
-
Usage example: /toggleui
- - -This HUD is the product of 4 months of work, craft and creativity. While now I'm giving it for free, if you want to help, consider donating any ammount you want to. It will be really appreciated. :)
- - -User Interface created originally for ESX and then adapted for VRP/VRPEX.
- -trew_hud_ui
in your resources directory.start trew_hud_ui
to your server.cfg
-
- TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F', function(status)
- return true
- end, function(status)
- status.remove(1000)
- end)
-
- TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1', function(status)
- return true
- end, function(status)
- status.remove(750)
- end)
-
-
-
- for this one
- -
-
- TriggerEvent('esx_status:registerStatus', 'hunger', 1000000, '#CFAD0F', function(status)
- return false
- end, function(status)
- status.remove(1000)
- end)
-
- TriggerEvent('esx_status:registerStatus', 'thirst', 1000000, '#0C98F1', function(status)
- return false
- end, function(status)
- status.remove(750)
- end)
-
-
-
-
- - Inside config.lua you will see a Config.vRP with certain items needed to set up properly, like black money. Since black money is considered an item on VRP/VRPEX versions, you need to put the ID of said item on this configuration. On most VRP versions, the ID is dirty_money. -
- -
- Config.vRP
- Special settings for vRP/vRPEX
-
- Config.Locale
- The language. Default is en.
-
- Config.serverLogo
- Logo for your server. It’s suggested that you upload a PNG file to websites like imgur.com and then paste the link there.
-
- Config.font
- Font configuration for the UI. Default is Montserrat and the link points up to Google Fonts. It’s suggested that you look up for a font there and place the name and the link on it’s location.
-
- Config.date
- Date format for the GPS location.
-
format:
-AmPm: set it to true if you want to use AM/PM time format, false if you don’t.
-
- Config.voice
- Voice settings for the UI. OneSync compatible
-
levels:
-keys:
-
- Config.vehicle
- Vehicle and speedometer settings
-
- Config.ui
- Display or hide elements of the HUD
-
-
- Check by the thirst indicator - -- You can create custom indicators for status you already have, like stress status, drunken, shit, piss, you name it! You would just have to use the new exports functions. I would recommend you create a new script with the code and load it below trew_hud_ui on your server.cfg. -
- -
- exports.trew_hud_ui.createStatus
- Creates a new indicator after the existing ones.
-
Example:
-
-
- local STRESS_ACTIVE = false
-
- AddEventHandler('playerSpawned', function()
-
- if STRESS_ACTIVE == false then
- exports.trew_hud_ui:createStatus({
- status = 'stress',
- color = '#FF0090',
- icon = '<i class="fas fa-brain"></i>'
- });
- STRESS_ACTIVE = true
- end
-
- end)
-
-
-
- Usage:
-
- exports.trew_hud_ui.setStatus
- It is what makes the status update. It should be set on a Wait() timer to update on whenever your custom status is. The example below ticks while getting from a custom status registered on esx_status.
-
Example:
-
-
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(1000)
-
- local STRESS_STATUS
-
- TriggerEvent('esx_status:getStatus', 'stress', function(status)
- STRESS_STATUS = status.getPercent()
- end)
-
- exports.trew_hud_ui:setStatus({
- name = 'stress',
- value = STRESS_STATUS
- });
- end
- end)
-
-
-
- Usage:
-
- /toggleui
- Enables/Disables HUD information elements, like and job all types money. Useful for streamers.
-
Usage example: /toggleui
- - -This HUD is the product of 4 months of work, craft and creativity. While now I'm giving it for free, if you want to help, consider donating any ammount you want to. It will be really appreciated. :)
- - -