Anthr4x292

MindBlast Server Client Code: Cute admin notifier

Feb 11th, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. local X, Y = 30, 200
  2. local ShowLastMessage = 0
  3.  
  4. local RecentMessages = {}
  5.  
  6. hook.Add( "HUDPaint", "AdminNotify", function()
  7.     for k, v in pairs( RecentMessages ) do
  8.         if not v.Sent or v.Sent ~= 1 then
  9.             if ShowLastMessage and ShowLastMessage + .5 > CurTime() then return end
  10.             ShowLastMessage = CurTime()
  11.  
  12.             v.Sent = 1
  13.             v.dietime = CurTime() + 10
  14.         end
  15.  
  16.         if CurTime() >= v.dietime then
  17.             table.remove( RecentMessages, k )
  18.         else
  19.             local remaining = math.ceil( v.dietime - CurTime() )
  20.             local fade = math.Clamp( ( remaining * 255 ) / 2, 0, 255 )
  21.  
  22.             surface.SetFont( "Trebuchet18" )
  23.  
  24.             surface.SetTextColor( v.colour.r, v.colour.g, v.colour.b, fade )
  25.             surface.SetTextPos( X, Y * k / 15 )
  26.             surface.DrawText( v.text )
  27.         end
  28.     end
  29. end )
  30.  
  31. usermessage.Hook( "AdminNotify", function( UMsg )
  32.     local R = UMsg:ReadShort()
  33.     local G = UMsg:ReadShort()
  34.     local B = UMsg:ReadShort()
  35.  
  36.     local Text = UMsg:ReadString()
  37.     local Date = os.date( "*t" )
  38.  
  39.     local Message = {}
  40.     Message.colour = Color( R, G, B )
  41.     Message.text = Format( "[%02i:%02i:%02i] %s", Date.hour, Date.min, Date.sec, Text )
  42.  
  43.     table.insert( RecentMessages, Message )
  44.     Msg( Message.text .. "\n" )
  45. end )
Advertisement
Add Comment
Please, Sign In to add comment