Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local hit = false;
- local time = 0;
- local alpha = 0;
- local function FireGameEvent( event )
- if( event:GetName( ) == "player_hurt" ) then
- local victim = entities.GetByUserID( event:GetInt( "userid" ) );
- local attacker = entities.GetByUserID( event:GetInt( "attacker" ) );
- local me = entities.GetLocalPlayer( );
- if( victim ~= nil and attacker ~= nil ) then
- if( victim ~= me and attacker == me ) then
- hit = true;
- time = os.clock( );
- alpha = 255;
- end
- end
- end
- end
- local function Draw( )
- if( hit ) then
- local diff = os.clock( ) - time;
- if( diff > 0.5 ) then
- alpha = alpha - ( 255 / 0.5 * globals.FrameTime( ) );
- end
- if( alpha <= 0 ) then
- hit = false;
- time = 0;
- alpha = 0;
- return;
- end
- local width, height = draw.GetScreenSize( );
- local x = width / 2;
- local y = height / 2;
- local linesize = 10;
- draw.Color( 200, 200, 200, math.floor( alpha ) );
- draw.Line( x - linesize, y - linesize, x - 4, y - 4 );
- draw.Line( x + linesize, y - linesize, x + 4, y - 4 );
- draw.Line( x - linesize, y + linesize, x - 4, y + 4 );
- draw.Line( x + linesize, y + linesize, x + 4, y + 4 );
- end
- end
- client.AllowListener( "player_hurt" );
- callbacks.Unregister( "FireGameEvent", "hitmarkereventcb" );
- callbacks.Register( "FireGameEvent", "hitmarkereventcb", FireGameEvent );
- callbacks.Unregister( "Draw", "hitmarkereventdraw" );
- callbacks.Register( "Draw", "hitmarkereventdraw", Draw );
Advertisement
Add Comment
Please, Sign In to add comment