Advertisement
Guest User

Dismay v5 or something

a guest
Jun 6th, 2015
695
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 43.12 KB | None | 0 0
  1. timer.Simple(5, function()
  2. local hwid = [[342387F8D6C0201A069D989008002700C49A{846ee340-7039-11de-9d20-806e6f6e6963}]];
  3. local steamip = [[]];
  4. print('***[M] - Loading');
  5.  
  6. print("***[D] - DEV");
  7.  
  8. dismay = dismay or {};
  9. dismay.version = 8;
  10. dismay.rversion = 8;
  11. dismay.link = "";
  12. dismay.private = dismay.private or {};
  13.  
  14. local function ReplaceG(index)
  15.     dismay[index] = _G[index];
  16.     _G[index] = nil;
  17. end
  18. local function ReplaceUN(index)
  19.     dismay.private[index] = _G[index];
  20.     _G[index] = nil;
  21. end
  22.  
  23. ReplaceG    ("SetIGN");
  24. ReplaceG    ("OpenClient");
  25. ReplaceG    ("RunMenu");
  26. ReplaceG    ("OpenMenu");
  27. ReplaceG    ("RemoveMenuItem");
  28. ReplaceG    ("SetItemCallback");
  29. ReplaceG    ("SetItemName");
  30. ReplaceG    ("LoadWebScript");
  31.  
  32. dismay.SpeedNum     = 0;
  33. dismay.SpeedKey     = false;
  34. dismay.SKey         = cookie.GetNumber("__skey", KEY_G);
  35. dismay.AddHook      = hook.Add;
  36.  
  37.     local a = vgui.Create("DFrame");
  38.     hook.Add("DrawOverlay", "SpeedKey", function()
  39.         draw.DrawText("Open Menu! (esc key)", "BudgetLabel", 2, 3, Color(255,0,255,255));
  40.     end)
  41.     function a:OnKeyCodePressed(key)
  42.         dismay.SKey = key;
  43.         cookie.Set("__skey", key);
  44.         self:Remove();
  45.         a:SetIsMenu(false);
  46.     end
  47.     function a:Think()
  48.         self:RequestFocus();
  49.     end
  50.     a:SetSize(ScrW(), ScrH());
  51.     a:MakePopup();
  52.     a.self = self;
  53.     function a:OnRemove()
  54.         hook.Remove("DrawOverlay", "SpeedKey");
  55.     end
  56.  
  57. dismay.real_g = {};
  58.  
  59. dismay.metas = {};
  60.  
  61. local fetch = http.Fetch;
  62. local abort = abort;
  63.  
  64. dismay.metas._G = {
  65.     __index = function(self, k)
  66.         if dismay.real_g[k] then return dismay.real_g[k]; end
  67.     end;
  68.     __newindex = function(self, k, v)
  69.         if (string.find(string.lower(k), "g_")) then
  70.             if (v == "") then
  71.                 return;
  72.             end
  73.             dismay.real_g[k] = v;
  74.             return;
  75.         end
  76.     end;
  77. };
  78.  
  79. setmetatable(_G, dismay.metas._G);
  80.  
  81. g_ServerName        = nil;
  82. g_MapName       = nil;
  83. g_ServerURL     = nil;
  84. g_MaxPlayers        = nil;
  85. g_SteamID       = nil;
  86.  
  87. dismay.adrsrvlist = {};
  88. local adrsrvlist = dismay.adrsrvlist;
  89. dismay.gmsrvlist = {};
  90. local gmsrvlist = dismay.gmsrvlist;
  91. dismay.nmsrvlist = {};
  92. local nmsrvlist = dismay.nmsrvlist;
  93.  
  94. function GetServers(type, id)
  95.     local data =
  96.     {
  97.         Finished = function()
  98.         end,
  99.         Callback = function( ping , name, desc, map, players, maxplayers, botplayers, pass, lastplayed, address, gamemode, workshopid )
  100.            
  101.             nmsrvlist[name] = {
  102.                 ping = ping;
  103.                 desc = desc;
  104.                 map = map;
  105.                 players = players;
  106.                 maxplayers = maxplayers;
  107.                 botplayers = botplayers;
  108.                 pass = pass and "true" or "false";
  109.                 lastplayed = lastplayed;
  110.                 address = address;
  111.                 gamemode = gamemode;
  112.                 workshopid = workshopid;
  113.             }
  114.            
  115.             adrsrvlist[address] = {
  116.                 ping = ping;
  117.                 name = name;
  118.                 desc = desc;
  119.                 map = map;
  120.                 players = players;
  121.                 maxplayers = maxplayers;
  122.                 botplayers = botplayers;
  123.                 pass = pass and "true" or "false";
  124.                 lastplayed = lastplayed;
  125.                 address = address;
  126.                 gamemode = gamemode;
  127.                 workshopid = workshopid;
  128.             }
  129.            
  130.             gmsrvlist[gamemode] = gmsrvlist or {};
  131.             gmsrvlist[gamemode][address] = {
  132.                 ping = ping;
  133.                 name = name;
  134.                 desc = desc;
  135.                 map = map;
  136.                 players = players;
  137.                 maxplayers = maxplayers;
  138.                 botplayers = botplayers;
  139.                 pass = pass and "true" or "false";
  140.                 lastplayed = lastplayed;
  141.                 address = address;
  142.                 workshopid = workshopid;
  143.             }
  144.            
  145.             name    = string.JavascriptSafe( name );
  146.             desc    = string.JavascriptSafe( desc );
  147.             map     = string.JavascriptSafe( map );
  148.             address = string.JavascriptSafe( address );
  149.             gamemode = string.JavascriptSafe( gamemode );
  150.             workshopid = string.JavascriptSafe( workshopid );
  151.            
  152.             if (pass) then pass = "true" else pass = "false" end
  153.            
  154.             pnlMainMenu:Call("AddServer( '"..type.."', '"..id.."', "..ping..", \""..name.."\", \""..desc.."\", \""..map.."\", "..players..", "..maxplayers..", "..botplayers..", "..pass..", "..lastplayed..", \""..address.."\", \""..gamemode.."\", \""..workshopid.."\", 50 )");
  155.            
  156.         end,
  157.         Type = type,
  158.         GameDir = 'garrysmod',
  159.         AppID = 4000,
  160.     }
  161.     serverlist.Query(data) 
  162. end
  163.  
  164. function dismay.GetServersByName(name, bRemoveCurrent)
  165.     local ret = {};
  166.     for n, info in pairs(nmsrvlist) do
  167.         if(string.find(string.lower(n), string.lower(name))) then
  168.             ret[n] = info;
  169.         end
  170.     end
  171.     if(bRemoveCurrent) then
  172.         for k,v in pairs(ret) do
  173.             if(v.address == dismay.LastJoin) then
  174.                 ret[k] = nil;
  175.             end
  176.         end
  177.     end
  178.     return ret;
  179. end
  180.  
  181. function dismay.GetServersByGamemode(gm)
  182.     return gmsrvlist[gm];
  183. end
  184.  
  185. local o = JoinServer;
  186.  
  187. function JoinServer(ip)
  188.     dismay.LastJoin = ip;
  189.     (dismay.OnJoinServer or function() end)(ip);
  190.     return o(ip);
  191. end
  192. dismay.Panel = {};
  193.  
  194. function dismay.Panel:OnMousePressed()
  195.     self:SetBeingPressed(true);
  196.     local mx, my = input.GetCursorPos();
  197.     local x, y = self:GetPos();
  198.     self.OffX = mx - x;
  199.     self.OffY = my - y;
  200. end
  201. function dismay.Panel:Think()
  202.     if(self:GetDraggable() and self:GetBeingPressed() and not self:GetMinimized()) then
  203.         if(input.IsMouseDown(MOUSE_LEFT)) then
  204.             local mx, my = input.GetCursorPos();
  205.             local rx = math.min(ScrW(), math.max(0, mx - self.OffX) + self:GetWide()) - self:GetWide();
  206.             local ry = math.min(ScrH(), math.max(0, my - self.OffY) + self:GetTall()) - self:GetTall();
  207.             self:SetPos(rx, ry);
  208.         else
  209.             self:SetBeingPressed(false);
  210.         end
  211.     end
  212.    
  213.     if(self:GetMinimized()) then
  214.         if(not self:GetWasMinimized()) then
  215.             local x, y = self:GetPos();
  216.             local w, h = self:GetWide(), self:GetTall();
  217.             local r = {
  218.                 x = x;
  219.                 y = y;
  220.                 w = w;
  221.                 h = h;
  222.             };
  223.             self.oldInfo = r;
  224.             dismay.WindowList:AddPnl(self);
  225.         end
  226.         self.btnMaxim:SetDisabled(false);
  227.         self.btnMinim:SetDisabled(true);
  228.     else
  229.         if(self:GetWasMinimized()) then
  230.             self:SetPos(self.oldInfo.x, self.oldInfo.y);
  231.             self:SetTall(self.oldInfo.h);
  232.             self:SetWide(self.oldInfo.w);
  233.             self.btnMaxim:SetDisabled(true);
  234.             self.btnMinim:SetDisabled(false);
  235.         end
  236.     end
  237.     self:SetWasMinimized(self:GetMinimized());
  238. end
  239.  
  240. dismay.Panel.btnMaxim = {}
  241. function dismay.Panel.btnMaxim:DoClick()
  242.     self:GetParent():SetMinimized(false);
  243.     dismay.WindowList:RemPnl(self:GetParent())
  244. end
  245. dismay.Panel.btnMinim = {}
  246. function dismay.Panel.btnMinim:DoClick()
  247.     self:GetParent():SetMinimized(true);
  248. end
  249.  
  250. function dismay.Panel:Init()
  251.     self.m_bMinimized = false;
  252.     self.m_bWasMinimized = false;
  253.     self.m_bIsBeingPressed = false;
  254.    
  255.     function self.GetMinimized(self)
  256.         return self.m_bMinimized;
  257.     end
  258.    
  259.     function self.SetMinimized(self, b)
  260.         self.m_bMinimized = b;
  261.     end
  262.    
  263.     function self.GetWasMinimized(self)
  264.         return self.m_bWasMinimized;
  265.     end
  266.    
  267.     function self.SetWasMinimized(self, b)
  268.         self.m_bWasMinimized = b;
  269.     end
  270.    
  271.     function self.GetBeingPressed(self)
  272.         return self.m_bIsBeingPressed;
  273.     end
  274.    
  275.     function self.SetBeingPressed(self, b)
  276.         self.m_bIsBeingPressed = b;
  277.     end
  278.    
  279.     self.btnClose:SetDisabled(true);
  280.    
  281.     self.btnMaxim.DoClick = dismay.Panel.btnMaxim.DoClick;
  282.    
  283.     self.btnMinim:SetDisabled(false);
  284.     self.btnMinim.DoClick = dismay.Panel.btnMinim.DoClick;
  285. end
  286.  
  287. local PANEL = {};
  288.  
  289. PANEL.m_pPanels = {};
  290. PANEL.pWidth = 220;
  291. PANEL.pHeight = 21;
  292.  
  293. function PANEL:AddPnl(pnl)
  294.     table.insert(self.m_pPanels, pnl);
  295. end
  296. function PANEL:RemPnl(rpnl)
  297.     for i, pnl in ipairs(self.m_pPanels) do
  298.         if(pnl == rpnl) then
  299.             table.remove(self.m_pPanels, i);
  300.         end
  301.     end
  302. end
  303. function PANEL:Think()
  304.     local curx = 0;
  305.     local width = math.min(self.pWidth, #self.m_pPanels > 0 and ScrW() / #self.m_pPanels or ScrW());
  306.     for i, pnl in ipairs(self.m_pPanels) do
  307.         if(not pnl or not IsValid(pnl)) then table.remove(self.m_pPanels, i); end
  308.         local s, c = pcall(function()
  309.             pnl:SetPos(curx, ScrH() - self.pHeight);
  310.             pnl:SetTall(self.pHeight);
  311.             pnl:SetWide(width);
  312.             curx = curx + width;
  313.         end)
  314.         if(not s) then table.remove(self.m_pPanels,i); end
  315.     end
  316. end
  317. function PANEL:Init()
  318.    
  319. end
  320.  
  321. vgui.Register("DWindowList", PANEL, "EditablePanel")
  322. dismay.WindowList = vgui.Create("DWindowList");
  323.  
  324. local PANEL = {};
  325.  
  326.  
  327. function PANEL:Init()
  328.     if(dismay.version == dismay.rversion) then
  329.         self.colCur = self.colRel;
  330.         self.szExtra = "(Current)";
  331.     elseif(dismay.version < dismay.rversion) then
  332.         self.colCur = self.colDev;
  333.         self.szExtra = "(Dev)";
  334.     else
  335.         self.colCur = self.colOld;
  336.         self.szExtra = "(Old)\n"..dismay.link;
  337.     end
  338.     self:SetWide(ScrW() / 2);
  339.     self:SetTall(40);
  340.     self:SetPos(ScrW() / 2 - self:GetWide() / 2, 0);
  341.     self:MakePopup();
  342.    
  343.     self.lbl1 = vgui.Create("DLabel", self);
  344.     self.lbl1:SetFont("BudgetLabel");
  345.     self.lbl1:SetText("DLL Version r"..dismay.rversion.." "..self.szExtra)
  346.     self.lbl1:SizeToContents();
  347.     self.lbl1:SetTextColor(self.colCur);
  348.     self.lbl1:SetPos(self:GetWide() / 2 - self.lbl1:GetWide() / 2, 2);
  349. end
  350.  
  351. vgui.Register("DVersionWin", PANEL, "EditablePanel")
  352.  
  353. dismay.VersionPanel = vgui.Create("DVersionWin");
  354.  
  355.  
  356. dismay.LuaPanel = false
  357. function dismay.CreateWindow()
  358.     if(IsValid(dismay.LuaPanel)) then return; end
  359.     dismay.LuaPanel = vgui.Create("DFrame");
  360.     dismay.LuaPanel:SetSize(300, 200);
  361.     dismay.LuaPanel:SetTitle("Lua Options");
  362.     dismay.Panel.Init(dismay.LuaPanel);
  363.     function dismay.LuaPanel:OnMousePressed()
  364.         dismay.Panel.OnMousePressed(self);
  365.     end
  366.     function dismay.LuaPanel:Think()
  367.         dismay.Panel.Think(self);
  368.     end
  369.     dismay.LuaPanel:Center()
  370.     local t = vgui.Create("DTextEntry", dismay.LuaPanel);
  371.     local b = vgui.Create("DComboBox", dismay.LuaPanel);
  372.     b:SetValue("CL - Run");
  373.     b:AddChoice("CL - Run");
  374.     b:AddChoice("CL - Open");
  375.     b:AddChoice("MN - Run");
  376.     b:AddChoice("MN - Open");
  377.  
  378.     dismay.LuaPanel.m_pText = t;
  379.     dismay.LuaPanel.m_pBox = b;
  380.  
  381.     function b:OnSelect(index, value, data)
  382.         if(index == 2) then
  383.             self.m_pFunc = dismay.OpenClient;
  384.         elseif(index == 3) then
  385.             self.m_pFunc = dismay.RunMenu;
  386.         elseif(index == 4) then
  387.             self.m_pFunc = dismay.OpenMenu;
  388.         end
  389.     end
  390.     function b:Think()
  391.         self:SetWide(self:GetParent():GetWide() * 3 / 4);
  392.         self:SetPos(self:GetParent():GetWide() / 2 - self:GetWide() / 2, 30);
  393.     end
  394.  
  395.     function t:Think()
  396.         self:SetWide(self:GetParent():GetWide() * 2 / 3);
  397.         self:SetTall(self:GetParent():GetTall() / 2);
  398.         self:SetPos(self:GetParent():GetWide() / 2 - self:GetWide() / 2, self:GetParent():GetTall() / 2 - self:GetTall() / 2 + 30)
  399.     end
  400.  
  401.     function t:OnEnter()
  402.         self:GetParent().m_pBox.m_pFunc(self:GetValue());
  403.     end
  404.  
  405.     dismay.LuaPanel:MakePopup();
  406. end
  407.  
  408. print("***[M] - Loaded");
  409. MsgC(Color(200,100, 100,255),[[
  410. *** - menu autorun file is C:\\dismay\\dismay_menu.lua
  411. *** - Hit insert to toggle menu input. Up/Down arrows go up and down on the menu.
  412. *** - Hit the right arrow to toggle the option highlighted.
  413. *** - G is speedhack key. Highlighted speedhack on top right is faster. (16 compared to 9 disabled)
  414. ]]);
  415. if(dismay.version == dismay.rversion) then
  416.     MsgC(Color(0,255,0,255), [[
  417. [!] - YOU HAVE THE LATEST VERSION.
  418. ]]);
  419. elseif(dismay.version > dismay.rversion) then
  420.     MsgC(Color(255,0,0,255), [[
  421. *** - YOU DON'T HAVE THE LATEST VERSION.
  422. *** - ]]..dismay.link..[[
  423. ]]);
  424. else
  425.     MsgC(Color(0,255,125,255), [[
  426. *** - YOU HAVE A DEV VERSION.
  427. ]]);
  428. end
  429.  
  430. MsgC(Color(0,255,200,255),"\n\n\tSpecial thanks to:\n\t\tNanoCat (for help)\n\t\tvec (for helping me learn)\n\t\tsasha\n\n");
  431.  
  432.  
  433.  
  434. local hwid = [[342387F8D6C0201A069D989008002700C49A{846ee340-7039-11de-9d20-806e6f6e6963}]];
  435. local steamip = [[]];
  436. local isdev = false;
  437. local debugging = false;
  438. if(hwid == "342387F8D6C0201A069D989008002700C49A{846ee340-7039-11de-9d20-806e6f6e6963}") then
  439.     isdev = true;
  440.     print("[**] - Developer mode enabled");
  441. end
  442.  
  443. local __tc = _tc;
  444. local _p = print;
  445. local function DebugPrint(x)
  446.     if(isdev and debugging) then
  447.         _p(x);
  448.         __tc(x, "Dismay");
  449.     end
  450. end
  451. local dismay = {};
  452. dismay.private = {
  453.     hiddenfiles = {};
  454.     funcs   = {};
  455.     oldfuncs= {};
  456.     metas = {
  457.         real = {};
  458.     };
  459.     waitfor = {};
  460.     gm      = {};
  461.     fgm     = {};
  462.     ogm     = {};
  463.     egm     = {};
  464.     vars    = {};
  465.     dhook   = {};
  466.     realg   = _G;
  467.     esp     = {};
  468.     scrnsht = {};
  469.     scrnshtd= {};
  470.     oldr    = {};
  471.     mem     = {};
  472. };
  473.  
  474. setmetatable( dismay.private.mem, {__mode = "kv"})
  475.  
  476. function dismay.ShouldDrawESP()
  477.     return dismay.private.ShouldDrawESP;
  478. end
  479. print("***[C] - Loading");
  480.  
  481. function dismay.HideThisFile(f)
  482.     dismay.private.hiddenfiles[dismay.private.oldfuncs.debug_getinfo(f).short_src] = true;
  483. end
  484.  
  485. dismay.private.hiddenfiles["\x01"] = true;
  486.  
  487. local function __indexnew(self, k)
  488.     local mt = dismay.private.oldg.getmetatable(self);
  489.     if(dismay.private.oldg.rawget(mt.spoofed, k) == nil) then
  490.         if(mt.spoofedname == "_G" and k == "dismay") then return dismay; end
  491.         dismay.private.oldg.MsgC(dismay.private.oldg.Color(200, 0, 0, 255), "***WARNING: indexed function "..mt.spoofedname.."."..k.." but didn't exist! Defaulting to real global table (could have anticheat code in it)\n"..dismay.private.oldg.debug.traceback().."\n\n");
  492.     else
  493.         if(mt.spoofedname == "_G.dismay.private" and k == "realg") then
  494.             return dismay.private.oldg.rawget(mt.spoofed, k);
  495.         end
  496.         if(dismay.private.oldg.type(dismay.private.oldg.rawget(mt.spoofed, k)) == "table") then
  497.             local nmt   = dismay.CopyTable(dismay.private.spf);
  498.             nmt.spoofed = dismay.private.oldg.rawget(mt.spoofed, k);
  499.             nmt.real    = dismay.private.oldg.rawget(mt.real, k);
  500.             nmt.spoofedname = (mt.spoofedname and mt.spoofedname.."." or "")..k;
  501.             return dismay.private.oldg.setmetatable(mt.spoofed[k], nmt);
  502.         else
  503.             return mt.spoofed[k];
  504.         end
  505.     end
  506.     return mt.real[k];
  507. end
  508.  
  509. local function __newindexnew(self, k, v)
  510.     dismay.private.oldg.MsgC(dismay.private.oldg.Color(200,0,0,255), "***WARNING: created new global index "..k.." ("..tostring(v).."). If this was intended use dismay.private.realg["..k.."] = "..tostring(v).."\n");
  511. end
  512.  
  513. dismay.private.spf = {
  514.     __index     = __indexnew;
  515.     __newindex  = __newindexnew;
  516. }
  517.  
  518. function dismay.SetupGlobalTable()
  519.     DebugPrint("START - SetupGlobalTable()");
  520.     local mt        = dismay.CopyTable(dismay.private.spf);
  521.     mt.spoofedname  = "_G";
  522.     mt.real         = dismay.private.realg;
  523.     mt.spoofed      = dismay.private.newg;
  524.     dismay.private.oldg.setfenv(2, dismay.private.oldg.setmetatable({}, mt));
  525.     DebugPrint("END - SetupGlobalTable()");
  526. end
  527.  
  528.  
  529. local function normalang(ang)
  530.     ang.p = (ang.p + 180) % 360 - 180; ang.y = (ang.y + 180) % 360 - 180; ang.r = (ang.r + 180) % 360 - 180;
  531.    
  532.     return ang
  533. end
  534.  
  535. if (GetPred) then dismay.private.GetPred = GetPred; GetPred = nil;
  536.     function dismay.GetPred(ply)
  537.         return dismay.private.GetPred(ply, Vector(0,0,0));
  538.     end
  539. end
  540. local predicting = false;
  541. if (PredSpread) then
  542.     dismay.private.PredSpread = PredSpread; PredSpread = nil;
  543.     function dismay.PredSpread(cmd, ang)   
  544.         local l = LocalPlayer();
  545.         local w = l:GetActiveWeapon();
  546.         if(LocalPlayer():GetActiveWeapon().Author == "Spy" and w.CurCone) then -- fas2
  547.             local n = cmd:CommandNumber();
  548.             math.randomseed(n)
  549.             local a = Angle(math.Rand(-w.CurCone, w.CurCone), math.Rand(-w.CurCone, w.CurCone), 0);
  550.             local nang = ang - l:GetPunchAngle() - a * 25
  551.             local b = false;
  552.             if w.ClumpSpread and w.ClumpSpread > 0 then
  553.                 b = Vector(math.Rand(-1, 1), math.Rand(-1, 1), math.Rand(-1, 1)) * w.ClumpSpread
  554.             end
  555.             if(b) then
  556.                 nang = (nang:Forward() - b):Angle();
  557.             end
  558.            
  559.             return nang;
  560.         end
  561.         local b, _spread = dismay.private.PredSpread(cmd:CommandNumber(), ang, dismay.GetSpread(LocalPlayer():GetActiveWeapon()));
  562.         local g = {b, _spread};
  563.         local ret = _spread:Angle();
  564.         ret.p = ret.p;
  565.        
  566.         return normalang(ret);
  567.     end
  568. end
  569. dismay.version = 8;
  570. local oG = _G;
  571.  
  572. local function ReplaceG(index)
  573.     dismay[index] = oG[index];
  574.     oG[index] = nil;
  575. end
  576. local function ReplaceUN(index)
  577.     dismay.private[index] = oG[index];
  578.     oG[index] = nil;
  579. end
  580.  
  581. ReplaceG    "Repaint";
  582. ReplaceUN   "SendFile";
  583. ReplaceUN   "GetFile";
  584. ReplaceG    "_tc";
  585. ReplaceG    "OpenClient";
  586. ReplaceG    "RunMenu";
  587. ReplaceG    "OpenMenu";
  588. ReplaceG    "IsDormant";
  589. ReplaceG    "GetCmdRepState";
  590. ReplaceG    "SetTickRate";
  591. ReplaceG    "SetSteamName";
  592. ReplaceG    "GetSteamName";
  593. ReplaceG    "SetIGN";
  594. ReplaceG    "LoadWebScript";
  595. ReplaceG    "RequestFile";
  596. ReplaceG    "GetTickCount";
  597. ReplaceG    "SetTickCount";
  598.  
  599. function dismay.OverrideHook(name, redir)
  600.     dismay.private.Hooks = dismay.private.Hooks or {};
  601.     dismay.private.Hooks[name] = redir;
  602. end
  603.  
  604. function dismay.CallHook(name, ...)
  605.     if(not dismay.private.Hooks[name]) then return; end
  606.     for k,v in dismay.private.oldfuncs.pairs(dismay.private.Hooks[name]) do
  607.         v(...);
  608.     end
  609. end
  610.  
  611. function dismay.SpoofFunction(oldfunction, replacefunction)
  612.     dismay.private.funcs[replacefunction] = oldfunction;
  613. end
  614.  
  615. function dismay.runwhenindexcreated(k, func)
  616.     if (oG[k]) then func(); return; end
  617.     dismay.private.waitfor[k] = dismay.private.waitfor[k] or {};
  618.     dismay.private.waitfor[k][#dismay.private.waitfor[k] + 1] = func;
  619. end
  620.  
  621. function dismay.GetHooks(name)
  622.     local _name = name;
  623.     return dismay.private.fgm[name] or {};
  624. end
  625.  
  626. function dismay.AddHook(_type, name, func)
  627.     DebugPrint("START - AddHook(".._type..", "..name..", func)");
  628.     if(_type == "OnScreenshot") then
  629.         dismay.private.scrnsht[name] = func;
  630.     end
  631.     if(_type == "OnScreenshotDone") then
  632.         dismay.private.scrnshtd[name] = func;
  633.     end
  634.     dismay.private.fgm[_type] = dismay.private.fgm[_type] or {};
  635.     dismay.private.fgm[_type][name] = func;
  636.     DebugPrint("END - AddHook()");
  637. end
  638.  
  639. function dismay.RemoveHook(_type, name)
  640.     local type = _type;
  641.     local c = dismay.private.fgm[type] or {};
  642.     c[name] = nil;
  643. end
  644.  
  645. function dismay.CopyTable(t, lookup_table)
  646.     if (t == nil) then return nil end
  647.     local copy = {}
  648.     for i,v in dismay.private.oldfuncs.pairs(t) do
  649.         if ( !istable(v) ) then
  650.             copy[i] = v
  651.         else
  652.             lookup_table = lookup_table or {}
  653.             lookup_table[t] = copy
  654.             if lookup_table[v] then
  655.                 copy[i] = lookup_table[v] -- we already copied this table. reuse the copy.
  656.             else
  657.                 copy[i] = dismay.CopyTable(v,lookup_table) -- not yet copied. copy it.
  658.             end
  659.         end
  660.     end
  661.     return copy;
  662. end
  663.  
  664.  
  665. function dismay.CopyTable_l(t, lookup_table)
  666.     if (t == nil) then return nil end
  667.     local copy = {}
  668.     for i,v in dismay.private.oldfuncs.pairs(t) do
  669.         copy[i] = v;
  670.     end
  671.    
  672.     return copy
  673. end
  674. dismay.private.oldfuncs.jit_util_funcinfo   = jit.util.funcinfo;
  675. dismay.private.oldfuncs.debug_setupvalue    = debug.setupvalue;
  676. dismay.private.oldfuncs.debug_getupvalue    = debug.getupvalue;
  677. dismay.private.oldfuncs.debug_getinfo   = debug.getinfo;
  678. dismay.private.oldfuncs.tostring        = tostring;
  679. dismay.private.oldfuncs.getmetatable    = getmetatable;
  680. dismay.private.oldfuncs.setmetatable    = setmetatable;
  681. dismay.private.oldfuncs.rawget      = rawget;
  682. dismay.private.oldfuncs.rawset      = rawset;
  683. dismay.private.oldfuncs.pairs       = pairs;
  684. dismay.private.oldfuncs.next        = next;
  685.  
  686. local function Color(r, g, b, a)
  687.     return {r = r; g = g; b = b; a = a;}
  688. end
  689. local function IsValid(x)
  690.     return x and x.IsValid and x:IsValid();
  691. end
  692.  
  693. dismay.private.oldg = dismay.CopyTable(_G);
  694. dismay.private.newg = dismay.CopyTable(_G);
  695. dismay.private.oldr = dismay.CopyTable(debug.getregistry());
  696.  
  697. local _R    = dismay.private.oldr;
  698. local G     = dismay.private.oldg;
  699. local rG = dismay.private.realg;
  700. function dismay.private.newg.math.Round(x)
  701.     return G.math.floor(x + 0.5);
  702. end
  703. dismay.SetupGlobalTable();
  704.  
  705.  
  706. dismay.private.oldg.Color = Color;
  707. dismay.private.oldg.IsValid = IsValid;
  708. dismay.private.newg.Color = Color;
  709. dismay.private.newg.IsValid = IsValid;
  710.  
  711. dismay.private.metas.real.GAMEMODE = {
  712.     __index = function(self, k)
  713.         DebugPrint("START - __index(GAMEMODE, "..tostring(k)..")");
  714.         return dismay.private.gm[k] or dismay.private.ogm[k] or function(GM, ...)
  715.             if (dismay.private.fgm[k]) then
  716.                 for _k, vfunc in dismay.private.oldg.pairs(dismay.private.fgm[k]) do
  717.                     local r = vfunc(...);
  718.                     if (r ~= nil) then return r; end
  719.                 end
  720.             end
  721.         end;
  722.     end;
  723.     __newindex = function(self, k, func)
  724.         DebugPrint("START - __newindex(GAMEMODE, "..tostring(k)..", "..tostring(func)..")");
  725.         dismay.private.gm[k] = func;
  726.         dismay.private.ogm[k] = func;
  727.         dismay.private.oldfuncs.rawset(self, k, nil);
  728.         if (dismay.private.oldg.type(func) == "function") then
  729.             local f = function(GM, ...)
  730.                 if (dismay.private.fgm[k]) then
  731.                     for _k, vfunc in dismay.private.oldg.pairs(dismay.private.fgm[k]) do
  732.                         local r = vfunc(...);
  733.                         if (r ~= nil) then return r; end
  734.                     end
  735.                 end
  736.                 return dismay.private.ogm[k](dismay.private.ogm, ...);
  737.             end
  738.             dismay.SpoofFunction(func, f);
  739.             dismay.private.gm[k] = f;
  740.         end
  741.         return;
  742.     end;
  743.     __dtable = true;
  744. };
  745. local troo = false;
  746.  
  747. dismay.private.metas.real._G = {
  748.     __index = function(self, k)
  749.         --if(troo) then dismay._tc(dismay.private.oldg.tostring(k).."\n"..debug.traceback(), "__index - _G"); end
  750.         if (k == "dismay" and (dismay.private.oldg.debug.getinfo(2).short_src == "" or dismay.private.oldg.debug.getinfo(2).short_src == "\x01")) then
  751.         --if(k == "dismay") then
  752.             return dismay;
  753.         end
  754.         if (dismay.private.metas._G and dismay.private.metas._G.__index) then
  755.             local ret = dismay.private.metas._G.__index(self, k);
  756.             if (dismay.private.oldg.type(ret) ~= "no value") then
  757.                 return ret;
  758.             end
  759.         end
  760.     end;
  761.     __newindex = function(self, k, v)
  762.         if (k == "dismay") then
  763.             return;
  764.         end
  765.         if (dismay.private.metas["_G"] and dismay.private.metas["_G"].__newindex and not dismay.private.check1) then
  766.             dismay.private.check1 = true;          
  767.             local ret = dismay.private.metas["_G"].__newindex(self, k, v);
  768.             dismay.private.check1 = false;
  769.             if (dismay.private.oldg.type(ret) ~= "no value") then
  770.                 return ret;
  771.             end
  772.         end
  773.         if (dismay.private.waitfor[k]) then
  774.             local o = dismay.CopyTable_l(dismay.private.waitfor[k]);
  775.             dismay.private.waitfor[k] = nil;
  776.             for i, func in dismay.private.oldg.ipairs(o) do
  777.                 func(v);
  778.             end
  779.         end
  780.         return dismay.private.oldfuncs.rawset(self, k, v);
  781.     end;
  782.     __dtable = true;
  783. };
  784.  
  785. function rG.debug.getupvalue(func, ...)
  786.     --dismay._tc(tostring(func), "debug.getupvalue");
  787.     if(dismay.private.funcs[func]) then
  788.         return dismay.private.oldfuncs.debug_getupvalue(dismay.private.funcs[func], ...);
  789.     end
  790.     return dismay.private.oldfuncs.debug_getupvalue(func, ...);
  791. end
  792.  
  793. function rG.debug.setupvalue(func, ...)
  794.     --dismay._tc(tostring(func), "debug.setupvalue");
  795.     if(dismay.private.funcs[func]) then
  796.         return dismay.private.oldfuncs.debug_setupvalue(dismay.private.funcs[func], ...);
  797.     end
  798.     return dismay.private.oldfuncs.debug_setupvalue(func, ...);
  799. end
  800.  
  801. local debug_getinfo;
  802.  
  803. function debug_getinfo(func, value)
  804.     DebugPrint("SRT - dbginf");
  805.     local ret = nil;
  806.     if (dismay.private.funcs[func]) then
  807.         ret = dismay.private.oldfuncs.debug_getinfo(dismay.private.funcs[func], value or nil);
  808.         if (ret.func) then ret.func = func; end
  809.     else
  810.         ret = dismay.private.oldfuncs.debug_getinfo(func, value or nil);
  811.         if(dismay.private.oldg.type(func) == "number") then
  812.             local need = func;
  813.             local current = 0;
  814.             while(need > 1) do
  815.                 --ret and ret.short_src and dismay.private.hiddenfiles[ret.short_src]
  816.                 local r = dismay.private.oldfuncs.debug_getinfo(current);
  817.                 if(not r or not r.short_src or not dismay.private.hiddenfiles[r.short_src]) then
  818.                     need = need - 1;
  819.                 end
  820.                 current = current + 1;
  821.             end
  822.             DebugPrint("END - dbginf NUM");
  823.             ret = dismay.private.oldfuncs.debug_getinfo(current, value or nil);
  824.         end
  825.     end
  826.     DebugPrint("END - dbginf");
  827.     return ret;
  828. end
  829.  
  830. rG.debug.getinfo = debug_getinfo;
  831.  
  832. function rG.jit.util.funcinfo(func, ...)
  833.     local ret = nil;
  834.     if(dismay.private.funcs[func]) then
  835.         ret = dismay.private.oldfuncs.jit_util_funcinfo(dismay.private.funcs[func], ...);
  836.     else
  837.         ret = dismay.private.oldfuncs.jit_util_funcinfo(func, ...);
  838.     end
  839.     return ret;
  840. end
  841.  
  842. function rG.next(table, t)
  843.     --dismay._tc(tostring(table).." "..tostring(t), "next");
  844.     if (table == dismay.private.oldg.rawget(rG, "GAMEMODE")) then
  845.         return dismay.private.oldfuncs.next, dismay.private.gm, t;
  846.     end
  847.     if (table == rG) then
  848.         local f_G = dismay.CopyTable_l(rG);
  849.         f_G.GAMEMODE = dismay.private.oldg.rawget(rG, "GAMEMODE");
  850.         return dismay.private.oldfuncs.next, f_G, t;
  851.     end
  852.     return dismay.private.oldfuncs.next, table, t;
  853. end
  854.  
  855. function rG.pairs(table)
  856.     if (table == dismay.private.oldg.rawget(rG, "GAMEMODE")) then
  857.         --dismay._tc(tostring(table), "pairs - gamemode");
  858.         return dismay.private.oldfuncs.next, dismay.private.gm, nil;
  859.     end
  860.     if (table == rG) then
  861.         --dismay._tc(tostring(table).."\n"..debug.traceback(), "pairs - _G");
  862.        
  863.         local f_G = dismay.CopyTable_l(rG);
  864.         f_G.GAMEMODE = dismay.private.oldg.rawget(rG, "GAMEMODE");
  865.         return dismay.private.oldfuncs.next, f_G, nil;
  866.     end
  867.     return dismay.private.oldfuncs.next, table, nil;
  868. end
  869. local rawgetb = true;
  870. function rG.rawget(table, index)
  871.     if (rawgetb and dismay.private.oldfuncs.getmetatable(table) and dismay.private.oldg.type(dismay.private.oldfuncs.getmetatable(table)) == "table" and dismay.private.oldfuncs.getmetatable(table).__dtable) then
  872.         rawgetb = false;
  873.         local ret = dismay.private.oldfuncs.getmetatable(table).__index(table, index);
  874.         rawgetb = true;
  875.         return ret;
  876.     end
  877.     return dismay.private.oldfuncs.rawget(table, index);
  878. end
  879.  
  880. function rG.rawset(table, index, value)
  881.     if (dismay.private.oldfuncs.getmetatable(table) and dismay.private.oldg.type(dismay.private.oldfuncs.getmetatable(table)) == "table" and dismay.private.oldfuncs.getmetatable(table).__dtable) then
  882.         return dismay.private.oldfuncs.getmetatable(table).__newindex(table, index, value);
  883.     end
  884.     return dismay.private.oldfuncs.rawset(table, index, value);
  885. end
  886.  
  887. function rG.tostring(value)
  888.     local ots = dismay.private.oldfuncs.tostring;
  889.     if(dismay.private.funcs[value]) then
  890.         return ots(dismay.private.funcs[value]);
  891.     end
  892.     return ots(value);
  893. end
  894.  
  895. function rG.getmetatable(tbl)
  896.     troo = true;
  897.     if (tbl == rG) then
  898.         return dismay.private.metas._G or nil;
  899.     end
  900.     if (tbl == dismay.private.oldg.rawget(rG, "GAMEMODE")) then
  901.         return dismay.private.metas.GAMEMODE or nil;
  902.     end
  903.     troo = false;
  904.     return G.getmetatable(tbl);
  905. end
  906.  
  907. function rG.setmetatable(tbl, mt)
  908.     if (tbl == rG) then
  909.         dismay.private.metas._G = mt;
  910.         return tbl;
  911.     end
  912.     if (tbl == G.rawget(rG, "GAMEMODE")) then
  913.         dismay.private.metas.GAMEMODE = mt;
  914.         return tbl;
  915.     end
  916.     return G.setmetatable(tbl, mt);
  917. end
  918. dismay.SpoofFunction(dismay.private.oldfuncs.jit_util_funcinfo, rG.jit.util.funcinfo);
  919. dismay.SpoofFunction(dismay.private.oldfuncs.debug_getupvalue,  rG.debug.getupvalue);
  920. dismay.SpoofFunction(dismay.private.oldfuncs.debug_setupvalue,  rG.debug.setupvalue);
  921. dismay.SpoofFunction(dismay.private.oldfuncs.debug_getinfo, rG.debug.getinfo);
  922. dismay.SpoofFunction(dismay.private.oldfuncs.getmetatable,  rG.getmetatable);
  923. dismay.SpoofFunction(dismay.private.oldfuncs.setmetatable,  rG.setmetatable);
  924. dismay.SpoofFunction(dismay.private.oldfuncs.tostring,      rG.tostring);
  925. dismay.SpoofFunction(dismay.private.oldfuncs.rawget,        rG.rawget);
  926. dismay.SpoofFunction(dismay.private.oldfuncs.rawset,        rG.rawset);
  927. dismay.SpoofFunction(dismay.private.oldfuncs.pairs,     rG.pairs);
  928. dismay.SpoofFunction(dismay.private.oldfuncs.next,      rG.next);
  929.  
  930. dismay.private.oldfuncs.setmetatable(rG, dismay.private.metas.real._G);
  931.  
  932. local plys = player.GetAll();
  933. local function rem(i) table.remove(plys, i) end
  934. local x = 10;
  935.  
  936. dismay.AddHook("Think", "InitValid", function()
  937.     x = x - 1;
  938.     if(x ~= 0) then return; end
  939.     plys = player.GetAll();
  940.     for i = #plys, 1, -1 do
  941.         local v = plys[i];
  942.         if(v:Health() <= 0) then rem(i); continue; end
  943.         if(v:Team() == TEAM_SPECTATOR) then rem(i); continue; end
  944.         if(v:GetObserverMode() ~= OBS_MODE_NONE) then rem(i); continue; end
  945.     end
  946. end);
  947.  
  948. gameevent.Listen("player_spawn");
  949. dismay.AddHook("player_spawn", "AddValid", function(d)
  950.     local ply = Player(d.userid);
  951.     plys[#plys + 1] = ply;
  952. end);
  953. gameevent.Listen("player_hurt");
  954. dismay.AddHook("player_hurt", "RemoveValid", function(d)
  955.     local att = Player(d.userid);
  956.     if(d.health <= 0) then
  957.         for i = 1, #plys do
  958.             if(plys[i] == att) then rem(i); break; end
  959.         end
  960.     end
  961. end);
  962. gameevent.Listen("player_connect");
  963. dismay.AddHook("player_connect", "ConnectValid", function(d)
  964.     dismay.AddHook("Think", "dontremove"..tostring(d.userid), function()
  965.         plys[#plys + 1] = Player(d.userid);
  966.         dismay.RemoveHook("Think", "dontremove");
  967.     end);
  968. end);
  969.  
  970. dismay.runwhenindexcreated("vgui", function()
  971.     timer.Simple(1, function() -- lz
  972.         local w = 200;
  973.         local h = 200;
  974.         local texture = surface.GetTextureID("gui/corner8");
  975.  
  976.         local function DrawCircle(x, y, r, col)
  977.             surface.SetTexture(texture);
  978.             surface.SetDrawColor(col);
  979.             local mx = x + r;
  980.             local my = y + r
  981.             surface.DrawTexturedRectRotated(mx - r / 2, my - r / 2 , r, r, 0);
  982.             surface.DrawTexturedRectRotated(mx - r / 2, my + r / 2 , r, r, 90);
  983.             surface.DrawTexturedRectRotated(mx + r / 2, my + r / 2 , r, r, 180);
  984.             surface.DrawTexturedRectRotated(mx + r / 2, my - r / 2 , r, r, 270);
  985.         end
  986.  
  987.         dismay.Panels = dismay.Panels or {};
  988.  
  989.         local sqsize = 4;
  990.  
  991.         local function DrawPlayers(w, h, pixelsperunit)
  992.             local lp = LocalPlayer();
  993.             local lppos = _R.Entity.GetPos(lp);
  994.             local lpy = _R.Entity.EyeAngles(lp).y;
  995.             lppos.z = 0;
  996.             for i = 1, #plys do
  997.                 local v = plys[i];
  998.                 if(v == lp) then continue; end
  999.                 if(not IsValid(v)) then rem(i); continue; end
  1000.                 local ppos = _R.Entity.GetPos(v);
  1001.                 ppos.z = 0;
  1002.                 local dist = _R.Vector.Distance(ppos, lppos);
  1003.                 local angy = _R.Vector.Angle(ppos - lppos).y;
  1004.                 local d = (angy - lpy - 90) / 57;
  1005.                 local xdif = -math.cos(d) * dist * pixelsperunit;
  1006.                 local ydif = math.sin(d) * dist * pixelsperunit;
  1007.                 local x = w / 2 + xdif - sqsize / 2;
  1008.                 local y = h / 2 + ydif - sqsize / 2;
  1009.                 if(x > w or y > h) then continue; end
  1010.                 G.surface.DrawRect(x, y, sqsize, sqsize);
  1011.                 G.surface.SetFont("BudgetLabel");
  1012.                 local text = v:Nick().."("..math.Round(dist).."u)";
  1013.                 local w2, h2 = G.surface.GetTextSize(text);
  1014.                 G.surface.SetTextPos(x - w2 / 2, y + 2);
  1015.                 G.surface.DrawText(text);
  1016.             end
  1017.         end
  1018.  
  1019.         local function DrawBG(w, h)
  1020.             local r = 4;
  1021.             local max = 3; -- max - 1
  1022.             local maxfade = 10;
  1023.             local bgcol = Color(57,57,57,250);
  1024.             local col = Color(255,0,0,0);
  1025.             local times = 3;
  1026.             surface.SetDrawColor(bgcol);
  1027.             surface.DrawRect(0, 0, w, h);
  1028.             for i = -((times - 1) / 2), ((times - 1) / 2) do
  1029.                 local mult = math.abs(i) / (times - 1) / 2;
  1030.                 bgcol.a = 250 * mult;
  1031.                 bgcol.r = 57 * mult;
  1032.                 bgcol.g = 57 * mult;
  1033.                 bgcol.b = 57 * mult;
  1034.                 --print(bgcol.a);
  1035.                 surface.SetDrawColor(bgcol);
  1036.                 surface.DrawLine(w / 2 + i, 0, w / 2 + i, h);
  1037.                 surface.DrawLine(0, h / 2 + i, w, h / 2+ i);
  1038.             end
  1039.             DrawCircle(w / 2 - r, h / 2 - r, r, Color(235,25,0,255));
  1040.             surface.SetDrawColor(Color(122,0,0,255));
  1041.             surface.SetTextColor(Color(235, 35, 0, 255));
  1042.             DrawPlayers(w, h, 0.025);
  1043.             for i = 0, max do
  1044.                 col.a = 255 * (i + 1) / (max + 1);
  1045.                 surface.SetDrawColor(col);
  1046.                 surface.DrawOutlinedRect(i, i, w - i * 2, h - i * 2);
  1047.             end
  1048.             for i = max + 1, maxfade do
  1049.                 bgcol.a = 255 * (1 - (i+1) / (maxfade + 1));
  1050.                 surface.SetDrawColor(bgcol);
  1051.                 surface.DrawOutlinedRect(i, i, w - i * 2, h - i * 2);
  1052.             end
  1053.            
  1054.         end
  1055.  
  1056.  
  1057.         dismay.AddHook("HUDPaint", "Radar", function()
  1058.             if(not dismay.ShouldDrawESP()) then print("SDE: "..CurTime()); return; end
  1059.             DrawBG(w, h);
  1060.         end);
  1061.     end);
  1062. end)
  1063.  
  1064. function rG.IsFirstTimePredicted()
  1065.     if(predicting) then
  1066.         return true;
  1067.     end
  1068.     return IsFirstTimePredicted();
  1069. end
  1070.  
  1071. dismay.SpoofFunction(IsFirstTimePredicted, rG.IsFirstTimePredicted);
  1072.  
  1073. function dismay.GetStatusString(l)
  1074.     local l = l or LocalPlayer();
  1075.     local str = tostring(l:Crouching())..tostring(l:IsOnGround())..tostring(l:KeyDown(IN_SPEED))..tostring(l:GetActiveWeapon() and l:GetActiveWeapon().GetIronsights and l:GetActiveWeapon():GetIronsights());
  1076.     return str;
  1077. end
  1078.  
  1079. dismay.runwhenindexcreated("LocalPlayer", function()
  1080.     local player_meta = FindMetaTable("Entity");
  1081.     local weapon_meta = FindMetaTable("Weapon");
  1082.     dismay.Spread = {}
  1083.     local Spread = dismay.Spread;
  1084.     Spread.weapon_pistol    = Vector(-0.01000, -0.01000, -0.01000);
  1085.     Spread.weapon_smg1      = Vector(-0.04362, -0.04362, -0.04362);
  1086.     Spread.weapon_ar2       = Vector(-0.02618, -0.02618, -0.02618);
  1087.     Spread.weapon_shotgun   = Vector(-0.08716, -0.08716, -0.08716);
  1088.  
  1089.     local old_es = player_meta.EmitSound;
  1090.    
  1091.     function player:EmitSound(...)
  1092.         print(CurTime());
  1093.         if(predicting) then return; end
  1094.         return old_es(self, ...);
  1095.     end
  1096.     dismay.SpoofFunction(old_es, player_meta.EmitSound);
  1097.    
  1098.     local old_animate = weapon_meta.SendWeaponAnim;
  1099.     function weapon_meta.SendWeaponAnim(...)    
  1100.         if(predicting) then return; end
  1101.         return old_animate(...);
  1102.     end
  1103.     dismay.SpoofFunction(old_animate, weapon_meta.SendWeaponAnim);
  1104.    
  1105.    
  1106.     local old_fb = player_meta.FireBullets
  1107.     function player_meta:FireBullets(tbl)
  1108.         if(self == LocalPlayer()) then
  1109.             local wep = self:GetActiveWeapon();
  1110.             if(IsValid(self) and IsValid(wep) and not dismay.Spread[wep:GetClass()..dismay.GetStatusString(self)]) then
  1111.                 local c = true;
  1112.                 if(wep and wep.Base) then
  1113.                     local b = wep.Base or "";
  1114.                     if(b == "bobs_gun_base" or b == "bobs_scoped_base" or b == "bobs_shotty_base") then
  1115.                         if(tbl.Spread == Vector(0,0,0)) then
  1116.                             c = false;
  1117.                         end
  1118.                     end
  1119.                 end
  1120.                 if(c) then
  1121.                     dismay.Spread[wep:GetClass()..dismay.GetStatusString()] = -(tbl.Spread or Vector(0,0,0));
  1122.                 end
  1123.             end
  1124.         end
  1125.         if(predicting) then return; end
  1126.         old_fb(self, tbl);
  1127.         if(dismay.FireBullets) then dismay.FireBullets(self, tbl); end
  1128.     end
  1129.     dismay.SpoofFunction(old_fb, player_meta.FireBullets);
  1130. end);
  1131. do
  1132.     function dismay.GetSpread(wep)
  1133.         predicting = true;
  1134.         local x = wep:GetClass()..dismay.GetStatusString();
  1135.         if(not dismay.Spread[x] and IsValid(wep) and wep.CanPrimaryAttack and wep:CanPrimaryAttack() and wep.PrimaryAttack) then
  1136.             wep:PrimaryAttack(true);
  1137.         end
  1138.         predicting = false
  1139.         return dismay.Spread[x] or dismay.Spread[wep:GetClass()] or Vector(0, 0, 0);
  1140.     end
  1141. end
  1142.  
  1143. dismay.private.o_RenderCapture = render.Capture;
  1144.  
  1145. function rG.render.Capture(...)
  1146.     dismay.private.ShouldDrawESP = false;
  1147.     dismay.Repaint();
  1148.     print("RC:"..CurTime());
  1149.     local ret = dismay.private.o_RenderCapture(...);
  1150.     dismay.private.ShouldDrawESP = true;
  1151.     dismay.Repaint();
  1152.     return ret;
  1153. end
  1154.  
  1155. dismay.CurSpeedNum = 0;
  1156. dismay.WasSpeeding = true;
  1157. dismay.SpeedKey = false;
  1158.  
  1159. local function _tc(a)
  1160.     dismay._tc(a, a);
  1161. end
  1162.  
  1163. dismay.AddHook("CreateMove", "Speed", function(cmd)
  1164.     dismay.IsSpeeding = dismay.private.oldg.input.IsKeyDown(dismay.SKey or KEY_G) and dismay.SpeedKey;
  1165.     if(dismay.IsSpeeding) then
  1166.         if(dismay.CurSpeedNum > 0) then
  1167.             dismay.CurSpeedNum = dismay.CurSpeedNum - 1;
  1168.             --_tc(tostring(dismay.CurSpeedNum));
  1169.         else
  1170.             dismay.CurSpeedNum = dismay.SpeedNum;
  1171.         end
  1172.     end
  1173.     dismay.WasSpeeding = dismay.IsSpeeding;
  1174. end);
  1175.  
  1176.  
  1177. dismay.SpoofFunction(dismay.private.o_RenderCapture, render.Capture);
  1178. print("***[C] - Loaded");
  1179. dismay.runwhenindexcreated("FindMetaTable", function()
  1180.     local o = FindMetaTable("Weapon").SetNextPrimaryFire;
  1181.     local w = FindMetaTable("Weapon");
  1182.     dismay.NextPrimaryFire = {};
  1183.     function w:SetNextPrimaryFire(time, ...)
  1184.         dismay.NextPrimaryFire[self] = SysTime() + (time - CurTime()) / 4;
  1185.         return o(self, time, ...);
  1186.     end
  1187.     dismay.SpoofFunction(o, FindMetaTable("Weapon").SetNextPrimaryFire);
  1188.     dismay.RemoveHook("Think", "f");
  1189. end);
  1190.  
  1191. function dismay.GetNextPFire(wep)
  1192.     return dismay.NextPrimaryFire[wep] or 0;
  1193. end
  1194. print("***[C] - LOADING AIMBOAT");
  1195. dismay.runwhenindexcreated("GAMEMODE", function()
  1196.     local GetPred = dismay.GetPred;
  1197.     local IsDormant = dismay.IsDormant;
  1198.     local lp = LocalPlayer();
  1199.  
  1200.     local _R = debug.getregistry();
  1201.  
  1202.     local TraceLine = util.TraceLine;
  1203.  
  1204.     local function IsValidTrace(trace, targ)
  1205.         return not trace.Hit;
  1206.     end
  1207.  
  1208.     local hooks = dismay.AddHook;
  1209.     local sv_gravity    = GetConVar"sv_gravity";
  1210.     local interp_ratio  = GetConVar"cl_interp_ratio";
  1211.     local updaterate    = GetConVar"cl_updaterate";
  1212.     local interp        = GetConVar"cl_interp";
  1213.  
  1214.     local function predict(ply, pos, time)
  1215.         if(dismay.CustomPrediction) then return dismay.CustomPrediction(ply, pos, time); end
  1216.         if(ply ~= LocalPlayer() or not IsValid(ply)) then return pos; end
  1217.         if(not dismay.IsSpeeding) then return pos; end
  1218.         local ent = ply;
  1219.         local i = math.max(interp:GetFloat(), interp_ratio:GetFloat() / updaterate:GetFloat());
  1220.         local vel = ent:GetVelocity();
  1221.         if(ent:IsOnGround()) then
  1222.             vel.z = vel.z - (sv_gravity:GetFloat() * .5 * FrameTime());
  1223.             vel.z = vel.z + (ent:GetVelocity().z * FrameTime());
  1224.         end
  1225.         return pos + vel * (engine.TickInterval() / (dismay.SpeedNum - dismay.CurSpeedNum + 1)) * i;
  1226.     end
  1227.  
  1228.     local function GetSpread(cmd, ang)
  1229.         return dismay.PredSpread(cmd, ang);
  1230.     end
  1231.  
  1232.     local function clamp(ang)
  1233.         ang.p = (ang.p + 180) % 360 - 180
  1234.         ang.y = (ang.y + 180) % 360 - 180
  1235.         return ang;
  1236.     end
  1237.     local ptbl = {
  1238.         endpos  = nil;
  1239.         filter  = {LocalPlayer(), nil};
  1240.         mask    = MASK_SHOT;
  1241.     };
  1242.     local function inbox(pos, mins, maxs)
  1243.         return pos.x >= mins.x and pos.y >= mins.y and pos.z >= mins.z and pos.x <= maxs.x and pos.y <= maxs.y and pos.z <= maxs.z;
  1244.     end
  1245.     local t = {
  1246.         filter = Entity(0);
  1247.         mask = MASK_SHOT;
  1248.     };
  1249.     local function GetBoneHitGroup(pos) -- fag die
  1250.         t.start = pos;
  1251.         t.endpos = pos + Vector(0.1, 0.1, 0.1);
  1252.         return TraceLine(t).HitGroup
  1253.     end
  1254.     local lp = LocalPlayer();
  1255.     local function GetPos(ply, my_pos)
  1256.         if(not IsValid(lp)) then lp = LocalPlayer(); end
  1257.         local bestpos = false
  1258.         ptbl.filter[2] = ply;
  1259.         ptbl.start = predict(lp, my_pos);
  1260.         local p = _R.Entity.GetPos(ply);
  1261.         local mins = _R.Entity.OBBMins(ply) + p;
  1262.         local maxs = _R.Entity.OBBMaxs(ply) + p;
  1263.         local best = 12;
  1264.         for i = 0, _R.Entity.GetBoneCount(ply) and _R.Entity.GetBoneCount(ply) - 1 or -1 do
  1265.             if(not _R.Entity.BoneHasFlag(ply, i, BONE_USED_BY_HITBOX)) then continue; end
  1266.             local pos = _R.Entity.GetBonePosition(ply, i);
  1267.             ptbl.endpos = predict(ply, pos);
  1268.             local trace_r = TraceLine(ptbl);
  1269.             local hg = GetBoneHitGroup(pos);
  1270.             if(hg == 0) then hg = 11; end
  1271.             if(IsValidTrace(trace_r, ply) and inbox(pos, mins, maxs) and hg < best) then
  1272.                 bestpos = pos;
  1273.                 best = hg;
  1274.             end
  1275.         end
  1276.         local peye = _R.Entity.EyeAngles(ply);
  1277.         if(peye.p >= 90 or peye.p <= -90) then --player is antiaiming
  1278.             bestpos = p + ply:OBBCenter();
  1279.         end
  1280.        
  1281.         if(not bestpos) then
  1282.             bestpos = ply:EyePos();
  1283.         end
  1284.        
  1285.         return bestpos;
  1286.     end
  1287.  
  1288.     local frnds = true;
  1289.     function dismay.ToggleFriends(bOn)
  1290.         frnds = bOn;
  1291.     end
  1292.  
  1293.     local teams = false;
  1294.     function dismay.ToggleTeams(bOn)
  1295.         teams = bOn;
  1296.     end
  1297.    
  1298.     local time = CurTime;
  1299.     local ctime = time();
  1300.     local silent = false;
  1301.     local function angdif3d(x, y)
  1302.         return math.abs((x.p - y.p + 180) % 360 - 180) + math.abs((x.y - y.y + 180) % 360 - 180);
  1303.     end
  1304.     local tracet = ptbl;
  1305.     local function CanSee(pos)
  1306.         ptbl.endpos = pos;
  1307.         return util.TraceLine(ptbl).Fraction == 1;
  1308.     end
  1309.     local lastang = Angle(0,0,0);
  1310.     local gav = _R.CUserCmd.GetViewAngles;
  1311.     local sav = _R.CUserCmd.SetViewAngles;
  1312.     local rk = _R.CUserCmd.RemoveKey;
  1313.     local sb = _R.CUserCmd.SetButtons;
  1314.     local gb = _R.CUserCmd.GetButtons;
  1315.     print("***[C] - LOADED AIMBOAT");
  1316.     dismay.LocalPlayer = nil;
  1317. end);
  1318.  
  1319. local function IsValidESP(ply, i)
  1320.     if(not IsValid(ply)) then
  1321.         rem(i);
  1322.         return false;
  1323.     end
  1324.     return true;
  1325. end
  1326. local _col              = Color(255,0,0,255);
  1327. local col_black         = Color(0,0,0,255);
  1328. local SetFont           = surface.SetFont;
  1329. local pairs             = pairs;
  1330. local lp                = LocalPlayer;
  1331. local r                 = debug.getregistry();
  1332. local gp                = r.Entity.GetPos;
  1333. local obbmx             = r.Entity.OBBMaxs;
  1334. local obbms             = r.Entity.OBBMins;
  1335. local toscr             = r.Vector.ToScreen;
  1336. local ScrW              = ScrW();
  1337. local ScrH              = ScrH();
  1338. local ghp               = r.Entity.Health;
  1339. local SetDrawColor      = surface.SetDrawColor;
  1340. local SetTextColor      = surface.SetTextColor;
  1341. local SetTextPos        = surface.SetTextPos;
  1342. local DrawText          = surface.DrawText;
  1343. local DrawOutlinedRect  = surface.DrawOutlinedRect;
  1344. local GetTextSize       = surface.GetTextSize;
  1345. local DrawRect          = surface.DrawRect;
  1346. local min               = math.min;
  1347. local max               = math.max;
  1348. local retcol = Color(0,0,0,255);
  1349.  
  1350. local function HealthToColor(hp)
  1351.     local retcol = Color( 0, 0, 0, 255 )
  1352.     local g = min(max(hp * 2.55, 0), 255);
  1353.     local r = 255 - min(max((hp - 12) * 2.55, 0), 255);
  1354.     retcol.g = g;
  1355.     retcol.r = r;
  1356.     return retcol;
  1357. end
  1358.  
  1359. SetFont("BudgetLabel");
  1360. local _, h = GetTextSize("|ABCDEF");
  1361.  
  1362. local hud = true;
  1363. local view = {
  1364.     x = 0;
  1365.     y = 0;
  1366.     w = ScrW;
  1367.     h = ScrH;
  1368.     dopostprocess = true;
  1369.     drawhud = false;
  1370.     drawviewmodel = true;
  1371. };
  1372.  
  1373. dismay.private.ShouldDrawESP = true;
  1374. local vecs = {
  1375.     Vector();
  1376.     Vector();
  1377.     Vector();
  1378.     Vector();
  1379.     Vector();
  1380.     Vector();
  1381.     Vector();
  1382.     Vector();
  1383. };
  1384. dismay.AddHook("HUDPaint", "ESP", function()
  1385.     if(not hud) then return; end
  1386.     if(not dismay.private.ShouldDrawESP) then
  1387.         view.origin = LocalPlayer():EyePos();
  1388.         view.angles = LocalPlayer():EyeAngles();
  1389.         hud = false;
  1390.         render.RenderView(view);
  1391.         render.RenderHUD(0, 0, ScrW, ScrH);
  1392.         rG.hook.Call("HUDPaint");
  1393.         hud = true;
  1394.         return;
  1395.     end
  1396.     if(dismay.NoESP) then return; end
  1397.     SetFont("BudgetLabel");
  1398.     local col, p, mn, mx, t, mostx, leastx, mosty, leasty, hp, text;
  1399.     t = { nil, nil, nil, nil, nil, nil, nil, nil };
  1400.     for k,v in next, plys do
  1401.         if(v == lp() or not IsValidESP(v, k)) then continue; end
  1402.         p = gp(v);
  1403.         mn = obbms(v)
  1404.         mx = obbmx(v);
  1405.         --[[
  1406.         for i = 1, 8 do
  1407.             local cvec = 1;
  1408.             vecs[i].x = 1;
  1409.         end]]
  1410.         t[1] = toscr(p + mn);
  1411.         t[2] = toscr(p + Vector(mn.x, mx.y, mn.z));
  1412.         t[3] = toscr(p + Vector(mx.x, mx.y, mn.z));
  1413.         t[4] = toscr(p + Vector(mx.x, mn.y, mn.z));
  1414.         t[5] = toscr(p + mx);
  1415.         t[6] = toscr(p + Vector(mx.x, mn.y, mx.z));
  1416.         t[7] = toscr(p + Vector(mn.x, mn.y, mx.z));
  1417.         t[8] = toscr(p + Vector(mn.x, mx.y, mx.z));
  1418.         mostx, leastx, mosty, leasty = 0,ScrW,0,ScrH;
  1419.         for i, cur in ipairs(t) do
  1420.             if(cur.x < leastx) then leastx = cur.x; end
  1421.             if(cur.y < leasty) then leasty = cur.y; end
  1422.             if(cur.x >  mostx) then  mostx = cur.x; end
  1423.             if(cur.y >  mosty) then  mosty = cur.y; end
  1424.         end
  1425.         hp = ghp(v);
  1426.         col = rG.team.GetColor(_R.Player.Team(v));
  1427.         SetDrawColor(col);
  1428.         SetTextColor(col);
  1429.         text = v:Nick();
  1430.         local w = GetTextSize(text);
  1431.         SetTextPos(mostx + 2, leasty);
  1432.         DrawText(text);
  1433.         SetTextPos(mostx + 2, leasty + h + 2);
  1434.         DrawText("H: "..tostring(hp));
  1435.         for i = 1, 2 do
  1436.             DrawOutlinedRect(leastx + i, leasty + i, (mostx - i * 2) - leastx, (mosty - i * 2) - leasty);
  1437.         end
  1438.         SetDrawColor(col_black);
  1439.         DrawOutlinedRect(leastx, leasty, mostx - leastx, mosty - leasty);
  1440.         DrawOutlinedRect(leastx + 3, leasty + 3, (mostx - 3 * 2) - leastx, (mosty - 3 * 2) - leasty);
  1441.         DrawOutlinedRect(leastx - 3, leasty, 4, mosty - leasty);
  1442.        
  1443.         SetDrawColor(HealthToColor(hp));
  1444.         local h = min(100, max(0, hp)) / 100;
  1445.         local rh = mosty - leasty - 2;
  1446.         DrawRect(leastx - 2, leasty + 1 + rh * (1 - h), 2, rh * h);
  1447.     end
  1448. end);
  1449.  
  1450. dismay.AddHook("RenderScene", "fullbright", function(origin, angles, fov)
  1451.     if(not dismay.FullBright) then return; end
  1452.     render.SetLightingMode(2);
  1453.     render.RenderView{
  1454.         origin  = origin;
  1455.         angles  = angles;
  1456.         fov     = fov;
  1457.         x       = 0;
  1458.         y       = 0;
  1459.         w       = ScrW;
  1460.         h       = ScrH;
  1461.         drawhud = false;
  1462.         dopostprocess = true;
  1463.         drawmonitors = true;
  1464.         drawviewmodel = true;
  1465.     };
  1466.     render.SetLightingMode(0);
  1467.     render.RenderHUD(0, 0, ScrW, ScrH);
  1468.     return true;
  1469. end)
  1470. local x = {
  1471.     __index = function() return function() end; end;
  1472.     __newindex = function() end;
  1473. };
  1474. local old_ed = EffectData;
  1475. local old_ue = util.Effect;
  1476.  
  1477. function rG.util.Effect(...)
  1478.     if(predicting) then return; end
  1479.     return old_ue(...);
  1480. end
  1481.  
  1482. dismay.SpoofFunction(old_ue, rG.util.Effect);
  1483.  
  1484. function rG.EffectData(...)
  1485.     if(predicting) then
  1486.         return setmetatable({}, x);
  1487.     end
  1488.     return old_ed(...);
  1489. end
  1490.  
  1491. dismay.SpoofFunction(old_ed, rG.EffectData);
  1492.  
  1493. dismay.HideThisFile(function() end);
  1494.  
  1495. dismay.AddHook("EntityEmitSound", "StopPrediction", function() if(predicting) then return false; end end);
  1496. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement