Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. function createnotif(text, textcolor, engtext)
  2. local msg = basewarslang[text]
  3. local color = 0
  4.  
  5. if textcolor == 1 then
  6. color = Color(192, 57, 43, 180)
  7. elseif textcolor == 2 then
  8. color = Color(46, 204, 113,255)
  9. elseif textcolor == 3 then
  10. color = Color(52, 152, 219, 180)
  11. elseif textcolor == 4 then
  12. color = Color(70, 70, 70, 255)
  13. elseif textcolor == 5 then
  14. color = Color(236, 240, 241,255)
  15. elseif textcolor ~= 6 then
  16. color = Color(192, 57, 43, 180)
  17. end
  18.  
  19. if not msg then
  20. msg = text
  21. end
  22.  
  23. if engtext and not basewarslang[text] then
  24. if countrylist[system.GetCountry()] then
  25. msg = text
  26. else
  27. msg = engtext
  28. end
  29. end
  30.  
  31. local notif = vgui.Create("DFrame")
  32. notif:SetSize(32 + (string.len(msg) * 9), 50) -- 38 + 20
  33. notif:SetPos(20,20 + (dermajump * #notiflist) + 50)
  34. notif:SetTitle("")
  35. notif:ShowCloseButton( false )
  36. function notif:Paint(w,h)
  37. if textcolor == 6 then
  38. draw.RoundedBox(16,0,0,w,h, HSVToColor( (engine.TickCount() * 0.75 )% 360, 1, 1 ))
  39. else
  40. draw.RoundedBox(16,0,0,w,h, color)
  41. end
  42. draw.RoundedBox(16,2,2, w - 4, h - 4, basewarslangcolor["black"])
  43. draw.SimpleText(msg, "BW_NotifFont", w/2, h/2, white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
  44. end
  45. notif:SetAlpha(0)
  46. notif:MoveTo(20,20 + dermajump * #notiflist - 1,1,0, -1, function()
  47. surface.PlaySound("")
  48. end)
  49. notif:AlphaTo(255,1,0)
  50.  
  51. function notif:OnRemove() -- for animations when there are several panels
  52. table.RemoveByValue(notiflist, self)
  53. for k,v in pairs(notiflist) do
  54. v:MoveTo(20,20 + dermajump * (k - 1),0.5)
  55. end
  56. self:Close()
  57. end
  58.  
  59. function notif:RemoveMe()
  60. table.RemoveByValue(notiflist, self)
  61. for k,v in pairs(notiflist) do
  62. v:MoveTo(20,20 + dermajump * (k - 1),0.5)
  63. end
  64. self:MoveTo(-50,20 + #notiflist,0.5)
  65. self:AlphaTo(0,0.5,0,function()
  66. self:Close()
  67. end)
  68. end
  69.  
  70. table.insert(notiflist, notif)
  71.  
  72. timer.Simple(6, function() notif:RemoveMe() end)
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement