Advertisement
Guest User

G2O_Notifications

a guest
Mar 13th, 2018
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. addEvent("onNotificationEnd");
  2.  
  3. class Notification {
  4.  
  5.     constructor(id,text,font,r,g,b,x,y) {
  6.         draw = Draw(x,y,text);
  7.         draw.font = font;
  8.         draw.setColor(r,g,b);
  9.         draw.setAlpha(0);
  10.         this.id = id;
  11.  
  12.         draw.visible = true;
  13.         notificationsTimer(this);
  14.     }
  15.  
  16.     id = -1;
  17.     draw = -1;
  18.     count = 1;
  19. }
  20.  
  21. function notificationsTimer(n) {
  22.     setTimer(function() {
  23.         if (n.count >= 1 && n.count <= 10) {
  24.             n.draw.setAlpha(25.5 * n.count);
  25.         } else if (n.count >= 50 && n.count <= 60) {
  26.             n.draw.setAlpha(255 - (10 - (60 - n.count)) * 25.5);
  27.         }
  28.  
  29.         if (n.count == 60) {
  30.             n.draw.visible = false;
  31.             callEvent("onNotificationEnd",n.id);
  32.         }
  33.  
  34.         local pos = n.draw.getPosition();
  35.         n.draw.setPosition(pos.x,pos.y - 16.6);
  36.  
  37.         n.count += 1;
  38.     },50,60);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement