Skip to content

Commit

Permalink
🎨Code formatted in all files
Browse files Browse the repository at this point in the history
  • Loading branch information
Gellipapa authored and ESX GITHUB ACTIONS BOT committed Jul 6, 2023
1 parent 747b18c commit 18432a6
Show file tree
Hide file tree
Showing 36 changed files with 1,603 additions and 1,499 deletions.
13 changes: 8 additions & 5 deletions .github/actions/bump-manifest-version.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const fs = require('fs');
const fs = require("fs");

const version = process.env.TGT_RELEASE_VERSION;
const newVersion = version.replace('v', '');
const newVersion = version.replace("v", "");

const manifestFile = fs.readFileSync('fxmanifest.lua', { encoding: 'utf8' });
const manifestFile = fs.readFileSync("fxmanifest.lua", { encoding: "utf8" });

const newFileContent = manifestFile.replace(/\bversion\s+(.*)$/gm, `version '${newVersion}'`);
const newFileContent = manifestFile.replace(
/\bversion\s+(.*)$/gm,
`version '${newVersion}'`,
);

fs.writeFileSync('fxmanifest.lua', newFileContent);
fs.writeFileSync("fxmanifest.lua", newFileContent);
90 changes: 50 additions & 40 deletions client/commands.lua
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
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", "NUMPAD4", 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)
end)

ESX.RegisterInput('esx_hud:indicator:right', Translate('indicatorRight'), "keyboard", "NUMPAD6", 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)
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, true, true)
end)
end
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", "NUMPAD4", 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)
end)

ESX.RegisterInput("esx_hud:indicator:right", Translate("indicatorRight"), "keyboard", "NUMPAD6", 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)
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, true, true)
end)
end
100 changes: 52 additions & 48 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
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)
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

-- Handlers
-- On script start
AddEventHandler('onResourceStart', function(resource)
if GetCurrentResourceName() ~= resource then return end
Wait(1000)
HUD:Start()
end)

-- On player loaded
AddEventHandler('esx:playerLoaded', function(xPlayer)
Wait(1000)
HUD:Start(xPlayer)
end)

-- ForceLog or Logout
AddEventHandler('esx:onPlayerLogout', function()
Wait(1000)
HUD:Toggle(false)
end)
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)
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

-- Handlers
-- On script start
AddEventHandler("onResourceStart", function(resource)
if GetCurrentResourceName() ~= resource then
return
end
Wait(1000)
HUD:Start()
end)

-- On player loaded
AddEventHandler("esx:playerLoaded", function(xPlayer)
Wait(1000)
HUD:Start(xPlayer)
end)

-- ForceLog or Logout
AddEventHandler("esx:onPlayerLogout", function()
Wait(1000)
HUD:Toggle(false)
end)
66 changes: 34 additions & 32 deletions client/nui.lua
Original file line number Diff line number Diff line change
@@ -1,32 +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(PlayerPedId()) ~= 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)
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(PlayerPedId()) ~= 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)
Loading

0 comments on commit 18432a6

Please sign in to comment.