--// ESX is needed only for the menu default ESX = nil Citizen.CreateThread(function() while ESX == nil do TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) Citizen.Wait(10) end end) local type = nil local _menu = { {label = 'Reset', value = 'reset'}, {label = 'Ultra Low', value = 'ulow'}, {label = 'Low', value = 'low'}, {label = 'Medium', value = 'medium'}, } RegisterCommand("fps", function() ESX.UI.Menu.CloseAll() ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'fps', { title = 'FPS Booster (By XenoS)', align = 'top-left', elements = _menu }, function(data, menu) local v = data.current.value --// Things need to be runned only one time if v == "reset" then RopeDrawShadowEnabled(true) CascadeShadowsSetAircraftMode(true) CascadeShadowsEnableEntityTracker(false) CascadeShadowsSetDynamicDepthMode(true) CascadeShadowsSetEntityTrackerScale(5.0) CascadeShadowsSetDynamicDepthValue(5.0) CascadeShadowsSetCascadeBoundsScale(5.0) SetFlashLightFadeDistance(10.0) SetLightsCutoffDistanceTweak(10.0) DistantCopCarSirens(true) SetArtificialLightsState(false) elseif v == "ulow" then RopeDrawShadowEnabled(false) CascadeShadowsClearShadowSampleType() CascadeShadowsSetAircraftMode(false) CascadeShadowsEnableEntityTracker(true) CascadeShadowsSetDynamicDepthMode(false) CascadeShadowsSetEntityTrackerScale(0.0) CascadeShadowsSetDynamicDepthValue(0.0) CascadeShadowsSetCascadeBoundsScale(0.0) SetFlashLightFadeDistance(0.0) SetLightsCutoffDistanceTweak(0.0) DistantCopCarSirens(false) elseif v == "low" then RopeDrawShadowEnabled(false) CascadeShadowsClearShadowSampleType() CascadeShadowsSetAircraftMode(false) CascadeShadowsEnableEntityTracker(true) CascadeShadowsSetDynamicDepthMode(false) CascadeShadowsSetEntityTrackerScale(0.0) CascadeShadowsSetDynamicDepthValue(0.0) CascadeShadowsSetCascadeBoundsScale(0.0) SetFlashLightFadeDistance(5.0) SetLightsCutoffDistanceTweak(5.0) DistantCopCarSirens(false) elseif v == "medium" then RopeDrawShadowEnabled(true) CascadeShadowsClearShadowSampleType() CascadeShadowsSetAircraftMode(false) CascadeShadowsEnableEntityTracker(true) CascadeShadowsSetDynamicDepthMode(false) CascadeShadowsSetEntityTrackerScale(5.0) CascadeShadowsSetDynamicDepthValue(3.0) CascadeShadowsSetCascadeBoundsScale(3.0) SetFlashLightFadeDistance(3.0) SetLightsCutoffDistanceTweak(3.0) DistantCopCarSirens(false) SetArtificialLightsState(false) end type = v end, function(data, menu) menu.close() end) end) -- // Distance rendering and entity handler (need a revision) Citizen.CreateThread(function() while true do if type == "ulow" then --// Find closest ped and set the alpha for ped in GetWorldPeds() do if not IsEntityOnScreen(ped) then SetEntityAlpha(ped, 0) SetEntityAsNoLongerNeeded(ped) else if GetEntityAlpha(ped) == 0 then SetEntityAlpha(ped, 255) elseif GetEntityAlpha(ped) ~= 210 then SetEntityAlpha(ped, 210) end end SetPedAoBlobRendering(ped, false) Citizen.Wait(1) end --// Find closest object and set the alpha for obj in GetWorldObjects() do if not IsEntityOnScreen(obj) then SetEntityAlpha(obj, 0) SetEntityAsNoLongerNeeded(obj) else if GetEntityAlpha(obj) == 0 then SetEntityAlpha(obj, 255) elseif GetEntityAlpha(obj) ~= 170 then SetEntityAlpha(obj, 170) end end Citizen.Wait(1) end DisableOcclusionThisFrame() SetDisableDecalRenderingThisFrame() RemoveParticleFxInRange(GetEntityCoords(PlayerPedId()), 10.0) OverrideLodscaleThisFrame(0.4) SetArtificialLightsState(true) elseif type == "low" then --// Find closest ped and set the alpha for ped in GetWorldPeds() do if not IsEntityOnScreen(ped) then SetEntityAlpha(ped, 0) SetEntityAsNoLongerNeeded(ped) else if GetEntityAlpha(ped) == 0 then SetEntityAlpha(ped, 255) elseif GetEntityAlpha(ped) ~= 210 then SetEntityAlpha(ped, 210) end end SetPedAoBlobRendering(ped, false) Citizen.Wait(1) end --// Find closest object and set the alpha for obj in GetWorldObjects() do if not IsEntityOnScreen(obj) then SetEntityAlpha(obj, 0) SetEntityAsNoLongerNeeded(obj) else if GetEntityAlpha(obj) == 0 then SetEntityAlpha(obj, 255) elseif GetEntityAlpha(ped) ~= 210 then SetEntityAlpha(ped, 210) end end Citizen.Wait(1) end SetDisableDecalRenderingThisFrame() RemoveParticleFxInRange(GetEntityCoords(PlayerPedId()), 10.0) OverrideLodscaleThisFrame(0.6) SetArtificialLightsState(true) elseif type == "medium" then --// Find closest ped and set the alpha for ped in GetWorldPeds() do if not IsEntityOnScreen(ped) then SetEntityAlpha(ped, 0) SetEntityAsNoLongerNeeded(ped) else if GetEntityAlpha(ped) == 0 then SetEntityAlpha(ped, 255) end end SetPedAoBlobRendering(ped, false) Citizen.Wait(1) end --// Find closest object and set the alpha for obj in GetWorldObjects() do if not IsEntityOnScreen(obj) then SetEntityAlpha(obj, 0) SetEntityAsNoLongerNeeded(obj) else if GetEntityAlpha(obj) == 0 then SetEntityAlpha(obj, 255) end end Citizen.Wait(1) end OverrideLodscaleThisFrame(0.8) else Citizen.Wait(500) end Citizen.Wait(8) end end) --// Clear broken thing, disable rain, disable wind and other tiny thing that dont require the frame tick Citizen.CreateThread(function() while true do if type == "ulow" or type == "low" then ClearAllBrokenGlass() ClearAllHelpMessages() LeaderboardsReadClearAll() ClearBrief() ClearGpsFlags() ClearPrints() ClearSmallPrints() ClearReplayStats() LeaderboardsClearCacheData() ClearFocus() ClearHdArea() ClearPedBloodDamage(PlayerPedId()) ClearPedWetness(PlayerPedId()) ClearPedEnvDirt(PlayerPedId()) ResetPedVisibleDamage(PlayerPedId()) ClearExtraTimecycleModifier() ClearTimecycleModifier() ClearOverrideWeather() ClearHdArea() DisableVehicleDistantlights(false) DisableScreenblurFade() SetRainLevel(0.0) SetWindSpeed(0.0) Citizen.Wait(300) elseif type == "medium" then ClearAllBrokenGlass() ClearAllHelpMessages() LeaderboardsReadClearAll() ClearBrief() ClearGpsFlags() ClearPrints() ClearSmallPrints() ClearReplayStats() LeaderboardsClearCacheData() ClearFocus() ClearHdArea() SetWindSpeed(0.0) Citizen.Wait(1000) else Citizen.Wait(1500) end end end) --// Entity Enumerator (https://gist.github.com/IllidanS4/9865ed17f60576425369fc1da70259b2#file-entityiter-lua) local entityEnumerator = { __gc = function(enum) if enum.destructor and enum.handle then enum.destructor(enum.handle) end enum.destructor = nil enum.handle = nil end } local function EnumerateEntities(initFunc, moveFunc, disposeFunc) return coroutine.wrap( function() local iter, id = initFunc() if not id or id == 0 then disposeFunc(iter) return end local enum = {handle = iter, destructor = disposeFunc} setmetatable(enum, entityEnumerator) local next = true repeat coroutine.yield(id) next, id = moveFunc(iter) until not next enum.destructor, enum.handle = nil, nil disposeFunc(iter) end ) end function GetWorldObjects() return EnumerateEntities(FindFirstObject, FindNextObject, EndFindObject) end function GetWorldPeds() return EnumerateEntities(FindFirstPed, FindNextPed, EndFindPed) end function GetWorldVehicles() return EnumerateEntities(FindFirstVehicle, FindNextVehicle, EndFindVehicle) end function GetWorldPickups() return EnumerateEntities(FindFirstPickup, FindNextPickup, EndFindPickup) end