diff --git a/.github/actions/bump-manifest-version.js b/.github/actions/bump-manifest-version.js index 5fe3462..09f4cd9 100644 --- a/.github/actions/bump-manifest-version.js +++ b/.github/actions/bump-manifest-version.js @@ -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); diff --git a/client/commands.lua b/client/commands.lua index 7087d74..57e4a23 100644 --- a/client/commands.lua +++ b/client/commands.lua @@ -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 \ No newline at end of file +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 diff --git a/client/main.lua b/client/main.lua index c3efb0b..bd173c6 100644 --- a/client/main.lua +++ b/client/main.lua @@ -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) \ No newline at end of file +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) diff --git a/client/nui.lua b/client/nui.lua index afb79fc..c3d39f9 100644 --- a/client/nui.lua +++ b/client/nui.lua @@ -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) \ No newline at end of file +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) diff --git a/client/player/main.lua b/client/player/main.lua index eba6082..f6a6d83 100644 --- a/client/player/main.lua +++ b/client/player/main.lua @@ -1,137 +1,163 @@ - -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 - - return string.format("%s - %s", ESX.PlayerData.job.label,ESX.PlayerData.job.grade_label) -end - -function HUD:GetLocation() - local PPos = GetEntityCoords(PlayerPedId()) - 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(PlayerPedId()) - - 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(PlayerPedId(), 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(PlayerPedId(), 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 - end - - Wait(1000) - end - end) -end - -function HUD:FastThick() - CreateThread(function() - while not ESX.PlayerLoaded do Wait(200) end - local plyId = GetPlayerServerId(PlayerId()) - local srvLogo = Config.Default.ServerLogo - while ESX.PlayerLoaded do - if not Config.Disable.Voice then - self.Data.isTalking = NetworkIsPlayerTalking(PlayerId()) - end - - if self.Data.Weapon.Active then - bool, ammoInClip = GetAmmoInClip(PlayerPedId(), self.Data.Weapon.CurrentWeapon) - self.Data.Weapon.CurrentAmmo = ammoInClip - end - - local values = { - playerId = plyId, - onlinePlayers = GlobalState["OnlinePlayers"], - 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 'pistol', - name = self.Data.Weapon.Name or 'Pistol', - isWeaponMelee = self.Data.Weapon.isWeaponMelee, - currentAmmo = self.Data.Weapon.CurrentAmmo or 0, - maxAmmo = self.Data.Weapon.MaxAmmo or 0 - }, - streetName = self.Data.Location or 'Noname 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(200) - 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 -AddEventHandler('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 +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 + + return string.format("%s - %s", ESX.PlayerData.job.label, ESX.PlayerData.job.grade_label) +end + +function HUD:GetLocation() + local PPos = GetEntityCoords(PlayerPedId()) + 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(PlayerPedId()) + + 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(PlayerPedId(), 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(PlayerPedId(), 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 + end + + Wait(1000) + end + end) +end + +function HUD:FastThick() + CreateThread(function() + while not ESX.PlayerLoaded do + Wait(200) + end + local plyId = GetPlayerServerId(PlayerId()) + local srvLogo = Config.Default.ServerLogo + while ESX.PlayerLoaded do + if not Config.Disable.Voice then + self.Data.isTalking = NetworkIsPlayerTalking(PlayerId()) + end + + if self.Data.Weapon.Active then + bool, ammoInClip = GetAmmoInClip(PlayerPedId(), self.Data.Weapon.CurrentWeapon) + self.Data.Weapon.CurrentAmmo = ammoInClip + end + + local values = { + playerId = plyId, + onlinePlayers = GlobalState["OnlinePlayers"], + 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 "pistol", + name = self.Data.Weapon.Name or "Pistol", + isWeaponMelee = self.Data.Weapon.isWeaponMelee, + currentAmmo = self.Data.Weapon.CurrentAmmo or 0, + maxAmmo = self.Data.Weapon.MaxAmmo or 0, + }, + streetName = self.Data.Location or "Noname 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(200) + 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 +AddEventHandler("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 diff --git a/client/player/status.lua b/client/player/status.lua index 807b20a..01260df 100644 --- a/client/player/status.lua +++ b/client/player/status.lua @@ -1,36 +1,44 @@ -if not Config.Disable.Status then - local values = {} - local playerId = PlayerId() - - 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 - - local ped = PlayerPedId() - - values.healthBar = math.floor((GetEntityHealth(ped) - 100) / (GetEntityMaxHealth(ped) - 100) * 100) - values.armorBar = GetPedArmour(ped) - values.drinkBar = thirst - values.foodBar = hunger - end) - - function HUD:StatusThread() - values = {} - CreateThread(function () - while ESX.PlayerLoaded do - local oxygen, stamina - oxygen = math.floor(GetPlayerUnderwaterTimeRemaining(playerId) * 10) - stamina = math.floor(100 - GetPlayerSprintStaminaRemaining(playerId)) - if stamina == 0 then stamina = 1 end - if stamina == 100 then stamina = 0 end - values.oxygenBar = IsPedSwimmingUnderWater(PlayerPedId()) and oxygen or 0 - values.staminaBar = stamina - SendNUIMessage({ type = 'STATUS_HUD', value = values }) - Wait(200) - end - end) - end -end \ No newline at end of file +if not Config.Disable.Status then + local values = {} + local playerId = PlayerId() + + 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 + + local ped = PlayerPedId() + + values.healthBar = math.floor((GetEntityHealth(ped) - 100) / (GetEntityMaxHealth(ped) - 100) * 100) + values.armorBar = GetPedArmour(ped) + values.drinkBar = thirst + values.foodBar = hunger + end) + + function HUD:StatusThread() + values = {} + CreateThread(function() + while ESX.PlayerLoaded do + local oxygen, stamina + oxygen = math.floor(GetPlayerUnderwaterTimeRemaining(playerId) * 10) + stamina = math.floor(100 - GetPlayerSprintStaminaRemaining(playerId)) + if stamina == 0 then + stamina = 1 + end + if stamina == 100 then + stamina = 0 + end + values.oxygenBar = IsPedSwimmingUnderWater(PlayerPedId()) and oxygen or 0 + values.staminaBar = stamina + SendNUIMessage({ type = "STATUS_HUD", value = values }) + Wait(200) + end + end) + end +end diff --git a/client/vehicle/fuel.lua b/client/vehicle/fuel.lua index 895ba9d..6a4d601 100644 --- a/client/vehicle/fuel.lua +++ b/client/vehicle/fuel.lua @@ -1,16 +1,16 @@ -if not Config.Disable.Vehicle then - if GetResourceState('ox_fuel') == 'started' then - function HUD:FuelExport() - return ESX.Math.Round(GetVehicleFuelLevel(HUD.Data.Vehicle), 2) - end - elseif GetResourceState('LegacyFuel') == 'started' then - function HUD:FuelExport() - return ESX.Math.Round(exports["LegacyFuel"]:GetFuel(HUD.Data.Vehicle), 2) - end - else - function HUD:FuelExport() - return false - end - TriggerServerEvent('esx_hud:ErrorHandle', 'Setup your custom fuel resource at: client/vehicle/fuel.lua') - end -end \ No newline at end of file +if not Config.Disable.Vehicle then + if GetResourceState("ox_fuel") == "started" then + function HUD:FuelExport() + return ESX.Math.Round(GetVehicleFuelLevel(HUD.Data.Vehicle), 2) + end + elseif GetResourceState("LegacyFuel") == "started" then + function HUD:FuelExport() + return ESX.Math.Round(exports["LegacyFuel"]:GetFuel(HUD.Data.Vehicle), 2) + end + else + function HUD:FuelExport() + return false + end + TriggerServerEvent("esx_hud:ErrorHandle", "Setup your custom fuel resource at: client/vehicle/fuel.lua") + end +end diff --git a/client/vehicle/main.lua b/client/vehicle/main.lua index 53a70d0..e2b236d 100644 --- a/client/vehicle/main.lua +++ b/client/vehicle/main.lua @@ -1,188 +1,203 @@ -local cruiseControlStatus = false -local isPassenger = false - -local function SetCruiseControlState(state) - cruiseControlStatus = state -end - -exports('CruiseControlState', function(...) - SetCruiseControlState(...) -end) - -if not Config.Disable.Vehicle then - local inVehicle, vehicleType, playerPos = false, nil, nil - local currentMileage = 0 - - HUD.Data.Driver = false - - local values = { - show = false, - defaultIndicators = {} - } - - local function driverCheck(currentVehicle) - if not DoesEntityExist(currentVehicle) then return false end - if GetPedInVehicleSeat(currentVehicle, -1) == PlayerPedId() then - return true - end - return false - end - - local function driverCheckThread(currentVehicle) - CreateThread(function() - while inVehicle do - HUD.Data.Driver = driverCheck(currentVehicle) - playerPos = GetEntityCoords(PlayerPedId()).xy - - if not Config.Default.PassengerSpeedo and not HUD.Data.Driver then - SendNUIMessage({ type = 'VEH_HUD', value = { show = false } }) - isPassenger = true - end - Wait(1000) - end - end) - end - - local function slowInfoThread(currentVehicle) - CreateThread(function() - local oldPos = nil - - while inVehicle and DoesEntityExist(currentVehicle) do - local engineHealth = math.floor(GetVehicleEngineHealth(currentVehicle) / 10) - local _, lowBeam, highBeam = GetVehicleLightsState(currentVehicle) - local lightState = false - local indicator = GetVehicleIndicatorLights(currentVehicle) - local indicatorLeft, indicatorRight = false, false - local doorLockStatus = false - local tempDoorLockStatus = GetVehicleDoorLockStatus(currentVehicle) - - -- Make sure engine health not going to minus - if engineHealth < 0 then engineHealth = 0 end - - -- Set light state - if lowBeam == 1 or highBeam == 1 then lightState = true end - - -- Set indicator state - if indicator == 1 or indicator == 3 then indicatorLeft = true end - if indicator == 2 or indicator == 3 then indicatorRight = true end - - -- Set lock state - if tempDoorLockStatus == 2 or tempDoorLockStatus == 3 then doorLockStatus = true end - - 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.tempomat = cruiseControlStatus - values.defaultIndicators.door = doorLockStatus - values.defaultIndicators.light = lightState - values.defaultIndicators.leftIndex = indicatorLeft - values.defaultIndicators.rightIndex = indicatorRight - - Wait(200) - end - end) - end - - local function fastInfoThread(currentVehicle) - CreateThread(function() - while inVehicle do - local currentSpeed = GetEntitySpeed(currentVehicle) - local engineRunning = GetIsVehicleEngineRunning(currentVehicle) - local rpm - - if vehicleType == 'LAND' then - rpm = engineRunning and (GetVehicleCurrentRpm(currentVehicle) * 450) or 0 - else - rpm = math.ceil(ESX.PlayerData.coords.z) - end - - values.speed = Config.Default.Kmh and math.floor(currentSpeed * 3.6) or math.floor(currentSpeed * 2.236936) - values.rpm = rpm - values.defaultIndicators.engine = engineRunning - if not isPassenger then - SendNUIMessage({ type = 'VEH_HUD', value = values }) - end - Wait(50) - end - end) - end - - local function activateVehicleHud(currentVehicle) - values.show = true - slowInfoThread(currentVehicle) - fastInfoThread(currentVehicle) - end - - AddEventHandler('esx:enteredVehicle', function(currentVehicle, currentPlate, currentSeat, displayName, netId) - local vehicleClass = GetVehicleClass(currentVehicle) - if vehicleClass == 13 then return end - - inVehicle = true - HUD.Data.Driver = currentSeat == -1 or false - HUD.Data.Vehicle = currentVehicle - vehicleType = (vehicleClass == 15 or vehicleClass == 16) and 'AIR' or 'LAND' - -- We have to check if he changed seat meantime - driverCheckThread(currentVehicle) - - if Config.Disable.MinimapOnFoot then - DisplayRadar(true) - end - - activateVehicleHud(currentVehicle) - - if HUD.Data.Driver then - TriggerServerEvent('esx_hud:EnteredVehicle', currentPlate, Config.Default.Kmh) - end - end) - - AddEventHandler('esx:exitedVehicle', function(currentVehicle, currentPlate, currentSeat, displayName, netId) - inVehicle = false - 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 +local cruiseControlStatus = false +local isPassenger = false + +local function SetCruiseControlState(state) + cruiseControlStatus = state +end + +exports("CruiseControlState", function(...) + SetCruiseControlState(...) +end) + +if not Config.Disable.Vehicle then + local inVehicle, vehicleType, playerPos = false, nil, nil + local currentMileage = 0 + + HUD.Data.Driver = false + + local values = { + show = false, + defaultIndicators = {}, + } + + local function driverCheck(currentVehicle) + if not DoesEntityExist(currentVehicle) then + return false + end + if GetPedInVehicleSeat(currentVehicle, -1) == PlayerPedId() then + return true + end + return false + end + + local function driverCheckThread(currentVehicle) + CreateThread(function() + while inVehicle do + HUD.Data.Driver = driverCheck(currentVehicle) + playerPos = GetEntityCoords(PlayerPedId()).xy + + if not Config.Default.PassengerSpeedo and not HUD.Data.Driver then + SendNUIMessage({ type = "VEH_HUD", value = { show = false } }) + isPassenger = true + end + Wait(1000) + end + end) + end + + local function slowInfoThread(currentVehicle) + CreateThread(function() + local oldPos = nil + + while inVehicle and DoesEntityExist(currentVehicle) do + local engineHealth = math.floor(GetVehicleEngineHealth(currentVehicle) / 10) + local _, lowBeam, highBeam = GetVehicleLightsState(currentVehicle) + local lightState = false + local indicator = GetVehicleIndicatorLights(currentVehicle) + local indicatorLeft, indicatorRight = false, false + local doorLockStatus = false + local tempDoorLockStatus = GetVehicleDoorLockStatus(currentVehicle) + + -- Make sure engine health not going to minus + if engineHealth < 0 then + engineHealth = 0 + end + + -- Set light state + if lowBeam == 1 or highBeam == 1 then + lightState = true + end + + -- Set indicator state + if indicator == 1 or indicator == 3 then + indicatorLeft = true + end + if indicator == 2 or indicator == 3 then + indicatorRight = true + end + + -- Set lock state + if tempDoorLockStatus == 2 or tempDoorLockStatus == 3 then + doorLockStatus = true + end + + 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.tempomat = cruiseControlStatus + values.defaultIndicators.door = doorLockStatus + values.defaultIndicators.light = lightState + values.defaultIndicators.leftIndex = indicatorLeft + values.defaultIndicators.rightIndex = indicatorRight + + Wait(200) + end + end) + end + + local function fastInfoThread(currentVehicle) + CreateThread(function() + while inVehicle do + local currentSpeed = GetEntitySpeed(currentVehicle) + local engineRunning = GetIsVehicleEngineRunning(currentVehicle) + local rpm + + if vehicleType == "LAND" then + rpm = engineRunning and (GetVehicleCurrentRpm(currentVehicle) * 450) or 0 + else + rpm = math.ceil(ESX.PlayerData.coords.z) + end + + values.speed = Config.Default.Kmh and math.floor(currentSpeed * 3.6) + or math.floor(currentSpeed * 2.236936) + values.rpm = rpm + values.defaultIndicators.engine = engineRunning + if not isPassenger then + SendNUIMessage({ type = "VEH_HUD", value = values }) + end + Wait(50) + end + end) + end + + local function activateVehicleHud(currentVehicle) + values.show = true + slowInfoThread(currentVehicle) + fastInfoThread(currentVehicle) + end + + AddEventHandler("esx:enteredVehicle", function(currentVehicle, currentPlate, currentSeat, displayName, netId) + local vehicleClass = GetVehicleClass(currentVehicle) + if vehicleClass == 13 then + return + end + + inVehicle = true + HUD.Data.Driver = currentSeat == -1 or false + HUD.Data.Vehicle = currentVehicle + vehicleType = (vehicleClass == 15 or vehicleClass == 16) and "AIR" or "LAND" + -- We have to check if he changed seat meantime + driverCheckThread(currentVehicle) + + if Config.Disable.MinimapOnFoot then + DisplayRadar(true) + end + + activateVehicleHud(currentVehicle) + + if HUD.Data.Driver then + TriggerServerEvent("esx_hud:EnteredVehicle", currentPlate, Config.Default.Kmh) + end + end) + + AddEventHandler("esx:exitedVehicle", function(currentVehicle, currentPlate, currentSeat, displayName, netId) + inVehicle = false + 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 diff --git a/client/voice.lua b/client/voice.lua index c381cac..0d7ca48 100644 --- a/client/voice.lua +++ b/client/voice.lua @@ -1,31 +1,36 @@ -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 \ No newline at end of file +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 diff --git a/fxmanifest.lua b/fxmanifest.lua index fcbe47b..d9a9c37 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -1,38 +1,38 @@ -fx_version 'cerulean' -game 'gta5' -lua54 'yes' +fx_version("cerulean") +game("gta5") +lua54("yes") -description 'ESX hud' -version '1.4.0' +description("ESX hud") +version("1.4.0") -shared_scripts { - '@es_extended/imports.lua', - '@es_extended/locale.lua', - 'shared/config.lua', - 'shared/main.lua', - 'locales/*.lua' -} +shared_scripts({ + "@es_extended/imports.lua", + "@es_extended/locale.lua", + "shared/config.lua", + "shared/main.lua", + "locales/*.lua", +}) -server_scripts { - '@oxmysql/lib/MySQL.lua', - 'server/*.lua' -} +server_scripts({ + "@oxmysql/lib/MySQL.lua", + "server/*.lua", +}) -client_scripts { - 'client/*.lua', - 'client/player/*.lua', - 'client/vehicle/*.lua' -} +client_scripts({ + "client/*.lua", + "client/player/*.lua", + "client/vehicle/*.lua", +}) -ui_page 'web/dist/index.html' +ui_page("web/dist/index.html") -files { - 'web/dist/**', - 'web/dist/assets/**', -} +files({ + "web/dist/**", + "web/dist/assets/**", +}) -dependencies { - 'es_extended', - 'esx_status', - 'oxmysql' - } +dependencies({ + "es_extended", + "esx_status", + "oxmysql", +}) diff --git a/locales/da.lua b/locales/da.lua index 1c5e132..0474dbe 100644 --- a/locales/da.lua +++ b/locales/da.lua @@ -1,15 +1,15 @@ Locales["da"] = { - toggleHud = 'Slå HUD til/fra', - indicatorLeft = 'Venstre indikator', - indicatorRight = 'Højre indikator', - toggleEngine = 'Motor tænd/sluk', - speedChanged = 'Fart ændret, ny hastighed: ', - resource_not_built = 'Ressourcen er ikke lavet, download venligst udgivelsesversionen', - settingsSaveSuccess = "De nuværende indstillinger er gemt", - settingsResetSuccess = "Indstillingerne blev nulstillet", - currentVersion = "Seneste version: ", - yourVersion = "Din version: ", - latestVersion = "Du bruger den seneste version!", - needUpdateResource = "Du skal downloade den nyeste version! Du bruger en gammel version i øjeblikket!", - errorGetCurrentVersion = "Der opstod en fejl under forsøget på at hente den nuværende version!" + toggleHud = "Slå HUD til/fra", + indicatorLeft = "Venstre indikator", + indicatorRight = "Højre indikator", + toggleEngine = "Motor tænd/sluk", + speedChanged = "Fart ændret, ny hastighed: ", + resource_not_built = "Ressourcen er ikke lavet, download venligst udgivelsesversionen", + settingsSaveSuccess = "De nuværende indstillinger er gemt", + settingsResetSuccess = "Indstillingerne blev nulstillet", + currentVersion = "Seneste version: ", + yourVersion = "Din version: ", + latestVersion = "Du bruger den seneste version!", + needUpdateResource = "Du skal downloade den nyeste version! Du bruger en gammel version i øjeblikket!", + errorGetCurrentVersion = "Der opstod en fejl under forsøget på at hente den nuværende version!", } diff --git a/locales/de.lua b/locales/de.lua index e8f2701..9e5c69c 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -1,15 +1,15 @@ Locales["de"] = { - toggleHud = 'HUD An / Ausschalten', - indicatorLeft = 'Linker Blinker', - indicatorRight = 'Rechter Blinker', - toggleEngine = 'Motor an / aus', - speedChanged = 'Geschwindigkeit geändert! Neue Geschwindigkeit: ', - resource_not_built = 'Resource ist gebuilded! Downloade die neuste version!', - settingsSaveSuccess = "Erfolgreich die derzeitigen einstellungen gespeichert!", - settingsResetSuccess = "Einstellungen erfolgreich zurückgesetzt", - currentVersion = "Letzte Version: ", - yourVersion = "Deine Version: ", - latestVersion = "Du nutzt die Letze Version!", - needUpdateResource = "Du musst die letze Version downloaden! Installiere die neuste Version!", - errorGetCurrentVersion = "Ein Fehler kam als die Versionsabfrage durchgeführt wurde!" + toggleHud = "HUD An / Ausschalten", + indicatorLeft = "Linker Blinker", + indicatorRight = "Rechter Blinker", + toggleEngine = "Motor an / aus", + speedChanged = "Geschwindigkeit geändert! Neue Geschwindigkeit: ", + resource_not_built = "Resource ist gebuilded! Downloade die neuste version!", + settingsSaveSuccess = "Erfolgreich die derzeitigen einstellungen gespeichert!", + settingsResetSuccess = "Einstellungen erfolgreich zurückgesetzt", + currentVersion = "Letzte Version: ", + yourVersion = "Deine Version: ", + latestVersion = "Du nutzt die Letze Version!", + needUpdateResource = "Du musst die letze Version downloaden! Installiere die neuste Version!", + errorGetCurrentVersion = "Ein Fehler kam als die Versionsabfrage durchgeführt wurde!", } diff --git a/locales/en.lua b/locales/en.lua index c18c184..3b63f62 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,15 +1,15 @@ Locales["en"] = { - toggleHud = 'Turn HUD on / off', - indicatorLeft = 'Left indicator', - indicatorRight = 'Right indicator', - toggleEngine = 'Engine on / off', - speedChanged = 'Speed changed, new speed: ', - resource_not_built = 'Resource are not built, please download the release version', - settingsSaveSuccess = "Successfully save current settings", - settingsResetSuccess = "Successfully reset settings", - currentVersion = "Latest version: ", - yourVersion = "Your version: ", - latestVersion = "You are using the latest version!", - needUpdateResource = "You need download latest version! You are using an old version at the moment!", - errorGetCurrentVersion = "An error occurred while trying to get the current version!" + toggleHud = "Turn HUD on / off", + indicatorLeft = "Left indicator", + indicatorRight = "Right indicator", + toggleEngine = "Engine on / off", + speedChanged = "Speed changed, new speed: ", + resource_not_built = "Resource are not built, please download the release version", + settingsSaveSuccess = "Successfully save current settings", + settingsResetSuccess = "Successfully reset settings", + currentVersion = "Latest version: ", + yourVersion = "Your version: ", + latestVersion = "You are using the latest version!", + needUpdateResource = "You need download latest version! You are using an old version at the moment!", + errorGetCurrentVersion = "An error occurred while trying to get the current version!", } diff --git a/locales/fi.lua b/locales/fi.lua index 5a47018..5d278e6 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -1,15 +1,15 @@ Locales["fi"] = { - toggleHud = 'HUD päälle / kiinni', - indicatorLeft = 'Vasen vilkku', - indicatorRight = 'Oikea vilkku', - toggleEngine = 'Moottori päälle / kiinni', - speedChanged = 'Nopeutta muutettu, uusi nopeus: ', - resource_not_built = 'Resursseja ei ole rakennettu, lataa julkaisuversio', - settingsSaveSuccess = "Nykyisten asetusten tallentaminen onnistui", - settingsResetSuccess = "Asetusten nollaus onnistui", - currentVersion = "Uusin versio: ", - yourVersion = "Sinun versio: ", - latestVersion = "Käytät uusinta versiota!", - needUpdateResource = "Sinun on ladattava uusin versio! Käytät tällä hetkellä vanhaa versiota!", - errorGetCurrentVersion = "Virhe yritettäessä saada nykyinen versio!" + toggleHud = "HUD päälle / kiinni", + indicatorLeft = "Vasen vilkku", + indicatorRight = "Oikea vilkku", + toggleEngine = "Moottori päälle / kiinni", + speedChanged = "Nopeutta muutettu, uusi nopeus: ", + resource_not_built = "Resursseja ei ole rakennettu, lataa julkaisuversio", + settingsSaveSuccess = "Nykyisten asetusten tallentaminen onnistui", + settingsResetSuccess = "Asetusten nollaus onnistui", + currentVersion = "Uusin versio: ", + yourVersion = "Sinun versio: ", + latestVersion = "Käytät uusinta versiota!", + needUpdateResource = "Sinun on ladattava uusin versio! Käytät tällä hetkellä vanhaa versiota!", + errorGetCurrentVersion = "Virhe yritettäessä saada nykyinen versio!", } diff --git a/locales/fr.lua b/locales/fr.lua index c890dba..57d3c08 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -1,15 +1,15 @@ Locales["fr"] = { - toggleHud = "Activer/Désactiver l'hud", - indicatorLeft = "Clignotant gauche", - indicatorRight = "Clignotant droit", - toggleEngine = "Allumer/éteindre le moteur", - speedChanged = "La vitesse a été changée, nouvelle vitesse: ", - resource_not_built = "La ressource n'est pas build, télécharger une version officielle ou compilez la ressource vous même", - settingsSaveSuccess = "Les paramètres actuels ont bien été sauvegardés", - settingsResetSuccess = "Les paramètres ont bien été réinitialisés", - currentVersion = "Dernière version: ", - yourVersion = "Votre version: ", - latestVersion = "Vous utilisez la dernière version!", - needUpdateResource = "Vous devez télécharger la dernière version! Vous utilisez actuellement une ancienne version!", - errorGetCurrentVersion = "Une erreur s'est produite lors de la tentative d'obtention de la version actuelle!" -} \ No newline at end of file + toggleHud = "Activer/Désactiver l'hud", + indicatorLeft = "Clignotant gauche", + indicatorRight = "Clignotant droit", + toggleEngine = "Allumer/éteindre le moteur", + speedChanged = "La vitesse a été changée, nouvelle vitesse: ", + resource_not_built = "La ressource n'est pas build, télécharger une version officielle ou compilez la ressource vous même", + settingsSaveSuccess = "Les paramètres actuels ont bien été sauvegardés", + settingsResetSuccess = "Les paramètres ont bien été réinitialisés", + currentVersion = "Dernière version: ", + yourVersion = "Votre version: ", + latestVersion = "Vous utilisez la dernière version!", + needUpdateResource = "Vous devez télécharger la dernière version! Vous utilisez actuellement une ancienne version!", + errorGetCurrentVersion = "Une erreur s'est produite lors de la tentative d'obtention de la version actuelle!", +} diff --git a/locales/hu.lua b/locales/hu.lua index 9347e6e..d824e73 100644 --- a/locales/hu.lua +++ b/locales/hu.lua @@ -1,17 +1,17 @@ Locales["hu"] = { - toggleHud = 'Hud ki / be kapcsolása', - indicatorLeft = 'Bal index', - indicatorRight = 'Jobb index', - toggleEngine = 'Motor ki / be kapcsolása', - increaseSpeed = '(Tempomat) Sebbeség nővelése', - decreaseSpeed = '(Tempomat) Sebbeség csökkenentése', - speedChanged = 'Sebesség megváltoztatva, új sebbeség: ', - resource_not_built = 'Nincs le buildelve a resource, kérlek töltsd le a release-t', - settingsSaveSuccess = "Sikeresen megtörtént a mentése beállításoknak!", - settingsResetSuccess = "Sikeresen megtörtént a visszaállítása a beállításoknak!", - latestVersion = "Legújabb verziót használod!", - currentVersion = "Legfrissebb verzió: ", - yourVersion = "Jelenlegi verziód: ", - needUpdateResource = "Elavult a verziód töltsd le a legújabbat!", - errorGetCurrentVersion = "Hiba történt a verzió lekérdezés közben!" -} \ No newline at end of file + toggleHud = "Hud ki / be kapcsolása", + indicatorLeft = "Bal index", + indicatorRight = "Jobb index", + toggleEngine = "Motor ki / be kapcsolása", + increaseSpeed = "(Tempomat) Sebbeség nővelése", + decreaseSpeed = "(Tempomat) Sebbeség csökkenentése", + speedChanged = "Sebesség megváltoztatva, új sebbeség: ", + resource_not_built = "Nincs le buildelve a resource, kérlek töltsd le a release-t", + settingsSaveSuccess = "Sikeresen megtörtént a mentése beállításoknak!", + settingsResetSuccess = "Sikeresen megtörtént a visszaállítása a beállításoknak!", + latestVersion = "Legújabb verziót használod!", + currentVersion = "Legfrissebb verzió: ", + yourVersion = "Jelenlegi verziód: ", + needUpdateResource = "Elavult a verziód töltsd le a legújabbat!", + errorGetCurrentVersion = "Hiba történt a verzió lekérdezés közben!", +} diff --git a/locales/it.lua b/locales/it.lua index dd7c19d..2c3f767 100644 --- a/locales/it.lua +++ b/locales/it.lua @@ -1,15 +1,15 @@ Locales["it"] = { - toggleHud = 'Attiva / disattiva HUD', - indicatorLeft = 'Indicatore sinistro', - indicatorRight = 'Indicatore destro', - toggleEngine = 'Motore acceso/spento', - speedChanged = 'Velocità modificata, nuova velocità: ', - resource_not_built = 'La risorsa non è stata buildata, scarica la versione release, non il source code!', - settingsSaveSuccess = "Salvataggio delle impostazioni correnti riuscito", - settingsResetSuccess = "Ripristino impostazioni riuscito", - currentVersion = "Ultima versione ", - yourVersion = "La tua versione:", - latestVersion = "Stai utilizzando l\'ultima versione!", - needUpdateResource = "Devi scaricare l\'ultima versione! Al momento stai usando una vecchia versione!", - errorGetCurrentVersion = "Si è verificato un errore durante il tentativo di ottenere la versione corrente!" + toggleHud = "Attiva / disattiva HUD", + indicatorLeft = "Indicatore sinistro", + indicatorRight = "Indicatore destro", + toggleEngine = "Motore acceso/spento", + speedChanged = "Velocità modificata, nuova velocità: ", + resource_not_built = "La risorsa non è stata buildata, scarica la versione release, non il source code!", + settingsSaveSuccess = "Salvataggio delle impostazioni correnti riuscito", + settingsResetSuccess = "Ripristino impostazioni riuscito", + currentVersion = "Ultima versione ", + yourVersion = "La tua versione:", + latestVersion = "Stai utilizzando l'ultima versione!", + needUpdateResource = "Devi scaricare l'ultima versione! Al momento stai usando una vecchia versione!", + errorGetCurrentVersion = "Si è verificato un errore durante il tentativo di ottenere la versione corrente!", } diff --git a/locales/nl.lua b/locales/nl.lua index b31649b..92dda06 100644 --- a/locales/nl.lua +++ b/locales/nl.lua @@ -1,15 +1,15 @@ Locales["nl"] = { - toggleHud = 'Zet HUD aan / uit', - indicatorLeft = 'Linker richtingaanwijzer', - indicatorRight = 'Rechter richtingaanwijzer', - toggleEngine = 'Motor aan / uit', - speedChanged = 'Snelheid veranderd, nieuwe snelheid: ', - resource_not_built = 'Resource is niet gebouwd, download de releaseversie', - settingsSaveSuccess = "De instellingen zijn succesvol opgeslagen", - settingsResetSuccess = "De instellingen zijn succesvol gereset", - currentVersion = "Laatste versie: ", - yourVersion = "Jouw versie: ", - latestVersion = "Je gebruikt de laatste versie !", - needUpdateResource = "Je bent een oude versie aan het gebruiken ! download de nieuwste versie !", - errorGetCurrentVersion = "Er is een error ontstaan tijdens het ophalen van de huidige versie !" + toggleHud = "Zet HUD aan / uit", + indicatorLeft = "Linker richtingaanwijzer", + indicatorRight = "Rechter richtingaanwijzer", + toggleEngine = "Motor aan / uit", + speedChanged = "Snelheid veranderd, nieuwe snelheid: ", + resource_not_built = "Resource is niet gebouwd, download de releaseversie", + settingsSaveSuccess = "De instellingen zijn succesvol opgeslagen", + settingsResetSuccess = "De instellingen zijn succesvol gereset", + currentVersion = "Laatste versie: ", + yourVersion = "Jouw versie: ", + latestVersion = "Je gebruikt de laatste versie !", + needUpdateResource = "Je bent een oude versie aan het gebruiken ! download de nieuwste versie !", + errorGetCurrentVersion = "Er is een error ontstaan tijdens het ophalen van de huidige versie !", } diff --git a/locales/pt.lua b/locales/pt.lua index c6333a6..e7073c2 100644 --- a/locales/pt.lua +++ b/locales/pt.lua @@ -1,15 +1,15 @@ Locales["pt"] = { - toggleHud = 'Ligar o HUD, on / off', - indicatorLeft = 'Pisca esquerdo', - indicatorRight = 'Pisca direito', - toggleEngine = 'Motor, on / off', - speedChanged = 'Velocidade alterada, nova velocidade: ', - resource_not_built = 'O resource não foi construido, por favor faz download da versão "Release"', - settingsSaveSuccess = "Salvaste as atuais definições com sucesso", - settingsResetSuccess = "Formataste as definições com sucesso", - currentVersion = "Versão mais recente: ", - yourVersion = "A tua versão: ", - latestVersion = "Estás a usar a versão mais recente!", - needUpdateResource = "Precisas de descarregar a versão mais recente! Neste momento, estás a utilizar uma versão antiga!", - errorGetCurrentVersion = "Ocorreu um erro ao tentar obter a versão atual!" + toggleHud = "Ligar o HUD, on / off", + indicatorLeft = "Pisca esquerdo", + indicatorRight = "Pisca direito", + toggleEngine = "Motor, on / off", + speedChanged = "Velocidade alterada, nova velocidade: ", + resource_not_built = 'O resource não foi construido, por favor faz download da versão "Release"', + settingsSaveSuccess = "Salvaste as atuais definições com sucesso", + settingsResetSuccess = "Formataste as definições com sucesso", + currentVersion = "Versão mais recente: ", + yourVersion = "A tua versão: ", + latestVersion = "Estás a usar a versão mais recente!", + needUpdateResource = "Precisas de descarregar a versão mais recente! Neste momento, estás a utilizar uma versão antiga!", + errorGetCurrentVersion = "Ocorreu um erro ao tentar obter a versão atual!", } diff --git a/locales/sr.lua b/locales/sr.lua index 7b7d459..a9ddc7e 100644 --- a/locales/sr.lua +++ b/locales/sr.lua @@ -1,15 +1,15 @@ Locales["sr"] = { - toggleHud = 'Upalite/Ugasite HUD', - indicatorLeft = 'Levi migavac', - indicatorRight = 'Desni migavac', - toggleEngine = 'Motor upaljen/ugašen', - speedChanged = 'Brzina promenjena, nova brzina: ', - resource_not_built = 'Resurs nije napravljen, preuzmite release verziju resursa!', - settingsSaveSuccess = "Trenutna podešavanja uspešno sačuvana", - settingsResetSuccess = "Podešavanja uspešno resetovana", - currentVersion = "Poslednja verzija: ", - yourVersion = "Vaša verzija: ", - latestVersion = "Vi koristite poslednju verziju!", - needUpdateResource = "Morate preuzeti najnoviju verziju. Trenutno koristite staru verziju.", - errorGetCurrentVersion = "Došlo je do greške prilikom provere trenutne verzije resursa!" + toggleHud = "Upalite/Ugasite HUD", + indicatorLeft = "Levi migavac", + indicatorRight = "Desni migavac", + toggleEngine = "Motor upaljen/ugašen", + speedChanged = "Brzina promenjena, nova brzina: ", + resource_not_built = "Resurs nije napravljen, preuzmite release verziju resursa!", + settingsSaveSuccess = "Trenutna podešavanja uspešno sačuvana", + settingsResetSuccess = "Podešavanja uspešno resetovana", + currentVersion = "Poslednja verzija: ", + yourVersion = "Vaša verzija: ", + latestVersion = "Vi koristite poslednju verziju!", + needUpdateResource = "Morate preuzeti najnoviju verziju. Trenutno koristite staru verziju.", + errorGetCurrentVersion = "Došlo je do greške prilikom provere trenutne verzije resursa!", } diff --git a/locales/tr.lua b/locales/tr.lua index b13ba07..7be1d1b 100644 --- a/locales/tr.lua +++ b/locales/tr.lua @@ -1,15 +1,15 @@ Locales["tr"] = { - toggleHud = 'HUD aç / kapat', - indicatorLeft = 'Sol gösterge', - indicatorRight = 'Sağ gösterge', - toggleEngine = 'Motoru aç / kapat', - speedChanged = 'Hız değiştirildi, yeni hız: ', - resource_not_built = 'Kaynak kurulamadı, lütfen uygun sürümü indiriniz', - settingsSaveSuccess = "Ayarlar başarıyla kaydedildi", - settingsResetSuccess = "Ayarlar başarıyla sıfırlandı", - currentVersion = "Son sürüm: ", - yourVersion = "Şu anki sürüm: ", - latestVersion = "Son sürümü kullanmaktasın!", - needUpdateResource = "Son sürümü kullanmanız gerekmekte! Şu anda eski bir sürüm kullanıyorsunuz!", - errorGetCurrentVersion = "Geçerli sürümü almaya çalışırken hata oluştu!" -} \ No newline at end of file + toggleHud = "HUD aç / kapat", + indicatorLeft = "Sol gösterge", + indicatorRight = "Sağ gösterge", + toggleEngine = "Motoru aç / kapat", + speedChanged = "Hız değiştirildi, yeni hız: ", + resource_not_built = "Kaynak kurulamadı, lütfen uygun sürümü indiriniz", + settingsSaveSuccess = "Ayarlar başarıyla kaydedildi", + settingsResetSuccess = "Ayarlar başarıyla sıfırlandı", + currentVersion = "Son sürüm: ", + yourVersion = "Şu anki sürüm: ", + latestVersion = "Son sürümü kullanmaktasın!", + needUpdateResource = "Son sürümü kullanmanız gerekmekte! Şu anda eski bir sürüm kullanıyorsunuz!", + errorGetCurrentVersion = "Geçerli sürümü almaya çalışırken hata oluştu!", +} diff --git a/server/main.lua b/server/main.lua index 5fbec0f..685e038 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,113 +1,123 @@ -HUD.VersionCheckURL = 'https://api.github.com/repos/esx-framework/esx-hud/releases/latest' - -function HUD:ErrorHandle(msg) - print(('[^1ERROR^7] ^3esx_hud^7: %s'):format(msg)) -end - -function HUD:InfoHandle(msg, color) - if color == "green" then - color = 2 - elseif color == "red" then - color = 1 - elseif color == "blue" then - color = 4 - else - color = 3 - end - print(('[^9INFO^7] ^3esx_hud^7: ^'..color..'%s^7'):format(msg)) -end - -function HUD:UpdatePlayerCount() - GlobalState['OnlinePlayers'] = HUD.Data.OnlinePlayers -end - -VERSION = { - Check = function(err, response, headers) - --Credit: OX_lib version checker by Linden - local currentVersion = GetResourceMetadata(GetCurrentResourceName(), 'version', 0) - local latestVersion - if not currentVersion then return end - - if err ~= 200 then - HUD:ErrorHandle(Translate('errorGetCurrentVersion')) - return - end - if response then - response = json.decode(response) - if not response.tag_name then return end - - latestVersion = response.tag_name:match('%d%.%d+%.%d+') - currentVersion = currentVersion:match('%d%.%d+%.%d+') - - if not latestVersion then return end - - if currentVersion == latestVersion then - HUD:InfoHandle(Translate('latestVersion'),"green") - return - end - - local currentVersionSplitted = {string.strsplit('.', currentVersion)} - local latestVersionSplitted = {string.strsplit('.', latestVersion)} - - HUD:InfoHandle(Translate('currentVersion') .. latestVersion, "green") - HUD:InfoHandle(Translate('yourVersion') .. currentVersion,"blue") - - for i = 1, #currentVersionSplitted do - local current, latest = tonumber(currentVersionSplitted[i]), tonumber(latestVersionSplitted[i]) - if current ~= latest then - if not current or not latest then return end - if current < latest then - HUD:InfoHandle(Translate('needUpdateResource'),"red") - else - break; - end - end - end - end - end, - - RunVersionChecker = function() - CreateThread(function() - PerformHttpRequest(HUD.VersionCheckURL, VERSION.Check, "GET") - end) - end -} - -RegisterNetEvent('esx_hud:ErrorHandle', function(msg) - HUD:ErrorHandle(msg) -end) - -AddEventHandler('playerJoining', function(playerId, reason) - HUD.Data.OnlinePlayers += 1 - HUD:UpdatePlayerCount() -end) - -AddEventHandler('playerDropped', function() - HUD.Data.OnlinePlayers += -1 - if HUD.Data.OnlinePlayers < 0 then - HUD.Data.OnlinePlayers = 0 - end - HUD:UpdatePlayerCount() -end) - -AddEventHandler('onResourceStart', function(resourceName) - local currentName = GetCurrentResourceName() - if resourceName ~= currentName then return end - local built = LoadResourceFile(currentName, './web/dist/index.html') - - Wait(100) - HUD.Data.OnlinePlayers = #GetPlayers() - HUD:UpdatePlayerCount() - - --Run version checker - VERSION:RunVersionChecker() - - if not built then - CreateThread(function () - while true do - HUD:ErrorHandle(Translate('resource_not_built')) - Wait(10000) - end - end) - end -end) +HUD.VersionCheckURL = "https://api.github.com/repos/esx-framework/esx-hud/releases/latest" + +function HUD:ErrorHandle(msg) + print(("[^1ERROR^7] ^3esx_hud^7: %s"):format(msg)) +end + +function HUD:InfoHandle(msg, color) + if color == "green" then + color = 2 + elseif color == "red" then + color = 1 + elseif color == "blue" then + color = 4 + else + color = 3 + end + print(("[^9INFO^7] ^3esx_hud^7: ^" .. color .. "%s^7"):format(msg)) +end + +function HUD:UpdatePlayerCount() + GlobalState["OnlinePlayers"] = HUD.Data.OnlinePlayers +end + +VERSION = { + Check = function(err, response, headers) + --Credit: OX_lib version checker by Linden + local currentVersion = GetResourceMetadata(GetCurrentResourceName(), "version", 0) + local latestVersion + if not currentVersion then + return + end + + if err ~= 200 then + HUD:ErrorHandle(Translate("errorGetCurrentVersion")) + return + end + if response then + response = json.decode(response) + if not response.tag_name then + return + end + + latestVersion = response.tag_name:match("%d%.%d+%.%d+") + currentVersion = currentVersion:match("%d%.%d+%.%d+") + + if not latestVersion then + return + end + + if currentVersion == latestVersion then + HUD:InfoHandle(Translate("latestVersion"), "green") + return + end + + local currentVersionSplitted = { string.strsplit(".", currentVersion) } + local latestVersionSplitted = { string.strsplit(".", latestVersion) } + + HUD:InfoHandle(Translate("currentVersion") .. latestVersion, "green") + HUD:InfoHandle(Translate("yourVersion") .. currentVersion, "blue") + + for i = 1, #currentVersionSplitted do + local current, latest = tonumber(currentVersionSplitted[i]), tonumber(latestVersionSplitted[i]) + if current ~= latest then + if not current or not latest then + return + end + if current < latest then + HUD:InfoHandle(Translate("needUpdateResource"), "red") + else + break + end + end + end + end + end, + + RunVersionChecker = function() + CreateThread(function() + PerformHttpRequest(HUD.VersionCheckURL, VERSION.Check, "GET") + end) + end, +} + +RegisterNetEvent("esx_hud:ErrorHandle", function(msg) + HUD:ErrorHandle(msg) +end) + +AddEventHandler("playerJoining", function(playerId, reason) + HUD.Data.OnlinePlayers += 1 + HUD:UpdatePlayerCount() +end) + +AddEventHandler("playerDropped", function() + HUD.Data.OnlinePlayers += -1 + if HUD.Data.OnlinePlayers < 0 then + HUD.Data.OnlinePlayers = 0 + end + HUD:UpdatePlayerCount() +end) + +AddEventHandler("onResourceStart", function(resourceName) + local currentName = GetCurrentResourceName() + if resourceName ~= currentName then + return + end + local built = LoadResourceFile(currentName, "./web/dist/index.html") + + Wait(100) + HUD.Data.OnlinePlayers = #GetPlayers() + HUD:UpdatePlayerCount() + + --Run version checker + VERSION:RunVersionChecker() + + if not built then + CreateThread(function() + while true do + HUD:ErrorHandle(Translate("resource_not_built")) + Wait(10000) + end + end) + end +end) diff --git a/server/mileage.lua b/server/mileage.lua index 2c22d47..bd3ab02 100644 --- a/server/mileage.lua +++ b/server/mileage.lua @@ -1,122 +1,123 @@ -if not Config.Disable.Vehicle then - HUD.Mileage = { - Data = {} - } - - local Mileage = HUD.Mileage - - -- Create column in sql if not exist - -- CREDIT: Overextended (https://github.com/overextended) - CreateThread(function() - local success, result = pcall(MySQL.query.await, 'SELECT mileage FROM owned_vehicles') - if not success then - MySQL.query('ALTER TABLE owned_vehicles ADD COLUMN `mileage` FLOAT(10) DEFAULT 0; ') - end - end) - - function Mileage:Load(plate, playerId, kmh) - MySQL.single('SELECT mileage FROM owned_vehicles WHERE plate = ?', { plate }, function(data) - local mileage, owned - if data then - mileage, owned = data.mileage, true - if kmh then - mileage = mileage * 1.61 - end - else - mileage, owned = math.random(100, 10000), false - end - self:Create(plate, mileage, owned, playerId) - end) - end - - function Mileage:Save() - if next(Mileage.Data) then - local parameters = {} - for plate, data in pairs(Mileage.Data) do - if data.owned then - parameters[#parameters + 1] = { data.mileage, plate } - end - end - - if next(parameters) then - MySQL.prepare('UPDATE `owned_vehicles` SET `mileage` = ? WHERE `plate` = ?', parameters) - end - end - end - - function Mileage:Create(plate, mileage, owned, playerId) - self.Data[plate] = {mileage = mileage, owned = owned} - self:UpdateClient(mileage, playerId) - end - - function Mileage:Update(plate, mileage, playerId, kmh) - if not self.Data[plate] then - return - end - - if kmh then - mileage = mileage / 1.61 - end - - self.Data[plate].mileage = mileage - if playerId then - self:UpdateClient(mileage, playerId) - end - end - - function Mileage:Exist(plate, playerId, kmh) - if self.Data[plate] then - local milage = self.Data[plate].mileage - if kmh then - milage = self.Data[plate].mileage * 1.61 - end - self:UpdateClient(milage, playerId) - return - end - self:Load(plate, playerId, kmh) - end - - -- Send date to client - function Mileage:UpdateClient(mileage, playerId) - TriggerClientEvent('esx_hud:UpdateMileage', playerId, mileage) - end - - RegisterNetEvent('esx_hud:EnteredVehicle', function(plate, kmh) - local playerId = source - Mileage:Exist(plate, playerId, kmh) - end) - - RegisterNetEvent('esx_hud:ExitedVehicle', function(plate, mileage, kmh) - Mileage:Update(plate, mileage, source, kmh) - end) - - -- Auto save every 5 min - CreateThread(function() - while true do - Wait(1000*60*5) - Mileage:Save() - end - end) - - -- Auto save on resource stop - AddEventHandler('onResourceStop', function(resourceName) - if GetCurrentResourceName() ~= resourceName then return end - Mileage:Save() - end) - - -- Auto save 10 sec before scheduled restart - AddEventHandler('txAdmin:events:scheduledRestart', function(eventData) - if eventData.secondsRemaining == 60 then - CreateThread(function() - Wait(50000) - Mileage:Save() - end) - end - end) - - -- Auto save on txAdmin server stop - AddEventHandler('txAdmin:events:serverShuttingDown', function() - Mileage:Save() - end) - -end \ No newline at end of file +if not Config.Disable.Vehicle then + HUD.Mileage = { + Data = {}, + } + + local Mileage = HUD.Mileage + + -- Create column in sql if not exist + -- CREDIT: Overextended (https://github.com/overextended) + CreateThread(function() + local success, result = pcall(MySQL.query.await, "SELECT mileage FROM owned_vehicles") + if not success then + MySQL.query("ALTER TABLE owned_vehicles ADD COLUMN `mileage` FLOAT(10) DEFAULT 0; ") + end + end) + + function Mileage:Load(plate, playerId, kmh) + MySQL.single("SELECT mileage FROM owned_vehicles WHERE plate = ?", { plate }, function(data) + local mileage, owned + if data then + mileage, owned = data.mileage, true + if kmh then + mileage = mileage * 1.61 + end + else + mileage, owned = math.random(100, 10000), false + end + self:Create(plate, mileage, owned, playerId) + end) + end + + function Mileage:Save() + if next(Mileage.Data) then + local parameters = {} + for plate, data in pairs(Mileage.Data) do + if data.owned then + parameters[#parameters + 1] = { data.mileage, plate } + end + end + + if next(parameters) then + MySQL.prepare("UPDATE `owned_vehicles` SET `mileage` = ? WHERE `plate` = ?", parameters) + end + end + end + + function Mileage:Create(plate, mileage, owned, playerId) + self.Data[plate] = { mileage = mileage, owned = owned } + self:UpdateClient(mileage, playerId) + end + + function Mileage:Update(plate, mileage, playerId, kmh) + if not self.Data[plate] then + return + end + + if kmh then + mileage = mileage / 1.61 + end + + self.Data[plate].mileage = mileage + if playerId then + self:UpdateClient(mileage, playerId) + end + end + + function Mileage:Exist(plate, playerId, kmh) + if self.Data[plate] then + local milage = self.Data[plate].mileage + if kmh then + milage = self.Data[plate].mileage * 1.61 + end + self:UpdateClient(milage, playerId) + return + end + self:Load(plate, playerId, kmh) + end + + -- Send date to client + function Mileage:UpdateClient(mileage, playerId) + TriggerClientEvent("esx_hud:UpdateMileage", playerId, mileage) + end + + RegisterNetEvent("esx_hud:EnteredVehicle", function(plate, kmh) + local playerId = source + Mileage:Exist(plate, playerId, kmh) + end) + + RegisterNetEvent("esx_hud:ExitedVehicle", function(plate, mileage, kmh) + Mileage:Update(plate, mileage, source, kmh) + end) + + -- Auto save every 5 min + CreateThread(function() + while true do + Wait(1000 * 60 * 5) + Mileage:Save() + end + end) + + -- Auto save on resource stop + AddEventHandler("onResourceStop", function(resourceName) + if GetCurrentResourceName() ~= resourceName then + return + end + Mileage:Save() + end) + + -- Auto save 10 sec before scheduled restart + AddEventHandler("txAdmin:events:scheduledRestart", function(eventData) + if eventData.secondsRemaining == 60 then + CreateThread(function() + Wait(50000) + Mileage:Save() + end) + end + end) + + -- Auto save on txAdmin server stop + AddEventHandler("txAdmin:events:serverShuttingDown", function() + Mileage:Save() + end) +end diff --git a/shared/config.lua b/shared/config.lua index c602b9e..82ec5d1 100644 --- a/shared/config.lua +++ b/shared/config.lua @@ -1,62 +1,62 @@ Config = { - Locale = GetConvar('esx:locale', 'en'), -- If you want to change UI language texts you can do it here: web/src/assets/translate.json !!IMPORTANT that this can only be modified with the unbuilt version. - Colors = { - Info = { - ['money-text-color'] = "#4d6973", - ['bank-text-color'] = "#32a852", - ['job-text-color'] = "orange", - }, - Status = { - healthBar = 'red', - armorBar = 'blue', - drinkBar = 'lightblue', - foodBar = 'yellow' - }, - Speedo = { - ['segment-color'] = '#eee', - ['segment-progress-color'] = 'green', - ['number-color'] = '#eee', - ['danger-color'] = 'red', - ['danger-progress-color'] = 'pink', - ['number-danger-color'] = '#eee', - ['speedo-progress-color'] = 'orange', - ['damage-progress-color'] = '#258539', - ['speedo-all-texts'] = 'orange', - ['engine-icon-color'] = "#FEC32C", - ['tempomat-icon-color'] = "#FEC32C", - ['light-icon-color'] = "#FEC32C", - ['door-icon-color'] = "#FEC32C", - ['fuel-icon-color'] = "white", - ['fuel-level-color'] = "white", - ['mileage-level-color'] = "#eee", - ['unit-color'] = "white", - ['current-speed-color'] = "pink", - ['left-right-index-color'] = "#00B065", - ['damage-icon-color'] = "white", - ['speedo-background-color'] = "rgba(0,0,0,.5)", - ['speedo-outer-circle-color'] = "#242222", - ['speedo-nooble-color'] = "#48a3cb", - ['speedo-nooble-container'] = "#1f2937" - } - }, - Disable = { - Status = false, - Vehicle = false, - Weapon = false, - Position = false, - Voice = false, - Money = false, - Info = false, - IndicatorSound = false, --vehicle index sound - VehicleHandlers = false, -- Engine toggle, Indicator lights - MinimapOnFoot = false, - Needle = true, - StatusPercent = true, - CenterStatuses = true - }, - Default = { - ServerLogo = 'https://esx.s3.fr-par.scw.cloud/blanc-800x800.png', - Kmh = false, - PassengerSpeedo = false -- if this true , you can see speedometer if you don't driver - } + Locale = GetConvar("esx:locale", "en"), -- If you want to change UI language texts you can do it here: web/src/assets/translate.json !!IMPORTANT that this can only be modified with the unbuilt version. + Colors = { + Info = { + ["money-text-color"] = "#4d6973", + ["bank-text-color"] = "#32a852", + ["job-text-color"] = "orange", + }, + Status = { + healthBar = "red", + armorBar = "blue", + drinkBar = "lightblue", + foodBar = "yellow", + }, + Speedo = { + ["segment-color"] = "#eee", + ["segment-progress-color"] = "green", + ["number-color"] = "#eee", + ["danger-color"] = "red", + ["danger-progress-color"] = "pink", + ["number-danger-color"] = "#eee", + ["speedo-progress-color"] = "orange", + ["damage-progress-color"] = "#258539", + ["speedo-all-texts"] = "orange", + ["engine-icon-color"] = "#FEC32C", + ["tempomat-icon-color"] = "#FEC32C", + ["light-icon-color"] = "#FEC32C", + ["door-icon-color"] = "#FEC32C", + ["fuel-icon-color"] = "white", + ["fuel-level-color"] = "white", + ["mileage-level-color"] = "#eee", + ["unit-color"] = "white", + ["current-speed-color"] = "pink", + ["left-right-index-color"] = "#00B065", + ["damage-icon-color"] = "white", + ["speedo-background-color"] = "rgba(0,0,0,.5)", + ["speedo-outer-circle-color"] = "#242222", + ["speedo-nooble-color"] = "#48a3cb", + ["speedo-nooble-container"] = "#1f2937", + }, + }, + Disable = { + Status = false, + Vehicle = false, + Weapon = false, + Position = false, + Voice = false, + Money = false, + Info = false, + IndicatorSound = false, --vehicle index sound + VehicleHandlers = false, -- Engine toggle, Indicator lights + MinimapOnFoot = false, + Needle = true, + StatusPercent = true, + CenterStatuses = true, + }, + Default = { + ServerLogo = "https://esx.s3.fr-par.scw.cloud/blanc-800x800.png", + Kmh = false, + PassengerSpeedo = false, -- if this true , you can see speedometer if you don't driver + }, } diff --git a/shared/main.lua b/shared/main.lua index 912aa55..497a5e4 100644 --- a/shared/main.lua +++ b/shared/main.lua @@ -1,6 +1,6 @@ -HUD = {} -HUD.Data = { - OnlinePlayers = 0, - Weapon = {}, - Money = {} -} \ No newline at end of file +HUD = {} +HUD.Data = { + OnlinePlayers = 0, + Weapon = {}, + Money = {}, +} diff --git a/web/DefaultDatas.js b/web/DefaultDatas.js index 7a74da3..0531ae1 100644 --- a/web/DefaultDatas.js +++ b/web/DefaultDatas.js @@ -1,331 +1,355 @@ - -import {ArmorIcon, DrinkIcon, FoodIcon, HealthIcon, OxygenIcon, StaminaIcon} from "./src/assets/Icons"; - +import { + ArmorIcon, + DrinkIcon, + FoodIcon, + HealthIcon, + OxygenIcon, + StaminaIcon, +} from "./src/assets/Icons"; let defaultConfig = { - ServerLogo: "", - Kmh: false -} + ServerLogo: "", + Kmh: false, +}; let disableDefaultConfig = { - Status: false, - Vehicle: false, - Weapon: false, - Position: false, - Voice: false, - Money: false, - Info: false, - IndicatorSound: false, - VehicleHandlers:false, - MinimapOnFoot:false, - Needle: false, - Kmh: true, - StatusPercent: false -} + Status: false, + Vehicle: false, + Weapon: false, + Position: false, + Voice: false, + Money: false, + Info: false, + IndicatorSound: false, + VehicleHandlers: false, + MinimapOnFoot: false, + Needle: false, + Kmh: true, + StatusPercent: false, +}; const progressColors = { - healthBar: "red", - armorBar: "blue", - drinkBar: "lightblue", - foodBar: "yellow", - oxygenBar: "green", - staminaBar: "purple" -} + healthBar: "red", + armorBar: "blue", + drinkBar: "lightblue", + foodBar: "yellow", + oxygenBar: "green", + staminaBar: "purple", +}; const vehDefaultData = { - show: true, - fuel: {level: 100, maxLevel: 100}, - mileage: 5000, - kmh: false, - speed: 50, - rpm: 100, - damage: 100, - vehType: "LAND", -} + show: true, + fuel: { level: 100, maxLevel: 100 }, + mileage: 5000, + kmh: false, + speed: 50, + rpm: 100, + damage: 100, + vehType: "LAND", +}; const hudDefaultData = { - playerId: 1, - onlinePlayers:150, - serverLogo: "https://esx.s3.fr-par.scw.cloud/blanc-800x800.png", - moneys: {bank: 75000, money: 100000}, - weaponData: { use: true ,image: "pistol", name: "WEAPON NAME" , currentAmmo: 32, maxAmmo: 128 , isWeaponMelee: false}, - streetName: "", - mic: false, -} + playerId: 1, + onlinePlayers: 150, + serverLogo: "https://esx.s3.fr-par.scw.cloud/blanc-800x800.png", + moneys: { bank: 75000, money: 100000 }, + weaponData: { + use: true, + image: "pistol", + name: "WEAPON NAME", + currentAmmo: 32, + maxAmmo: 128, + isWeaponMelee: false, + }, + streetName: "", + mic: false, +}; const progressLevels = { - healthBar: 20, - armorBar: 80, - drinkBar: 40, - foodBar: 80, - oxygenBar: 100, - staminaBar: 100 -} + healthBar: 20, + armorBar: 80, + drinkBar: 40, + foodBar: 80, + oxygenBar: 100, + staminaBar: 100, +}; const defaultIndicators = { - tempomat: true, - door: false, - light: false, - engine: false, - leftIndex: false, - rightIndex: false, -} + tempomat: true, + door: false, + light: false, + engine: false, + leftIndex: false, + rightIndex: false, +}; const defaultMenuButtons = [ - { - name: "Status", - path: "status" - }, - { - name: "Speedo", - path: "speedo" - }, - { - name: "Settings", - path: "settings" - } -] + { + name: "Status", + path: "status", + }, + { + name: "Speedo", + path: "speedo", + }, + { + name: "Settings", + path: "settings", + }, +]; const progressDefaultCircles = [ + { + name: "healthBar", + progressLevel: 100, + color: "red", + icon: HealthIcon, + active: false, + }, + { + name: "armorBar", + progressLevel: 100, + color: "blue", + icon: ArmorIcon, + }, + { + name: "drinkBar", + progressLevel: 100, + color: "lightblue", + icon: DrinkIcon, + }, + { + name: "foodBar", + progressLevel: 100, + color: "yellow", + icon: FoodIcon, + }, + { + name: "oxygenBar", + progressLevel: 100, + color: "pink", + icon: OxygenIcon, + }, + { + name: "staminaBar", + progressLevel: 100, + color: "green", + icon: StaminaIcon, + }, +]; + +const speedoDefaultColors = [ + { + name: "segment-color", + color: "#eee", + }, + { + name: "segment-progress-color", + color: "green", + }, + { + name: "number-color", + color: "#eee", + }, + { + name: "danger-color", + color: "#ff113a", + }, + { + name: "danger-progress-color", + color: "pink", + }, + { + name: "number-danger-color", + color: "#da0b64", + }, + { + name: "speedo-progress-color", + color: "orange", + }, + { + name: "damage-progress-color", + color: "#1be70d", + }, + { + name: "engine-icon-color", + color: "#FEC32C", + }, + + { + name: "tempomat-icon-color", + color: "#FEC32C", + }, + { + name: "light-icon-color", + color: "#FEC32C", + }, + { + name: "door-icon-color", + color: "#FEC32C", + }, + { + name: "fuel-icon-color", + color: "white", + }, + { + name: "fuel-level-color", + color: "pink", + }, + { + name: "mileage-level-color", + color: "green", + }, + { + name: "unit-color", + color: "red", + }, + { + name: "current-speed-color", + color: "pink", + }, + { + name: "left-right-index-color", + color: "#00B065", + }, + { + name: "damage-icon-color", + color: "white", + }, + { + name: "speedo-background-color", + color: "rgba(0,0,0,.5)", + }, + { + name: "speedo-outer-circle-color", + color: "#242222", + }, + { + name: "speedo-nooble-color", + color: "#48a3cb", + }, + { + name: "speedo-nooble-container", + color: "#1f2937", + }, +]; + +const allColors = { + Status: [ { - name: "healthBar", - progressLevel: 100, - color: "red", - icon: HealthIcon, - active: false - }, - { - name: "armorBar", - progressLevel: 100, - color: "blue", - icon: ArmorIcon + name: "healthBar", + color: "red", }, { - name: "drinkBar", - progressLevel: 100, - color: "lightblue", - icon: DrinkIcon + name: "armorBar", + color: "blue", }, { - name: "foodBar", - progressLevel: 100, - color: "yellow", - icon: FoodIcon + name: "drinkBar", + color: "lightblue", }, { - name: "oxygenBar", - progressLevel: 100, - color: "pink", - icon: OxygenIcon + name: "foodBar", + color: "yellow", }, { - name: "staminaBar", - progressLevel: 100, - color: "green", - icon: StaminaIcon - } -] - -const speedoDefaultColors = [ - { - name: "segment-color", - color: "#eee" + name: "oxygenBar", + color: "green", }, { - name:"segment-progress-color", - color:"green" + name: "staminaBar", + color: "purple", }, + ], + Speedo: [ { - name: "number-color", - color: "#eee" + name: "segment-color", + color: "#eee", }, { - name: "danger-color", - color: "#ff113a" + name: "number-color", + color: "#eee", }, { - name:"danger-progress-color", - color:"pink" + name: "danger-color", + color: "#ff113a", }, { - name: "number-danger-color", - color: "#da0b64" + name: "number-danger-color", + color: "#da0b64", }, { - name: "speedo-progress-color", - color: "orange" + name: "speedo-progress-color", + color: "orange", }, { - name: "damage-progress-color", - color: "#1be70d" + name: "damage-progress-color", + color: "#1be70d", }, { - name: "engine-icon-color", - color: "#FEC32C" + name: "engine-icon-color", + color: "#FEC32C", }, { - name: "tempomat-icon-color", - color: "#FEC32C" - }, - { - name: "light-icon-color", - color: "#FEC32C" - }, - { - name: "door-icon-color", - color: "#FEC32C" + name: "tempomat-icon-color", + color: "#FEC32C", }, { - name: "fuel-icon-color", - color: "white" + name: "light-icon-color", + color: "#FEC32C", }, { - name: "fuel-level-color", - color: "pink" + name: "door-icon-color", + color: "#FEC32C", }, { - name: "mileage-level-color", - color: "green" + name: "fuel-icon-color", + color: "white", }, { - name: "unit-color", - color: "red" + name: "fuel-level-color", + color: "pink", }, { - name: "current-speed-color", - color: "pink" + name: "mileage-level-color", + color: "green", }, { - name: "left-right-index-color", - color: "#00B065" + name: "unit-color", + color: "red", }, { - name: "damage-icon-color", - color: "white" + name: "current-speed-color", + color: "pink", }, { - name: "speedo-background-color", - color: "rgba(0,0,0,.5)" + name: "left-right-index-color", + color: "#00B065", }, { - name: "speedo-outer-circle-color", - color: "#242222" + name: "damage-icon-color", + color: "white", }, { - name: "speedo-nooble-color", - color: "#48a3cb" + name: "speedo-background-color", + color: "rgba(0,0,0,.5)", }, { - name: "speedo-nooble-container", - color: "#1f2937" + name: "speedo-outer-circle-color", + color: "#242222", }, -] - -const allColors = { - Status:[ - { - name: "healthBar", - color: "red" - }, - { - name: "armorBar", - color: "blue" - }, - { - name: "drinkBar", - color: "lightblue" - }, - { - name: "foodBar", - color: "yellow" - }, - { - name: "oxygenBar", - color: "green" - }, - { - name: "staminaBar", - color: "purple" - }, - ], - Speedo: [ - { - name: "segment-color", - color: "#eee" - }, - { - name: "number-color", - color: "#eee" - }, - { - name: "danger-color", - color: "#ff113a" - }, - { - name: "number-danger-color", - color: "#da0b64" - }, - { - name: "speedo-progress-color", - color: "orange" - }, - { - name: "damage-progress-color", - color: "#1be70d" - }, - { - name: "engine-icon-color", - color: "#FEC32C" - }, - - { - name: "tempomat-icon-color", - color: "#FEC32C" - }, - { - name: "light-icon-color", - color: "#FEC32C" - }, - { - name: "door-icon-color", - color: "#FEC32C" - }, - { - name: "fuel-icon-color", - color: "white" - }, - { - name: "fuel-level-color", - color: "pink" - }, - { - name: "mileage-level-color", - color: "green" - }, - { - name: "unit-color", - color: "red" - }, - { - name: "current-speed-color", - color: "pink" - }, - { - name: "left-right-index-color", - color: "#00B065" - }, - { - name: "damage-icon-color", - color: "white" - }, - { - name: "speedo-background-color", - color: "rgba(0,0,0,.5)" - }, - { - name: "speedo-outer-circle-color", - color: "#242222" - } - ] -} + ], +}; -export{disableDefaultConfig,defaultConfig,progressColors,vehDefaultData,hudDefaultData,progressLevels,defaultIndicators,defaultMenuButtons,progressDefaultCircles,allColors,speedoDefaultColors} \ No newline at end of file +export { + disableDefaultConfig, + defaultConfig, + progressColors, + vehDefaultData, + hudDefaultData, + progressLevels, + defaultIndicators, + defaultMenuButtons, + progressDefaultCircles, + allColors, + speedoDefaultColors, +}; diff --git a/web/index.html b/web/index.html index 59e149c..6dcffda 100644 --- a/web/index.html +++ b/web/index.html @@ -1,4 +1,4 @@ - +
diff --git a/web/postcss.config.js b/web/postcss.config.js index 33ad091..12a703d 100644 --- a/web/postcss.config.js +++ b/web/postcss.config.js @@ -3,4 +3,4 @@ module.exports = { tailwindcss: {}, autoprefixer: {}, }, -} +}; diff --git a/web/src/Utils/Nui.js b/web/src/Utils/Nui.js index 1875ee8..8d2bce1 100644 --- a/web/src/Utils/Nui.js +++ b/web/src/Utils/Nui.js @@ -1,25 +1,25 @@ export const Nui = { - async send(event, data = {}) { - try { - const resp = await fetch(`https://${GetParentResourceName()}/${event}`, { - method: 'post', - headers: { - 'Content-Type': 'application/json; charset=UTF-8', - }, - body: JSON.stringify(data), - }); + async send(event, data = {}) { + try { + const resp = await fetch(`https://${GetParentResourceName()}/${event}`, { + method: "post", + headers: { + "Content-Type": "application/json; charset=UTF-8", + }, + body: JSON.stringify(data), + }); - return await resp.json(); - } catch (error) { - throw Error(`Failed to fetch NUI callback ${event}! (${error})`); - } - }, + return await resp.json(); + } catch (error) { + throw Error(`Failed to fetch NUI callback ${event}! (${error})`); + } + }, - emulate(type, data = null) { - window.dispatchEvent( - new MessageEvent("message", { - data: { type, data }, - }) - ); - }, -}; \ No newline at end of file + emulate(type, data = null) { + window.dispatchEvent( + new MessageEvent("message", { + data: { type, data }, + }), + ); + }, +}; diff --git a/web/src/Utils/Translate.js b/web/src/Utils/Translate.js index 0d13569..1e6fccb 100644 --- a/web/src/Utils/Translate.js +++ b/web/src/Utils/Translate.js @@ -1,4 +1,4 @@ -import TranslateData from '../assets/translate.json'; +import TranslateData from "../assets/translate.json"; /** * Converts the key into dynamic language text @@ -7,20 +7,28 @@ import TranslateData from '../assets/translate.json'; * @param defaultKey (optional) return default string if doesn't exist key * @return {*} */ -let lang = "en" -export const translate = (translateKey,translateObjectName = "General",defaultKey = null) =>{ - if(!TranslateData[lang][translateObjectName][translateKey.toLowerCase()]){ - console.warn(`Doesn't exist translate key: ${translateKey.toLowerCase()} in ${translateObjectName} translate object`) - return defaultKey ? defaultKey : translateKey - } - return TranslateData[lang][translateObjectName][translateKey.toLowerCase()] -} +let lang = "en"; +export const translate = ( + translateKey, + translateObjectName = "General", + defaultKey = null, +) => { + if (!TranslateData[lang][translateObjectName][translateKey.toLowerCase()]) { + console.warn( + `Doesn't exist translate key: ${translateKey.toLowerCase()} in ${translateObjectName} translate object`, + ); + return defaultKey ? defaultKey : translateKey; + } + return TranslateData[lang][translateObjectName][translateKey.toLowerCase()]; +}; -export function setLang(currentLang){ - let newLang = currentLang.length > 0 ? currentLang : "en" - if(!TranslateData[currentLang]){ - console.warn(`There is no such language type! Current language type: ${currentLang} If you want add other lang you can do here: web/src/assets/translate.json !!IMPORTANT this file only see with the unbuilt version.`) - newLang = "en" - } - lang = newLang -} \ No newline at end of file +export function setLang(currentLang) { + let newLang = currentLang.length > 0 ? currentLang : "en"; + if (!TranslateData[currentLang]) { + console.warn( + `There is no such language type! Current language type: ${currentLang} If you want add other lang you can do here: web/src/assets/translate.json !!IMPORTANT this file only see with the unbuilt version.`, + ); + newLang = "en"; + } + lang = newLang; +} diff --git a/web/src/assets/Components/InfoHud.css b/web/src/assets/Components/InfoHud.css index 4ab8183..24e7dba 100644 --- a/web/src/assets/Components/InfoHud.css +++ b/web/src/assets/Components/InfoHud.css @@ -1,11 +1,11 @@ -.moneyTextColor{ - color: var(--money-text-color) +.moneyTextColor { + color: var(--money-text-color); } -.bankTextColor{ - color: var(--bank-text-color) +.bankTextColor { + color: var(--bank-text-color); } -.jobTextColor{ - color: var(--job-text-color) -} \ No newline at end of file +.jobTextColor { + color: var(--job-text-color); +} diff --git a/web/src/assets/Components/Speedo.css b/web/src/assets/Components/Speedo.css index 4c76fe1..544ea1c 100644 --- a/web/src/assets/Components/Speedo.css +++ b/web/src/assets/Components/Speedo.css @@ -1,239 +1,231 @@ - -:root{ - --segment-color: #eee; - --segment-progress-color:green; - --number-color: #eee; - --danger-color: #ff113a; - --danger-progress-color:pink; - --number-danger-color: #da0b64; - --speedo-progress-color: orange; - --damage-progress-color: #1be70d; - --speedo-all-texts: #ff113a; - --engine-icon-color: #FEC32C; - --tempomat-icon-color: #FEC32C; - --light-icon-color: #FEC32C; - --door-icon-color: #FEC32C; - --fuel-icon-color: white; - --fuel-level-color: pink; - --mileage-level-color: green; - --unit-color: red; - --current-speed-color: pink; - --left-right-index-color: #00B065; - --damage-icon-color: white; - --speedo-background-color: rgba(0,0,0,.5); - --speedo-outer-circle-color: #242222; - --speedo-nooble-color: #48a3cb; - --speedo-nooble-container: #1f2937; - --speedo-scale-size: 0.9; +:root { + --segment-color: #eee; + --segment-progress-color: green; + --number-color: #eee; + --danger-color: #ff113a; + --danger-progress-color: pink; + --number-danger-color: #da0b64; + --speedo-progress-color: orange; + --damage-progress-color: #1be70d; + --speedo-all-texts: #ff113a; + --engine-icon-color: #fec32c; + --tempomat-icon-color: #fec32c; + --light-icon-color: #fec32c; + --door-icon-color: #fec32c; + --fuel-icon-color: white; + --fuel-level-color: pink; + --mileage-level-color: green; + --unit-color: red; + --current-speed-color: pink; + --left-right-index-color: #00b065; + --damage-icon-color: white; + --speedo-background-color: rgba(0, 0, 0, 0.5); + --speedo-outer-circle-color: #242222; + --speedo-nooble-color: #48a3cb; + --speedo-nooble-container: #1f2937; + --speedo-scale-size: 0.9; } /* SVG DONT'T TOUCH PLEASE THANK YOU */ .circleBackground { - stroke: #eee; - opacity: 0.3; - stroke-width: 6; - fill: transparent; + stroke: #eee; + opacity: 0.3; + stroke-width: 6; + fill: transparent; } .circleProgress { - stroke: var(--speedo-progress-color); - stroke-width: 6; - stroke-dashoffset: 10; - fill: transparent; + stroke: var(--speedo-progress-color); + stroke-width: 6; + stroke-dashoffset: 10; + fill: transparent; } /*SMALL CIRCLE SVG LEFT SIDE*/ .backgroundPartCircle { - stroke: #eee; - opacity: 0.3; - stroke-width: 4; - fill: transparent; + stroke: #eee; + opacity: 0.3; + stroke-width: 4; + fill: transparent; } .progressPartCircle { - stroke: var(--damage-progress-color); - stroke-width: 4; - /*stroke-dasharray: 0 160;*/ - fill: transparent; + stroke: var(--damage-progress-color); + stroke-width: 4; + /*stroke-dasharray: 0 160;*/ + fill: transparent; } .dashesPartCircle { - stroke: white; - stroke-width: 4; - stroke-dasharray: 2 34; - stroke-dashoffset: -17; - fill: none; + stroke: white; + stroke-width: 4; + stroke-dasharray: 2 34; + stroke-dashoffset: -17; + fill: none; } .nob { - width: 15px; - height: 4px; - background: var(--segment-color); + width: 15px; + height: 4px; + background: var(--segment-color); } .midNob { - width: 5px; - border-radius: 50%; - height: 5px; + width: 5px; + border-radius: 50%; + height: 5px; } .numb { - color: var(--number-color); - text-align: left; - overflow: hidden; - opacity: 0.5; - font-size: 17px; - font-weight: bold; + color: var(--number-color); + text-align: left; + overflow: hidden; + opacity: 0.5; + font-size: 17px; + font-weight: bold; } .numb, .nob { - position: absolute; - transition: 0.5s all ease-in; + position: absolute; + transition: 0.5s all ease-in; } .nob.bright { - background: var(--segment-progress-color) !important; + background: var(--segment-progress-color) !important; } -.nob.brightDanger{ - background: var(--danger-progress-color) !important; +.nob.brightDanger { + background: var(--danger-progress-color) !important; } .numb.bright { - background: var(--segment-progress-color); + background: var(--segment-progress-color); } .nob.danger { - background: var(--danger-color); + background: var(--danger-color); } .numb.danger { - color: var(--number-danger-color); + color: var(--number-danger-color); } - .slideOut { - transform: translateY(200%) scale(var(--speedo-scale-size)) !important; + transform: translateY(200%) scale(var(--speedo-scale-size)) !important; } .main-container { - transform-origin: bottom right; - transform: scale(var(--speedo-scale-size)); - transition: 0.5s all ease-in; - height: 300px; + transform-origin: bottom right; + transform: scale(var(--speedo-scale-size)); + transition: 0.5s all ease-in; + height: 300px; } .template-main-container { - /*top: 110px;*/ - /*left: 74%;*/ - /*position: absolute;*/ - transform: scale(0.8); - height: 300px; - transition: 0.5s all ease-in; + /*top: 110px;*/ + /*left: 74%;*/ + /*position: absolute;*/ + transform: scale(0.8); + height: 300px; + transition: 0.5s all ease-in; } .main-container2 { - position: relative; - top: 49.95%; - left: 49.05%; - transform: translate(-50%,-50%); - background: var(--speedo-background-color); - width: 100%; - height: 100%; - border-radius: 50%; - box-shadow: inset 0 0 14px 3px #000; - border: 5px solid var(--speedo-outer-circle-color); + position: relative; + top: 49.95%; + left: 49.05%; + transform: translate(-50%, -50%); + background: var(--speedo-background-color); + width: 100%; + height: 100%; + border-radius: 50%; + box-shadow: inset 0 0 14px 3px #000; + border: 5px solid var(--speedo-outer-circle-color); } -.textColor{ - color: var(--speedo-all-texts); +.textColor { + color: var(--speedo-all-texts); } -.blinkerOn{ - fill-opacity: 1; - fill: var(--left-right-index-color); +.blinkerOn { + fill-opacity: 1; + fill: var(--left-right-index-color); } -.blink{ - transition: all 0.1s !important; +.blink { + transition: all 0.1s !important; } - /*SPEEDO COLORS*/ -#fuelIcon{ - fill: var(--fuel-icon-color); +#fuelIcon { + fill: var(--fuel-icon-color); } -.indexColor{ - fill: var(--left-right-index-color); +.indexColor { + fill: var(--left-right-index-color); } -.damageStatusIcon{ - fill: var(--damage-icon-color); +.damageStatusIcon { + fill: var(--damage-icon-color); } -.tempomatIcon{ - fill: var(--tempomat-icon-color); +.tempomatIcon { + fill: var(--tempomat-icon-color); } -.doorIcon{ - fill: var(--door-icon-color) +.doorIcon { + fill: var(--door-icon-color); } -.lightIcon{ - stroke: var(--light-icon-color); +.lightIcon { + stroke: var(--light-icon-color); } -.engineIcon{ - fill:var(--engine-icon-color); +.engineIcon { + fill: var(--engine-icon-color); } - -.mileageTextColor{ - color: var(--mileage-level-color); +.mileageTextColor { + color: var(--mileage-level-color); } -.unitTextColor{ - color: var(--unit-color); +.unitTextColor { + color: var(--unit-color); } -.fuelTextColor{ - color: var(--fuel-level-color); +.fuelTextColor { + color: var(--fuel-level-color); } -.currentSpeedTextColor{ - color: var(--current-speed-color); +.currentSpeedTextColor { + color: var(--current-speed-color); } /*Speedo Noble*/ -.speedoNoobleContainer{ - background: var(--speedo-nooble-container); +.speedoNoobleContainer { + background: var(--speedo-nooble-container); } .speedNobe { - position: absolute; - width: 100%; - transition: all 0.3s; - height: 5px; - left: 50%; - top: 48%; - transform: translate(-50%, -50%); - transform-origin: 50% 50%; - /* transform: rotate(-48deg); */ + position: absolute; + width: 100%; + transition: all 0.3s; + height: 5px; + left: 50%; + top: 48%; + transform: translate(-50%, -50%); + transform-origin: 50% 50%; + /* transform: rotate(-48deg); */ } .speedNobe div { - background: var(--speedo-nooble-color); - position: absolute; - height: 100%; - top: 0px; - width: 165px; - left: 28px; - border-radius: 80% 6px 6px 80%; + background: var(--speedo-nooble-color); + position: absolute; + height: 100%; + top: 0px; + width: 165px; + left: 28px; + border-radius: 80% 6px 6px 80%; } - - - - diff --git a/web/src/assets/Contexts/index.js b/web/src/assets/Contexts/index.js index e2ce9b1..7fa03d8 100644 --- a/web/src/assets/Contexts/index.js +++ b/web/src/assets/Contexts/index.js @@ -1,2 +1,2 @@ -export { default as HudStorageProvider } from "./HudStorage" -export { default as SettingsStorageProvider } from "./SettingsStorage" +export { default as HudStorageProvider } from "./HudStorage"; +export { default as SettingsStorageProvider } from "./SettingsStorage"; diff --git a/web/src/index.css b/web/src/index.css index eef32b9..9716013 100644 --- a/web/src/index.css +++ b/web/src/index.css @@ -1,20 +1,19 @@ -@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&display=swap'); +@import url("https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&display=swap"); @font-face { font-family: "Gilroy"; - src: url('./assets/font/Gilroy-ExtraBold.otf'); + src: url("./assets/font/Gilroy-ExtraBold.otf"); } @tailwind base; @tailwind components; @tailwind utilities; - @layer components { .flex-col-status { @apply flex flex-col absolute bottom-10 left-7 transition-opacity; } - .center-statuses{ + .center-statuses { @apply flex flex-col absolute bottom-[50%] translate-y-[50%] left-[1%] transition-opacity; } @@ -23,13 +22,12 @@ } .template-speedo { - @apply absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 + @apply absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2; } .speedo { - @apply absolute bottom-4 right-8 + @apply absolute bottom-4 right-8; } - } * { @@ -43,11 +41,11 @@ body { display: none; align-items: center; justify-content: center; - background:transparent; + background: transparent; overflow: hidden; - font-family: 'Rajdhani', sans-serif; + font-family: "Rajdhani", sans-serif; user-select: none; - color:white; + color: white; } .form-check-input:checked[type="checkbox"] { @@ -58,9 +56,8 @@ body { background-image: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%22-4 -4 8 8%22%3E%3Ccircle r=%222%22 fill=%22%23fff%22/%3E%3C/svg%3E"); } -input[type="checkbox"] -{ - vertical-align:middle; +input[type="checkbox"] { + vertical-align: middle; } /* width */ @@ -71,7 +68,7 @@ input[type="checkbox"] /* Track */ ::-webkit-scrollbar-track { - background: #1E2122; + background: #1e2122; } /* Handle */ @@ -84,16 +81,16 @@ input[type="checkbox"] background: #555; } -.bodyPicker{ +.bodyPicker { position: absolute; top: 100px; left: 100px; } -.slideDown{ +.slideDown { transform: translateY(0px); } -.slideUp{ +.slideUp { transform: translateY(-100%); } diff --git a/web/tailwind.config.js b/web/tailwind.config.js index 62bf77f..50d7d83 100644 --- a/web/tailwind.config.js +++ b/web/tailwind.config.js @@ -1,22 +1,21 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - content: [ - "./src/**/*.{js,jsx,ts,tsx}", - ], + content: ["./src/**/*.{js,jsx,ts,tsx}"], theme: { extend: { backgroundImage: { - 'ammo-container-background': "linear-gradient(270deg, rgba(255, 255, 255, 0.15) -0.79%, rgba(255, 255, 255, 0) 107.59%)" + "ammo-container-background": + "linear-gradient(270deg, rgba(255, 255, 255, 0.15) -0.79%, rgba(255, 255, 255, 0) 107.59%)", }, keyframes: { blinker: { - '50%': { opacity: '0' }, - } + "50%": { opacity: "0" }, + }, }, animation: { - blinker: 'blinker 1s step-start infinite' - } + blinker: "blinker 1s step-start infinite", + }, }, }, plugins: [], -} \ No newline at end of file +}; diff --git a/web/vite.config.js b/web/vite.config.js index cacaa18..077f584 100644 --- a/web/vite.config.js +++ b/web/vite.config.js @@ -1,13 +1,13 @@ -import { defineConfig } from 'vite'; -import solidPlugin from 'vite-plugin-solid'; +import { defineConfig } from "vite"; +import solidPlugin from "vite-plugin-solid"; export default defineConfig({ plugins: [solidPlugin()], - base: './', + base: "./", server: { port: 3000, }, build: { - target: 'esnext', + target: "esnext", }, });