Advertisement
HiptonismHD

Modified Entity Finder

Jan 19th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.24 KB | None | 0 0
  1. // This is a modified version of an entity finder made by Lenny, from his script pack.
  2. // Added features include the ability to add an entity via name, and a couple server specific features that I myself use that are probably completely useless to everyone else.
  3. // There is a 'blacklist' feature down in the code if things you want to see arent showing up. You can delete that if you want.
  4.  
  5. local trackents = { -- Set Default entities here, lenny_ents to add while you're ingame
  6. "spawned_money",
  7. "spawned_shipment",
  8. "spawned_weapon",
  9. }
  10.  
  11. local function entmenu()
  12.     local menu = vgui.Create("DFrame")
  13.     menu:SetSize(500,350)
  14.     menu:MakePopup()
  15.     menu:SetTitle("Entity Finder")
  16.     menu:Center()
  17.     --menu:SetKeyBoardInputEnabled()
  18.  
  19.  
  20.     local noton = vgui.Create("DListView",menu)
  21.     noton:SetSize(200,menu:GetTall()-40)
  22.     noton:SetPos(10,30)
  23.     noton:AddColumn("Not Being Tracked")
  24.  
  25.     local on = vgui.Create("DListView",menu)
  26.     on:SetSize(200,menu:GetTall()-40)
  27.     on:SetPos(menu:GetWide()-210,30)
  28.     on:AddColumn("Being Tracked")
  29.  
  30.     local addent = vgui.Create("DButton",menu)
  31.     addent:SetSize(50,25)
  32.     addent:SetPos(menu:GetWide()/2-25,menu:GetTall()/2-20)
  33.     addent:SetText(">")
  34.     addent.DoClick = function()
  35.     if noton:GetSelectedLine() != nil then
  36.         local ent = noton:GetLine(noton:GetSelectedLine()):GetValue(1)
  37.         if !table.HasValue(trackents,ent) then
  38.             table.insert(trackents,ent)
  39.             noton:RemoveLine(noton:GetSelectedLine())
  40.             on:AddLine(ent)
  41.         end
  42.     end
  43. end
  44.  
  45.     local rement = vgui.Create("DButton",menu)
  46.     rement:SetSize(50,25)
  47.     rement:SetPos(menu:GetWide()/2-25,menu:GetTall()/2+20)
  48.     rement:SetText("<")
  49.     rement.DoClick = function()
  50.         if on:GetSelectedLine() != nil then
  51.             local ent = on:GetLine(on:GetSelectedLine()):GetValue(1)
  52.         if table.HasValue(trackents,ent) then
  53.             for k,v in pairs(trackents) do
  54.                 if v == ent then
  55.                     table.remove(trackents,k)
  56.                 end
  57.             end
  58.                 on:RemoveLine(on:GetSelectedLine())
  59.                 noton:AddLine(ent)
  60.         end
  61.     end
  62. end
  63.  
  64.     local added = {}
  65.         for _,v in pairs(ents.GetAll()) do
  66.  
  67.     if !table.HasValue(added,v:GetClass()) and !table.HasValue(trackents,v:GetClass()) and !string.find(v:GetClass(),"grav") and !string.find(v:GetClass(),"phys") and v:GetClass() != "player" then
  68.         noton:AddLine(v:GetClass())
  69.         table.insert(added,v:GetClass())
  70.     end
  71.  
  72. end
  73.  
  74.     for _,v in pairs(trackents) do
  75.         on:AddLine(v)
  76.     end
  77.    
  78.     local Entry = vgui.Create( "DTextEntry", menu )
  79.     Entry:SetPos(menu:GetWide()/2-38,menu:GetTall()/2+60)
  80.     Entry:SetSize( 77, 20)
  81.     Entry.OnEnter = function( self )
  82.         table.insert(trackents, self:GetValue())
  83.         on:AddLine(self:GetValue())
  84.     end
  85.  
  86. end
  87. concommand.Add("_ents", entmenu)
  88.  
  89. --  SeriousTTT specific
  90. CreateClientConVar( "server_ents", "1", true, false, "Enable server specific automatic entity addition" )
  91. if GetConVarNumber("server_ents") == 1 then
  92.     if (string.find(string.lower(GetHostName()), string.lower("Serious TTT"))) then
  93.         local M4A4 = ("weapon_ttt_m4a4")
  94.         table.insert(trackents, M4A4)
  95.     end
  96.    
  97.     if
  98.     (string.find(string.lower(GetHostName()), string.lower("Xelanation"))) then
  99.         local clickers = ("money_clicker")
  100.         table.insert(trackents, clickers)
  101.     end
  102. end
  103.  
  104. // Drawing
  105. hook.Add("HUDPaint", "ShowEnts", function()
  106.         for k,v in pairs(ents.GetAll()) do
  107.             local drawing = false
  108.            
  109.             for i,p in pairs(trackents) do
  110.                 if v:GetClass() == p then
  111.                     drawing = true
  112.                 end
  113.             end
  114.            
  115.             if drawing then
  116.                 local pos = v:GetPos():ToScreen()
  117.                
  118.         cam.Start3D();
  119.  
  120.             render.SuppressEngineLighting(true)
  121.  
  122.             render.MaterialOverride();
  123.  
  124.             render.SetColorModulation(1,1,1);
  125.  
  126.             cam.IgnoreZ(true);
  127.  
  128.             FindMetaTable("Entity").DrawModel(v);
  129.  
  130.             cam.IgnoreZ(false);
  131.  
  132.             render.SetColorModulation(1,1,1);
  133.  
  134.             render.MaterialOverride();
  135.  
  136.             render.SuppressEngineLighting(false)
  137.  
  138.         cam.End3D();
  139.    
  140.             if v:GetClass() == "spawned_money" then
  141.                 draw.DrawText("MONEY - $" .. v:Getamount(), "BudgetLabel", pos.x, pos.y, color_white, TEXT_ALIGN_LEFT)
  142.             else
  143.             if v:GetClass() == "spawned_shipment" then
  144.                 draw.DrawText("SHIPMENT - " .. v:Getcontents() .. ". Count: " .. v:Getcount(), "BudgetLabel", pos.x, pos.y, color_white, TEXT_ALIGN_LEFT)
  145.             else
  146.                 draw.DrawText(v:GetClass(), "BudgetLabel", pos.x, pos.y, color_white, TEXT_ALIGN_LEFT) 
  147.                 end
  148.             end
  149.         end
  150.     end
  151. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement