Guest User

Untitled

a guest
Jun 13th, 2019
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.06 KB | None | 0 0
  1.  
  2. if game.GetIPAddress () == '54.36.226.201:27022' then return end
  3.  
  4. local e_lookup = { -- our lookup table, its defined as `class = {cvar, clr, text}`
  5.     ix_vendingmachine = {
  6.         CreateClientConVar ('hv_show_vendingmachine', 0, true, true, 'Should HelixVision show vending machines?'),
  7.         Color (161,   0, 255),
  8.         'Vending Machine'
  9.     },
  10.     ix_forcefield     = {
  11.         CreateClientConVar ('hv_show_forcefield'    , 0, true, true, 'Should HelixVision show forcefields?'     ),
  12.         Color (  0, 199, 255),
  13.         'Forcefield'
  14.     },
  15.     ix_vendor         = {
  16.         CreateClientConVar ('hv_show_vendor'        , 0, true, true, 'Should HelixVision show vendors?'         ),
  17.         Color (  0, 255,   0),
  18.         function (ent) return ('Vendor: %s'):format (ent:GetDisplayName ()) end
  19.     },
  20.     ix_money          = {
  21.         CreateClientConVar ('hv_show_money'         , 0, true, true, 'Should HelixVision show money?'           ),
  22.         Color (187, 255,   0),
  23.         'Cash'
  24.     },
  25.     ix_item           = {
  26.         CreateClientConVar ('hv_show_item'          , 1, true, true, 'Should HelixVision show items?'           ),
  27.         Color (255,   0,   8),
  28.         function (ent) return ent:GetItemTable ().name end
  29.     },
  30. }
  31.  
  32. hook.Add ('HUDPaint', 'Time2DrawSumCheats', function ()
  33.     local ents = ents.GetAll ()
  34.     for a = 1, ents.GetCount () do -- sequential for loop is faster than pairs, getcount is faster than #
  35.         local ent = ents [a]
  36.  
  37.         local lookup = e_lookup [ent:GetClass ()] -- our lookup table
  38.  
  39.         if not lookup                    then continue end -- if no lookup then we abort
  40.         if     lookup [1]:GetInt () ~= 1 then continue end -- if not activated then we abort
  41.  
  42.         -- draw.DrawText is just a wrapper for surface, we know everything so we can cut to the chase
  43.  
  44.         local pos = ent:GetPos ():ToScreen ()
  45.  
  46.         surface.SetFont 'ChatFont'
  47.  
  48.         local t = lookup [3]
  49.               t = isstring (t) and t or t (ent) -- extra 2 calls but this is for modularity
  50.  
  51.         local w, h = surface.GetTextSize (t)
  52.         local x, y = pos.x - w * 0.5, pos.y - h * 0.5
  53.  
  54.         surface.SetTextPos    (x, y)
  55.         surface.SetTextColour (lookup [2])
  56.  
  57.         surface.DrawText (t)
  58.     end
  59. end)
Advertisement
Add Comment
Please, Sign In to add comment