0.0.1
This commit is contained in:
84
resources/[esx_addons]/esx_hud/client/commands.lua
Normal file
84
resources/[esx_addons]/esx_hud/client/commands.lua
Normal file
@@ -0,0 +1,84 @@
|
||||
HUD.Data.hudHidden = false
|
||||
RegisterCommand("hud", function()
|
||||
HUD:Toggle(HUD.Data.hudHidden)
|
||||
HUD.Data.hudHidden = not HUD.Data.hudHidden
|
||||
end, false)
|
||||
|
||||
RegisterCommand("togglehud", function()
|
||||
HUD:Toggle(HUD.Data.hudHidden)
|
||||
HUD.Data.hudHidden = not HUD.Data.hudHidden
|
||||
end, false)
|
||||
|
||||
RegisterCommand("hudsettings", function()
|
||||
SendNUIMessage({ type = "OPEN_SETTINGS" })
|
||||
SetNuiFocus(true, true)
|
||||
end, false)
|
||||
|
||||
if not Config.Disable.VehicleHandlers and not Config.Disable.Vehicle then
|
||||
local leftSignal, rightSignal = false, false
|
||||
|
||||
ESX.RegisterInput("esx_hud:indicator:left", Translate("indicatorLeft"), "keyboard", "LEFT", function()
|
||||
if not HUD.Data.Vehicle then
|
||||
return
|
||||
end
|
||||
if HUD.Data.VehicleType == "AIR" then
|
||||
return
|
||||
end
|
||||
leftSignal = not leftSignal
|
||||
SetVehicleIndicatorLights(HUD.Data.Vehicle, 1, leftSignal)
|
||||
|
||||
local isAttached, trailer = GetVehicleTrailerVehicle(HUD.Data.Vehicle)
|
||||
if isAttached and DoesEntityExist(trailer) then
|
||||
SetVehicleIndicatorLights(trailer, 1, leftSignal)
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.RegisterInput("esx_hud:indicator:right", Translate("indicatorRight"), "keyboard", "RIGHT", function()
|
||||
if not HUD.Data.Vehicle then
|
||||
return
|
||||
end
|
||||
if HUD.Data.VehicleType == "AIR" then
|
||||
return
|
||||
end
|
||||
rightSignal = not rightSignal
|
||||
SetVehicleIndicatorLights(HUD.Data.Vehicle, 0, rightSignal)
|
||||
|
||||
local isAttached, trailer = GetVehicleTrailerVehicle(HUD.Data.Vehicle)
|
||||
if isAttached and DoesEntityExist(trailer) then
|
||||
SetVehicleIndicatorLights(trailer, 0, rightSignal)
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.RegisterInput("esx_hud:indicator:Hazard", Translate("indicatorHazard"), "keyboard", "UP", function()
|
||||
if not HUD.Data.Vehicle then
|
||||
return
|
||||
end
|
||||
if HUD.Data.VehicleType == "AIR" then
|
||||
return
|
||||
end
|
||||
if leftSignal ~= rightSignal then
|
||||
leftSignal = true
|
||||
rightSignal = true
|
||||
else
|
||||
leftSignal = not leftSignal
|
||||
rightSignal = not rightSignal
|
||||
end
|
||||
SetVehicleIndicatorLights(HUD.Data.Vehicle, 0, rightSignal)
|
||||
SetVehicleIndicatorLights(HUD.Data.Vehicle, 1, leftSignal)
|
||||
|
||||
local isAttached, trailer = GetVehicleTrailerVehicle(HUD.Data.Vehicle)
|
||||
if isAttached and DoesEntityExist(trailer) then
|
||||
SetVehicleIndicatorLights(trailer, 0, rightSignal)
|
||||
SetVehicleIndicatorLights(trailer, 1, leftSignal)
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.RegisterInput("esx_hud:toggleEngine", Translate("toggleEngine"), "keyboard", "N", function()
|
||||
if not HUD.Data.Vehicle then
|
||||
return
|
||||
end
|
||||
local engineState = GetIsVehicleEngineRunning(HUD.Data.Vehicle)
|
||||
engineState = not engineState
|
||||
SetVehicleEngineOn(HUD.Data.Vehicle, engineState, false, true)
|
||||
end)
|
||||
end
|
||||
68
resources/[esx_addons]/esx_hud/client/main.lua
Normal file
68
resources/[esx_addons]/esx_hud/client/main.lua
Normal file
@@ -0,0 +1,68 @@
|
||||
function HUD:Toggle(state)
|
||||
SendNUIMessage({ type = "SHOW", value = state })
|
||||
end
|
||||
|
||||
function HUD:SetHudColor()
|
||||
SendNUIMessage({ type = "SET_CONFIG_DATA", value = Config })
|
||||
end
|
||||
|
||||
function HUD:Start(xPlayer)
|
||||
while not ESX.PlayerLoaded do
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
if not xPlayer then
|
||||
xPlayer = ESX.GetPlayerData()
|
||||
end
|
||||
|
||||
self:SetHudColor()
|
||||
self:SlowThick()
|
||||
self:FastThick()
|
||||
|
||||
if not Config.Disable.Status then
|
||||
self:StatusThread()
|
||||
end
|
||||
|
||||
if not Config.Disable.Info then
|
||||
self:UpdateAccounts(xPlayer.accounts)
|
||||
end
|
||||
|
||||
if Config.Disable.MinimapOnFoot then
|
||||
DisplayRadar(false)
|
||||
end
|
||||
|
||||
self:Toggle(true)
|
||||
end
|
||||
|
||||
local function ToggleHud(state)
|
||||
HUD:Toggle(state)
|
||||
HUD.Data.hudHidden = not state
|
||||
end
|
||||
|
||||
RegisterNetEvent("esx_hud:HudToggle", ToggleHud)
|
||||
exports("HudToggle", ToggleHud)
|
||||
|
||||
-- Handlers
|
||||
-- On script start
|
||||
AddEventHandler("onResourceStart", function(resource)
|
||||
if GetCurrentResourceName() ~= resource then
|
||||
return
|
||||
end
|
||||
Wait(1000)
|
||||
HUD:Start()
|
||||
end)
|
||||
|
||||
-- On player loaded
|
||||
ESX.SecureNetEvent("esx:playerLoaded", function(xPlayer)
|
||||
while IsScreenFadedOut() do
|
||||
Wait(200)
|
||||
end
|
||||
|
||||
HUD:Start(xPlayer)
|
||||
end)
|
||||
|
||||
-- ForceLog or Logout
|
||||
ESX.SecureNetEvent("esx:onPlayerLogout", function()
|
||||
Wait(1000)
|
||||
HUD:Toggle(false)
|
||||
end)
|
||||
34
resources/[esx_addons]/esx_hud/client/nui.lua
Normal file
34
resources/[esx_addons]/esx_hud/client/nui.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
RegisterNUICallback("closePanel", function(data, cb)
|
||||
SetNuiFocus(false, false)
|
||||
cb("ok")
|
||||
end)
|
||||
|
||||
RegisterNUICallback("unitChanged", function(state, cb)
|
||||
if HUD.Data.Driver then
|
||||
if Config.Default.Kmh ~= state.unit then
|
||||
TriggerEvent("esx_hud:UnitChanged", state.unit)
|
||||
end
|
||||
end
|
||||
Config.Default.Kmh = state.unit
|
||||
cb("ok")
|
||||
end)
|
||||
|
||||
RegisterNUICallback("minimapSettingChanged", function(state, cb)
|
||||
Config.Disable.MinimapOnFoot = state.changed
|
||||
if IsPedOnFoot(ESX.PlayerData.ped) ~= 1 then
|
||||
return cb("ok")
|
||||
end
|
||||
DisplayRadar(not state.changed)
|
||||
cb("ok")
|
||||
end)
|
||||
|
||||
RegisterNUICallback("notify", function(data, cb)
|
||||
local state = data.state
|
||||
if state.reset then
|
||||
ESX.ShowNotification(Translate("settingsResetSuccess", 5000, "info"))
|
||||
cb("ok")
|
||||
return
|
||||
end
|
||||
ESX.ShowNotification(Translate("settingsSaveSuccess", 5000, "info"))
|
||||
cb("ok")
|
||||
end)
|
||||
164
resources/[esx_addons]/esx_hud/client/player/main.lua
Normal file
164
resources/[esx_addons]/esx_hud/client/player/main.lua
Normal file
@@ -0,0 +1,164 @@
|
||||
local bool, ammoInClip = false, 0
|
||||
local WeaponList = {}
|
||||
function HUD:GetJobLabel()
|
||||
if not ESX.PlayerData.job then
|
||||
return
|
||||
end
|
||||
|
||||
if ESX.PlayerData.job.name == "unemployed" then
|
||||
return ESX.PlayerData.job.label
|
||||
end
|
||||
|
||||
local dutySuffix = ESX.PlayerData.job.onDuty and "" or Translate("job_off_duty")
|
||||
return string.format("%s - %s %s", ESX.PlayerData.job.label, ESX.PlayerData.job.grade_label, dutySuffix)
|
||||
end
|
||||
function HUD:GetLocation()
|
||||
local PPos = GetEntityCoords(ESX.PlayerData.ped)
|
||||
local streetHash = GetStreetNameAtCoord(PPos.x, PPos.y, PPos.z)
|
||||
local streetName = GetStreetNameFromHashKey(streetHash)
|
||||
return streetName
|
||||
end
|
||||
|
||||
function HUD:UpdateAccounts(accounts)
|
||||
if not Config.Disable.Money then
|
||||
if accounts == nil then
|
||||
return
|
||||
end
|
||||
for _, data in pairs(accounts) do
|
||||
if data.name == "bank" then
|
||||
self.Data.Money.bank = data.money
|
||||
elseif data.name == "money" then
|
||||
self.Data.Money.cash = data.money
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function HUD:GetWeapons()
|
||||
WeaponList = ESX.GetWeaponList(true)
|
||||
end
|
||||
|
||||
function HUD:SlowThick()
|
||||
CreateThread(function()
|
||||
while not ESX.PlayerLoaded do
|
||||
Wait(200)
|
||||
end
|
||||
while ESX.PlayerLoaded do
|
||||
self.Data.Position = GetEntityCoords(ESX.PlayerData.ped)
|
||||
|
||||
if not Config.Disable.Position then
|
||||
self.Data.Location = self:GetLocation()
|
||||
end
|
||||
|
||||
if not Config.Disable.Weapon then
|
||||
self.Data.Weapon.Active, self.Data.Weapon.CurrentWeapon = GetCurrentPedWeapon(ESX.PlayerData.ped, false)
|
||||
if self.Data.Weapon.CurrentWeapon == 0 then
|
||||
self.Data.Weapon.Active = false
|
||||
end
|
||||
if self.Data.Weapon.Active and WeaponList[self.Data.Weapon.CurrentWeapon] then
|
||||
self.Data.Weapon.MaxAmmo = (GetAmmoInPedWeapon(ESX.PlayerData.ped, self.Data.Weapon.CurrentWeapon) - ammoInClip)
|
||||
self.Data.Weapon.Name = WeaponList[self.Data.Weapon.CurrentWeapon].label and WeaponList[self.Data.Weapon.CurrentWeapon].label or false
|
||||
self.Data.Weapon.isWeaponMelee = not WeaponList[self.Data.Weapon.CurrentWeapon].ammo
|
||||
self.Data.Weapon.Image = string.gsub(WeaponList[self.Data.Weapon.CurrentWeapon].name, "WEAPON_", "")
|
||||
self.Data.Weapon.Image = string.lower(self.Data.Weapon.Image)
|
||||
end
|
||||
|
||||
--here we handle it when we find a hash that is not in the weapon list so we don't show the weapon data on the hud
|
||||
if self.Data.Weapon.Active then
|
||||
self.Data.Weapon.Active = self.Data.Weapon.CurrentWeapon ~= 0 and self.Data.Weapon.Name and self.Data.Weapon.Image
|
||||
end
|
||||
end
|
||||
|
||||
Wait(1000)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function HUD:FastThick()
|
||||
CreateThread(function()
|
||||
while not ESX.PlayerLoaded do
|
||||
Wait(200)
|
||||
end
|
||||
|
||||
local srvLogo = Config.Default.ServerLogo
|
||||
while ESX.PlayerLoaded do
|
||||
if not Config.Disable.Voice then
|
||||
self.Data.isTalking = NetworkIsPlayerTalking(ESX.playerId)
|
||||
end
|
||||
|
||||
if self.Data.Weapon.Active then
|
||||
bool, ammoInClip = GetAmmoInClip(ESX.PlayerData.ped, self.Data.Weapon.CurrentWeapon)
|
||||
self.Data.Weapon.CurrentAmmo = ammoInClip
|
||||
end
|
||||
|
||||
local values = {
|
||||
playerId = ESX.serverId,
|
||||
onlinePlayers = GlobalState["playerCount"],
|
||||
serverLogo = srvLogo,
|
||||
moneys = { bank = self.Data.Money.bank or 0, money = self.Data.Money.cash or 0 },
|
||||
weaponData = {
|
||||
use = self.Data.Weapon.Active,
|
||||
image = self.Data.Weapon.Image or false,
|
||||
name = self.Data.Weapon.Name or false,
|
||||
isWeaponMelee = self.Data.Weapon.isWeaponMelee,
|
||||
currentAmmo = self.Data.Weapon.CurrentAmmo or 0,
|
||||
maxAmmo = self.Data.Weapon.MaxAmmo or 0,
|
||||
},
|
||||
streetName = self.Data.Location or "Unknown street",
|
||||
voice = {
|
||||
mic = self.Data.isTalking or false,
|
||||
radio = self.Data.isTalkingOnRadio,
|
||||
range = self.Data.VoiceRange,
|
||||
},
|
||||
job = HUD:GetJobLabel(),
|
||||
}
|
||||
|
||||
SendNUIMessage({ type = "HUD_DATA", value = values })
|
||||
Wait(500)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Handlers
|
||||
-- On script start
|
||||
AddEventHandler("onResourceStart", function(resource)
|
||||
if GetCurrentResourceName() ~= resource then
|
||||
return
|
||||
end
|
||||
Wait(1000)
|
||||
if not Config.Disable.Weapon then
|
||||
HUD:GetWeapons()
|
||||
end
|
||||
end)
|
||||
|
||||
-- On player loaded
|
||||
ESX.SecureNetEvent("esx:playerLoaded", function(xPlayer)
|
||||
if not Config.Disable.Weapon then
|
||||
HUD:GetWeapons()
|
||||
end
|
||||
HUD:GetJobLabel(xPlayer.job)
|
||||
end)
|
||||
|
||||
AddEventHandler("esx:pauseMenuActive", function(state)
|
||||
if HUD.Data.hudHidden then
|
||||
return
|
||||
end
|
||||
HUD:Toggle(not state)
|
||||
end)
|
||||
|
||||
-- job handler
|
||||
RegisterNetEvent("esx:setJob")
|
||||
AddEventHandler("esx:setJob", function(job)
|
||||
ESX.PlayerData.job = job
|
||||
end)
|
||||
|
||||
--Cash and Bank handler
|
||||
if not Config.Disable.Money then
|
||||
RegisterNetEvent("esx:setAccountMoney", function(account)
|
||||
if account.name == "money" then
|
||||
HUD.Data.Money.cash = account.money
|
||||
elseif account.name == "bank" then
|
||||
HUD.Data.Money.bank = account.money
|
||||
end
|
||||
end)
|
||||
end
|
||||
52
resources/[esx_addons]/esx_hud/client/player/status.lua
Normal file
52
resources/[esx_addons]/esx_hud/client/player/status.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
if not Config.Disable.Status then
|
||||
local GetPlayerUnderwaterTimeRemaining = GetPlayerUnderwaterTimeRemaining
|
||||
local GetPlayerSprintStaminaRemaining = GetPlayerSprintStaminaRemaining
|
||||
local IsPedSwimmingUnderWater = IsPedSwimmingUnderWater
|
||||
local GetEntityHealth = GetEntityHealth
|
||||
local GetEntityMaxHealth = GetEntityMaxHealth
|
||||
local GetPedArmour = GetPedArmour
|
||||
local values = {}
|
||||
|
||||
AddEventHandler("esx_status:onTick", function(data)
|
||||
local hunger, thirst
|
||||
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
|
||||
end
|
||||
|
||||
values.healthBar = math.floor((GetEntityHealth(ESX.PlayerData.ped) - 100) / 100 * 100)
|
||||
values.armorBar = GetPedArmour(ESX.PlayerData.ped)
|
||||
values.drinkBar = thirst
|
||||
values.foodBar = hunger
|
||||
end)
|
||||
|
||||
function HUD:StatusThread()
|
||||
values = {}
|
||||
CreateThread(function()
|
||||
while ESX.PlayerLoaded do
|
||||
local oxygen, stamina = 0, 0
|
||||
|
||||
stamina = math.floor(100 - GetPlayerSprintStaminaRemaining(ESX.playerId))
|
||||
if stamina == 0 then
|
||||
stamina = 1
|
||||
end
|
||||
if stamina == 100 then
|
||||
stamina = 0
|
||||
end
|
||||
|
||||
if IsPedSwimmingUnderWater(ESX.PlayerData.ped) then
|
||||
oxygen = math.floor(GetPlayerUnderwaterTimeRemaining(ESX.playerId) * 10)
|
||||
end
|
||||
|
||||
values.oxygenBar = oxygen or 0
|
||||
values.staminaBar = stamina
|
||||
SendNUIMessage({ type = "STATUS_HUD", value = values })
|
||||
Wait(250)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
11
resources/[esx_addons]/esx_hud/client/vehicle/fuel.lua
Normal file
11
resources/[esx_addons]/esx_hud/client/vehicle/fuel.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
if not Config.Disable.Vehicle then
|
||||
if GetResourceState("LegacyFuel") == "started" then
|
||||
function HUD:FuelExport()
|
||||
return ESX.Math.Round(exports["LegacyFuel"]:GetFuel(HUD.Data.Vehicle), 2)
|
||||
end
|
||||
else
|
||||
function HUD:FuelExport()
|
||||
return ESX.Math.Round(GetVehicleFuelLevel(HUD.Data.Vehicle), 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
190
resources/[esx_addons]/esx_hud/client/vehicle/main.lua
Normal file
190
resources/[esx_addons]/esx_hud/client/vehicle/main.lua
Normal file
@@ -0,0 +1,190 @@
|
||||
local cruiseControlStatus = false
|
||||
local isPassenger = false
|
||||
local isSeatbeltOn = false
|
||||
local p = promise:new()
|
||||
|
||||
local function SetCruiseControlState(state)
|
||||
cruiseControlStatus = state
|
||||
end
|
||||
|
||||
local function SetSeatbeltState(state)
|
||||
isSeatbeltOn = state
|
||||
end
|
||||
|
||||
exports("CruiseControlState", SetCruiseControlState)
|
||||
exports("SeatbeltState", SetSeatbeltState)
|
||||
|
||||
if not Config.Disable.Vehicle then
|
||||
local vehicleType, playerPos
|
||||
local currentMileage = 0
|
||||
|
||||
HUD.Data.Driver = false
|
||||
|
||||
local values = {
|
||||
show = false,
|
||||
defaultIndicators = {},
|
||||
}
|
||||
|
||||
local function driverCheck(currentVehicle)
|
||||
return DoesEntityExist(currentVehicle) and (GetPedInVehicleSeat(currentVehicle, -1) == ESX.PlayerData.ped)
|
||||
end
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
local currentVehicle = Citizen.Await(p)
|
||||
if currentVehicle then
|
||||
HUD.Data.Driver = driverCheck(currentVehicle)
|
||||
playerPos = GetEntityCoords(ESX.PlayerData.ped).xy
|
||||
|
||||
if not Config.Default.PassengerSpeedo then
|
||||
if HUD.Data.Driver then
|
||||
isPassenger = false
|
||||
else
|
||||
SendNUIMessage({ type = "VEH_HUD", value = { show = false } })
|
||||
isPassenger = true
|
||||
end
|
||||
end
|
||||
end
|
||||
Wait(1000)
|
||||
end
|
||||
end)
|
||||
|
||||
CreateThread(function()
|
||||
local oldPos
|
||||
while true do
|
||||
local currentVehicle = Citizen.Await(p)
|
||||
if currentVehicle and DoesEntityExist(currentVehicle) then
|
||||
local engineHealth = math.floor(GetVehicleEngineHealth(currentVehicle) / 10)
|
||||
local _, lowBeam, highBeam = GetVehicleLightsState(currentVehicle)
|
||||
local indicator = GetVehicleIndicatorLights(currentVehicle)
|
||||
local tempDoorLockStatus = GetVehicleDoorLockStatus(currentVehicle)
|
||||
|
||||
if engineHealth < 0 then
|
||||
engineHealth = 0
|
||||
end
|
||||
|
||||
local lightState = lowBeam == 1 or highBeam == 1
|
||||
local indicatorLeft = indicator == 1 or indicator == 3
|
||||
local indicatorRight = indicator == 2 or indicator == 3
|
||||
local doorLockStatus = tempDoorLockStatus == 2 or tempDoorLockStatus == 3
|
||||
|
||||
if IsVehicleOnAllWheels(currentVehicle) then
|
||||
if oldPos then
|
||||
local distance = #(oldPos - playerPos)
|
||||
if distance >= 10 then
|
||||
currentMileage += Config.Default.Kmh and distance / 1000 or distance / 1620
|
||||
currentMileage = ESX.Math.Round(currentMileage, 2)
|
||||
oldPos = playerPos
|
||||
end
|
||||
else
|
||||
oldPos = playerPos
|
||||
end
|
||||
end
|
||||
|
||||
values.fuel = { level = HUD:FuelExport() or 100, maxLevel = 100 }
|
||||
values.mileage = currentMileage
|
||||
values.kmh = Config.Default.Kmh
|
||||
values.damage = engineHealth
|
||||
values.vehType = vehicleType
|
||||
values.driver = HUD.Data.Driver
|
||||
values.defaultIndicators.seatbelt = isSeatbeltOn
|
||||
values.defaultIndicators.tempomat = cruiseControlStatus
|
||||
values.defaultIndicators.door = doorLockStatus
|
||||
values.defaultIndicators.light = lightState
|
||||
values.defaultIndicators.leftIndex = indicatorLeft
|
||||
values.defaultIndicators.rightIndex = indicatorRight
|
||||
end
|
||||
Wait(200)
|
||||
end
|
||||
end)
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
local currentVehicle = Citizen.Await(p)
|
||||
if currentVehicle and DoesEntityExist(currentVehicle) then
|
||||
local currentSpeed = GetEntitySpeed(currentVehicle)
|
||||
local engineRunning = GetIsVehicleEngineRunning(currentVehicle)
|
||||
local rpm
|
||||
|
||||
if vehicleType == "LAND" or vehicleType == "MOTO" then
|
||||
rpm = engineRunning and (GetVehicleCurrentRpm(currentVehicle) * 450) or 0
|
||||
else
|
||||
rpm = math.ceil(ESX.PlayerData.coords.z)
|
||||
end
|
||||
|
||||
values.speed = math.floor(currentSpeed * (Config.Default.Kmh and 3.6 or 2.236936))
|
||||
values.rpm = rpm
|
||||
values.defaultIndicators.engine = engineRunning
|
||||
|
||||
if not isPassenger then
|
||||
SendNUIMessage({ type = "VEH_HUD", value = values })
|
||||
end
|
||||
end
|
||||
Wait(50)
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler("esx:enteredVehicle", function(currentVehicle, currentPlate, currentSeat, displayName, netId)
|
||||
local vehicleClass = GetVehicleClass(currentVehicle)
|
||||
if vehicleClass == 13 then
|
||||
return
|
||||
end
|
||||
|
||||
HUD.Data.Driver = currentSeat == -1 or false
|
||||
HUD.Data.Vehicle = currentVehicle
|
||||
vehicleType = "LAND"
|
||||
|
||||
if vehicleClass == 15 or vehicleClass == 16 then
|
||||
vehicleType = "AIR"
|
||||
elseif vehicleClass == 8 then
|
||||
vehicleType = "MOTO"
|
||||
end
|
||||
|
||||
if Config.Disable.MinimapOnFoot then
|
||||
DisplayRadar(true)
|
||||
end
|
||||
|
||||
if HUD.Data.Driver then
|
||||
TriggerServerEvent("esx_hud:EnteredVehicle", currentPlate, Config.Default.Kmh)
|
||||
end
|
||||
values.show = true
|
||||
p:resolve(currentVehicle)
|
||||
end)
|
||||
|
||||
AddEventHandler("esx:exitedVehicle", function(currentVehicle, currentPlate, currentSeat, displayName, netId)
|
||||
p = promise:new()
|
||||
HUD.Data.Driver = false
|
||||
HUD.Data.Vehicle = nil
|
||||
vehicleType = nil
|
||||
|
||||
values = {
|
||||
show = false,
|
||||
defaultIndicators = {},
|
||||
}
|
||||
|
||||
SendNUIMessage({ type = "VEH_HUD", value = { show = false } })
|
||||
|
||||
if Config.Disable.MinimapOnFoot then
|
||||
DisplayRadar(false)
|
||||
end
|
||||
|
||||
if currentSeat == -1 then
|
||||
TriggerServerEvent("esx_hud:ExitedVehicle", currentPlate, currentMileage, Config.Default.Kmh)
|
||||
end
|
||||
currentMileage = 0
|
||||
isPassenger = false
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx_hud:UpdateMileage", function(mileage)
|
||||
currentMileage = mileage
|
||||
end)
|
||||
|
||||
AddEventHandler("esx_hud:UnitChanged", function(state)
|
||||
if state then
|
||||
currentMileage = currentMileage * 1.61
|
||||
else
|
||||
currentMileage = currentMileage / 1.61
|
||||
end
|
||||
currentMileage = ESX.Math.Round(currentMileage, 2)
|
||||
end)
|
||||
end
|
||||
33
resources/[esx_addons]/esx_hud/client/voice.lua
Normal file
33
resources/[esx_addons]/esx_hud/client/voice.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
if not Config.Disable.Voice then
|
||||
HUD.Data.TalkingOnRadio = false
|
||||
if GetResourceState("pma-voice") == "started" then
|
||||
AddEventHandler("pma-voice:setTalkingMode", function(mode)
|
||||
SendNUIMessage({ type = "VOICE_RANGE", value = mode })
|
||||
HUD.Data.VoiceRange = mode
|
||||
end)
|
||||
|
||||
AddEventHandler("pma-voice:radioActive", function(radioTalking)
|
||||
HUD.Data.isTalkingOnRadio = radioTalking
|
||||
end)
|
||||
|
||||
AddEventHandler("onResourceStart", function(resourceName)
|
||||
if not resourceName == "pma-voice" then
|
||||
return
|
||||
end
|
||||
Wait(1000)
|
||||
SendNUIMessage({ type = "VOICE_RANGE", value = LocalPlayer.state.proximity.index })
|
||||
end)
|
||||
elseif GetResourceState("saltychat") == "started" then
|
||||
-- #TODO: Test salty chat, add restart handlers
|
||||
AddEventHandler("SaltyChat_VoiceRangeChanged", function(range, index, availableVoiceRanges)
|
||||
SendNUIMessage({ type = "VOICE_RANGE", value = index })
|
||||
HUD.Data.VoiceRange = index
|
||||
end)
|
||||
|
||||
AddEventHandler("SaltyChat_RadioTrafficStateChanged", function(primaryReceive, primaryTransmit, secondaryReceive, secondaryTransmit)
|
||||
HUD.Data.isTalkingOnRadio = primaryTransmit or secondaryTransmit
|
||||
end)
|
||||
else
|
||||
TriggerServerEvent("esx_hud:ErrorHandle", "Setup your custom voice resource at: client/voice.lua")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user