Advertisement
Mouamle

not notify

May 21st, 2016
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.98 KB | None | 0 0
  1. local sx, sy = guiGetScreenSize ()
  2.  
  3. function notify(x, y, w, h, Title, text, fadeTime)
  4.     local sx, sy = guiGetScreenSize()
  5.     local tempTextTable = {}
  6.     local tempText = ""
  7.     local isShowing = false;
  8.     local Alpha = 255;
  9.     local Alpha2 = 180;
  10.  
  11.     for token in string.gmatch(text, ".") do
  12.        table.insert(tempTextTable, token)
  13.     end
  14.     local int = 0;
  15.     for k,v in pairs(tempTextTable) do
  16.         if ( string.len(tempText) * 10 > w ) then
  17.             if ( int == 0 ) then
  18.                 tempText = tempText .. "\n"
  19.                 int = 1;
  20.             end
  21.         end
  22.         tempText = tempText .. v;
  23.     end
  24.  
  25.     local notify = {
  26.  
  27.         draw = function ()
  28.             dxDrawRectangle( x, y, w, h, tocolor(0, 0, 0, Alpha2) ) -- main
  29.             dxDrawText(Title, x + 10, y + 5, 0, 0, tocolor( 255, 0, 0, Alpha ), 2) -- title
  30.  
  31.             dxDrawLine( x, y+h, w +x, y+h, tocolor( 255, 255, 255, Alpha ), 2 ) -- outside
  32.             dxDrawLine( x, y, w +x, y, tocolor( 255, 255, 255, Alpha ), 2 ) -- outside
  33.             dxDrawLine( x, y, x, y + h, tocolor( 255, 255, 255, Alpha ), 2 ) -- outside
  34.  
  35.             dxDrawLine( x, y + 40, w +x, y + 40, tocolor( 255, 255, 255, Alpha ), 2 ) -- x
  36.             --outputChatBox(string.len(text) .. ", " .. w)
  37.             dxDrawText(text, x + 5, y + 45, 0, 0, tocolor(231, 76, 60, Alpha), 1.5) -- text
  38.         end,
  39.  
  40.         update = function ()
  41.             if ( x >  sx ) then
  42.                 --removeEventHandler( "onClientRender", getRootElement(), update )
  43.                 isShowing = false;
  44.             else
  45.                 y = y + 10;
  46.             end
  47.         end,
  48.  
  49.         isOn = function ()
  50.             return isShowing;
  51.         end
  52.  
  53.     }
  54.  
  55.     function create ()
  56.         addEventHandler( "onClientRender", getRootElement(), notify.draw )
  57.         isShowing = true;
  58.         setTimer(
  59.             function ()
  60.                 addEventHandler( "onClientRender", getRootElement(), notify.update )
  61.             end,
  62.         fadeTime * 1000, 1)
  63.  
  64.         return notify;
  65.     end
  66.  
  67.     return create();
  68. end
  69.  
  70. function ntoX( Title, text, fadeOut )
  71.     notify(sx - 300, 0, 300, 100, Title, text, fadeOut)
  72. end
  73.  
  74. addEvent( "notify", true )
  75. addEventHandler( "notify", getRootElement(),
  76.     function ( Title, text, fadeIn )
  77.         ntoX(Title, text, fadeIn)
  78.     end
  79. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement