diff --git a/[core]/es_extended/client/main.lua b/[core]/es_extended/client/main.lua index a10df217..ad8185b1 100644 --- a/[core]/es_extended/client/main.lua +++ b/[core]/es_extended/client/main.lua @@ -57,66 +57,63 @@ AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin) NetworkSetFriendlyFireOption(true) end - CreateThread(function() - local SetPlayerHealthRechargeMultiplier = SetPlayerHealthRechargeMultiplier - local BlockWeaponWheelThisFrame = BlockWeaponWheelThisFrame - local DisableControlAction = DisableControlAction - local IsPedArmed = IsPedArmed - local SetPlayerLockonRangeOverride = SetPlayerLockonRangeOverride - local DisablePlayerVehicleRewards = DisablePlayerVehicleRewards - local RemoveAllPickupsOfType = RemoveAllPickupsOfType - local HideHudComponentThisFrame = HideHudComponentThisFrame - local PlayerId = PlayerId() - local DisabledComps = {} - for i=1, #(Config.RemoveHudCommonents) do - if Config.RemoveHudCommonents[i] then - DisabledComps[#DisabledComps + 1] = i - end + local playerId = PlayerId() + + -- RemoveHudCommonents + for i=1, #(Config.RemoveHudCommonents) do + if Config.RemoveHudCommonents[i] then + SetHudComponentPosition(i, 999999.0, 999999.0) end + end - while true do - local Sleep = true - - if Config.DisableHealthRegeneration then - Sleep = false - SetPlayerHealthRechargeMultiplier(PlayerId, 0.0) - end - - if Config.DisableWeaponWheel then - Sleep = false - BlockWeaponWheelThisFrame() - DisableControlAction(0, 37,true) - end - - if Config.DisableAimAssist then - Sleep = false - if IsPedArmed(ESX.PlayerData.ped, 4) then - SetPlayerLockonRangeOverride(PlayerId, 2.0) - end - end - - if Config.DisableVehicleRewards then - Sleep = false - DisablePlayerVehicleRewards(PlayerId) - end - - if Config.DisableNPCDrops then - Sleep = false - RemoveAllPickupsOfType(0xDF711959) - RemoveAllPickupsOfType(0xF9AFB48F) - RemoveAllPickupsOfType(0xA9355DCD) - end - - if #DisabledComps > 0 then - Sleep = false - for i=1, #(DisabledComps) do - HideHudComponentThisFrame(DisabledComps[i]) - end - end - - Wait(Sleep and 1500 or 0) + -- DisableNPCDrops + if Config.DisableNPCDrops then + local weaponPickups = {`PICKUP_WEAPON_CARBINERIFLE`, `PICKUP_WEAPON_PISTOL`, `PICKUP_WEAPON_PUMPSHOTGUN`} + for i = 1, #weaponPickups do + ToggleUsePickupsForPlayer(playerId, weaponPickups[i], false) end - end) + end + + -- DisableVehicleRewards + if Config.DisableVehicleRewards then + AddEventHandler('gameEventTriggered', function(name, args) + if name == "CEventNetworkPlayerEnteredVehicle" then + CreateThread(function() + while true do + DisablePlayerVehicleRewards(playerId) + if not GetVehiclePedIsIn(ESX.PlayerData.ped, false) then + break + end + + Wait(0) + end + end) + end + end) + end + + if Config.DisableHealthRegeneration or Config.DisableWeaponWheel or Config.DisableAimAssist then + CreateThread(function() + while true do + if Config.DisableHealthRegeneration then + SetPlayerHealthRechargeMultiplier(playerId, 0.0) + end + + if Config.DisableWeaponWheel then + BlockWeaponWheelThisFrame() + DisableControlAction(0, 37, true) + end + + if Config.DisableAimAssist then + if IsPedArmed(ESX.PlayerData.ped, 4) then + SetPlayerLockonRangeOverride(playerId, 2.0) + end + end + + Wait(0) + end + end) + end if Config.EnableHud then for i=1, #(ESX.PlayerData.accounts) do