Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- util.AddNetworkString( "StartFade" )
- CreateConVar( "glxy_blackouttime", 10, FCVAR_REPLICATED, "Set to any desired amount of seconds untill full blackout. (Going too low causes stuttery animations)" )
- -- Server pings client when player has died
- hook.Add( "PlayerDeath", "GalaxyPlayerDied", function( ply )
- net.Start( "StartFade" )
- net.WriteInt( GetConVar( "glxy_blackouttime"):GetInt(), 32 )
- net.Send( ply )
- end )
- -- Server pings client when player has spawned
- hook.Add( "PlayerSpawn", "GalaxyPlayerSpawned", function( ply )
- net.Start( "StartFade" )
- net.WriteInt( 0, 32 )
- net.Send( ply )
- end )
- end
- if CLIENT then
- -- Remove red stuff
- hook.Add( "HUDShouldDraw", "RemoveRedScreenOnDeath", function( name )
- if ( name == "CHudDamageIndicator" ) then
- return false
- end
- end )
- -- Calculate the firstperson view attached to ragdoll
- local function CalcView( ply, origin, angles, fov )
- local ragdoll = ply:GetRagdollEntity()
- if( !ragdoll || ragdoll == NULL || !ragdoll:IsValid() ) then
- return
- end
- local eyes = ragdoll:GetAttachment( ragdoll:LookupAttachment( "eyes" ) )
- local view = {
- origin = eyes.Pos,
- angles = eyes.Ang,
- fov = 90,
- }
- return view
- end
- hook.Add( "CalcView", "DeathView", CalcView )
- -- Receive player dead/spawn status
- net.Receive( "StartFade", function()
- local BlackoutTime = net.ReadInt( 32 )
- local RemainingTime = 0
- local TimeInterval = 0
- if BlackoutTime > 0 then
- TimeInterval = ( 255 / BlackoutTime ) * 0.1
- timer.Create( "BlackoutTimer", 0.1, BlackoutTime * 10, function()
- RemainingTime = RemainingTime + TimeInterval
- --print( RemainingTime ) ONLY ENABLE FOR DEBUG!
- end )
- end
- hook.Add( "HUDPaint", "PaintBlack", function()
- if BlackoutTime > 0 then
- draw.RoundedBox( 0, 0, 0, ScrW(), ScrH(), Color( 0, 0, 0, RemainingTime ) )
- end
- end )
- end )
- endif SERVER then
- util.AddNetworkString( "StartFade" )
- CreateConVar( "glxy_blackouttime", 10, FCVAR_REPLICATED, "Set to any desired amount of seconds untill full blackout. (Going too low causes stuttery animations)" )
- -- Server pings client when player has died
- hook.Add( "PlayerDeath", "GalaxyPlayerDied", function( ply )
- net.Start( "StartFade" )
- net.WriteInt( GetConVar( "glxy_blackouttime"):GetInt(), 32 )
- net.Send( ply )
- end )
- -- Server pings client when player has spawned
- hook.Add( "PlayerSpawn", "GalaxyPlayerSpawned", function( ply )
- net.Start( "StartFade" )
- net.WriteInt( 0, 32 )
- net.Send( ply )
- end )
- end
- if CLIENT then
- -- Remove red stuff
- hook.Add( "HUDShouldDraw", "RemoveRedScreenOnDeath", function( name )
- if ( name == "CHudDamageIndicator" ) then
- return false
- end
- end )
- -- Calculate the firstperson view attached to ragdoll
- local function CalcView( ply, origin, angles, fov )
- local ragdoll = ply:GetRagdollEntity()
- if( !ragdoll || ragdoll == NULL || !ragdoll:IsValid() ) then
- return
- end
- local eyes = ragdoll:GetAttachment( ragdoll:LookupAttachment( "eyes" ) )
- local view = {
- origin = eyes.Pos,
- angles = eyes.Ang,
- fov = 90,
- }
- return view
- end
- hook.Add( "CalcView", "DeathView", CalcView )
- -- Receive player dead/spawn status
- net.Receive( "StartFade", function()
- local BlackoutTime = net.ReadInt( 32 )
- local RemainingTime = 0
- local TimeInterval = 0
- if BlackoutTime > 0 then
- TimeInterval = ( 255 / BlackoutTime ) * 0.1
- timer.Create( "BlackoutTimer", 0.1, BlackoutTime * 10, function()
- RemainingTime = RemainingTime + TimeInterval
- --print( RemainingTime ) ONLY ENABLE FOR DEBUG!
- end )
- end
- hook.Add( "HUDPaint", "PaintBlack", function()
- if BlackoutTime > 0 then
- draw.RoundedBox( 0, 0, 0, ScrW(), ScrH(), Color( 0, 0, 0, RemainingTime ) )
- end
- end )
- end )
- end
Advertisement
Add Comment
Please, Sign In to add comment