Guest User

Untitled

a guest
Jan 4th, 2023
799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | None | 0 0
  1. -- sh_fog.lua
  2. globalFogDed = 2700
  3.  
  4. if CLIENT then
  5.     RunConsoleCommand("r_3dsky", 0)
  6.  
  7.     hook.Add( "SetupWorldFog", "FoxController", function()
  8.         if globalFogDed then
  9.             render.FogMode( 1 )
  10.             render.FogStart( globalFogDed - 350 )
  11.             render.FogEnd( globalFogDed - 150 )
  12.             render.FogMaxDensity( 1 )
  13.  
  14.             local col = Vector(0.8,0.8,0.8)
  15.             render.FogColor( col.x * 255, col.y * 255, col.z * 255 )
  16.  
  17.             return true
  18.         end
  19.     end )
  20.  
  21.     hook.Add( "SetupSkyboxFog", "FoxControllerSky", function()
  22.         if globalFogDed then
  23.             render.FogMode(MATERIAL_FOG_LINEAR)
  24.             render.FogStart( (globalFogDed-600)/16-(200/16) )
  25.             render.FogEnd( globalFogDed/16-(200/16)  )
  26.             render.FogMaxDensity( 1 )
  27.  
  28.             local col = Vector(0.8,0.8,0.8)
  29.             render.FogColor( col.x * 255, col.y * 255, col.z * 255 )
  30.  
  31.             return true
  32.         end
  33.     end )
  34.  
  35.     hook.Add("NetworkEntityCreated", "hideshit", function(ent) -- скрывает энтити в тумане
  36.         timer.Simple(1, function()
  37.             if !IsValid(ent) then return end
  38.             ent.RenderOverride = function()
  39.                 if (LocalPlayer():GetPos():Distance(ent:GetPos()) < globalFogDed) then
  40.                     ent:DrawModel()
  41.                 end
  42.             end
  43.         end)
  44.     end)
  45. end
  46.  
  47. if SERVER then
  48.     entFog = false
  49.     function DedrussFPSfix()
  50.         for k, v in ipairs( ents.GetAll( ) ) do
  51.             if v:GetClass( ) == "env_fog_controller" then
  52.                 v:SetKeyValue("fogend", globalFogDed - 150)
  53.                 v:SetKeyValue("fogstart", globalFogDed  - 150)
  54.                 v:SetKeyValue("farz",globalFogDed)
  55.                 entFog = v
  56.                 break
  57.             end
  58.         end
  59.  
  60.         if not entFog then
  61.             v = ents.Create( "env_fog_controller" )
  62.             v:SetKeyValue("fogend",  globalFogDed  - 150 )
  63.             v:SetKeyValue("fogstart", globalFogDed - 150)
  64.             v:SetKeyValue("farz", globalFogDed)
  65.             v:Spawn( )
  66.             entFog = v
  67.         end
  68.     end
  69.     hook.Add( "Initialize", "dedrussfpsfix", DedrussFPSfix );
  70. end
Advertisement
Add Comment
Please, Sign In to add comment