SHARE
TWEET

Untitled

a guest Jul 23rd, 2019 71 in 1 day
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Made by Rab(SamzSakerz#4758)
  2. local mouseX, mouseY, x, y, dx, dy, w, h = 0, 0, 25, 660, 0, 0, 300, 60;
  3. local shouldDrag = false;
  4. local font_title = draw.CreateFont("Arial", 16, 16);
  5. local font_spec = draw.CreateFont("Arial", 15, 15);
  6. local topbarSize = 25;
  7. local windowW, windowH, menuPressed, j = 240, 105, 1, 0;
  8. local mainWindow = gui.Window("rab_onetap_speclist", "Onetap Speclist", 200, 200, windowW, windowH);
  9. local settingsGroup = gui.Groupbox(mainWindow, "Settings", 13, 13, windowW - 25, windowH - 55);
  10. local enabled = gui.Checkbox(settingsGroup, 'rab_onetap_speclist_enable', 'Enable', true);
  11. local gradientOne = gui.ColorEntry("rab_onetap_speclist_gradient_one", "OT Spec List Gradient 1", 52, 63, 65, 255);
  12. local gradientTwo = gui.ColorEntry("rab_onetap_speclist_gradient_two", "OT Spec List Gradient 2", 190, 205, 216, 255);
  13.  
  14. local function getSpectators()
  15.     local spectators = {};
  16.     local lp = entities.GetLocalPlayer();
  17.     if lp ~= nil then
  18.         local players = entities.FindByClass("CBasePlayer");
  19.         local specI = 1;
  20.         for i = 1, #players do
  21.             local player = players[i];
  22.             if player ~= lp and player:GetHealth() <= 0 then
  23.                 local name = player:GetName();
  24.                 if player:GetPropEntity("m_hObserverTarget") ~= nil then
  25.                     local playerindex = player:GetIndex();
  26.                     if playerindex ~= 1 then
  27.                         local target = player:GetPropEntity("m_hObserverTarget");
  28.                         if target:IsPlayer() then
  29.                             local targetindex = target:GetIndex();
  30.                             local myindex = client.GetLocalPlayerIndex();
  31.                            
  32.                                 if targetindex == myindex then
  33.                                     spectators[specI] = player;
  34.                                     specI = specI + 1;
  35.                                 end
  36.                            
  37.                         end
  38.                     end
  39.                 end
  40.             end
  41.         end
  42.     end
  43.     return spectators;
  44. end
  45.  
  46. local function drawRectFill(r, g, b, a, x, y, w, h, texture)
  47.     if (texture ~= nil) then
  48.         draw.SetTexture(texture);
  49.     else
  50.         draw.SetTexture(r, g, b, a);
  51.     end
  52.     draw.Color(r, g, b, a);
  53.     draw.FilledRect(x, y, x + w, y + h);
  54. end
  55.  
  56. local function drawGradientRectFill(col1, col2, x, y, w, h)
  57.     drawRectFill(col1[1], col1[2], col1[3], col1[4], x, y, w, h);
  58.     local r, g, b = col2[1], col2[2], col2[3];
  59.     for i = 1, h do
  60.         local a = i / h * col2[4];
  61.         drawRectFill(r, g, b, a, x + 2, y + i, w - 2, 1);
  62.     end
  63. end
  64.  
  65. local function dragFeature()
  66.     if input.IsButtonDown(1) then
  67.         mouseX, mouseY = input.GetMousePos();
  68.         if shouldDrag then
  69.             x = mouseX - dx;
  70.             y = mouseY - dy;
  71.         end
  72.         if mouseX >= x and mouseX <= x + w and mouseY >= y and mouseY <= y + 40 then
  73.             shouldDrag = true;
  74.             dx = mouseX - x;
  75.             dy = mouseY - y;
  76.         end
  77.     else
  78.         shouldDrag = false;
  79.     end
  80. end
  81.  
  82. local function drawOutline(r, g, b, a, x, y, w, h, howMany)
  83.     for i = 1, howMany do
  84.         draw.Color(r, g, b, a);
  85.         draw.OutlinedRect(x - i, y - i, x + w + i, y + h + i);
  86.     end
  87. end
  88.  
  89. --This draws the nice looking material window designed and developed by Rab
  90. local function drawWindow(spectators)
  91.     local h2 = 10 + (spectators * 15);
  92.     local h = h + (spectators * 15);
  93.  
  94.     -- Draw small outline
  95.     draw.Color(0, 0, 0, 255);
  96.     draw.OutlinedRect(x - 6, y - 6, x + w + 6, y + h + 6);
  97.  
  98.     -- Draw big outline
  99.     drawOutline(74, 65, 54, 200, x, y, w, h, 5);
  100.  
  101.     -- Draw the main bg
  102.     drawRectFill(11, 11, 11, 150, x, y, w, h);
  103.  
  104.  
  105.     -- Draw the text
  106.     draw.Color(255, 255, 255);
  107.     draw.SetFont(font_title);
  108.     local spectext = 'spectators(' .. spectators .. ')';
  109.     local tW, _ = draw.GetTextSize(spectext);
  110.     draw.Text(x + ((w - tW) / 2), y + 5, spectext)
  111.  
  112.     -- draw the gradient divider
  113.     drawGradientRectFill({ gradientOne:GetValue() }, { gradientTwo:GetValue() }, x + 5, y + 23, w - 10, 5, true)
  114.  
  115.     drawRectFill(27, 24, 25, 255, x + 7, y + 40, w - 14, h2);
  116.  
  117.     drawOutline(41, 35, 36, 255, x + 7, y + 40, w - 14, h2, 2);
  118. end
  119.  
  120. local function drawSpectators(spectators)
  121.     for index, player in pairs(spectators) do
  122.         draw.SetFont(font_spec);
  123.         draw.Color(255, 255, 255, 255);
  124.         draw.Text(x + 15, (y + topbarSize + 5) + (index * 15), player:GetName())
  125.     end
  126. end
  127.  
  128. callbacks.Register("Draw", function()
  129.     if input.IsButtonPressed(gui.GetValue("msc_menutoggle")) then
  130.         menuPressed = menuPressed == 0 and 1 or 0;
  131.     end
  132.     mainWindow:SetActive(menuPressed);
  133.     if (enabled:GetValue() ~= true) then
  134.         return
  135.     end
  136.     local spectators = getSpectators();
  137.     if (#spectators == 0) then
  138.         return
  139.     end
  140.     drawWindow(#spectators);
  141.     drawSpectators(spectators);
  142.     dragFeature();
  143. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top