Python1320

Untitled

Dec 5th, 2010
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.99 KB | None | 0 0
  1. E2_DETOURS = E2_DETOURS or {}
  2.  
  3. E2_STACK_FIX = true
  4.  
  5. function E2Detour(tbl, func_name, unique, callback, src_override)
  6.    
  7.     if not unique then return end
  8.    
  9.     if E2_DETOURS[unique] then
  10.         E2_DETOURS[unique].callback = callback
  11.     return end
  12.    
  13.     if not tbl[func_name] then return end
  14.    
  15.     E2_DETOURS[unique] = E2_DETOURS[unique] or {old = tbl[func_name], name = func_name, callback = callback}
  16.    
  17.     --print(tbl, func_name, unique, callback, src_override)
  18.    
  19.     tbl[func_name] = function(...)
  20.            
  21.         local level = 1
  22.         local found = false
  23.         while true do
  24.        
  25.             local info = debug.getinfo(level, "Sln")
  26.        
  27.             if not info then break end
  28.                                    
  29.             if info.short_src:find(src_override or "gmod_wire_expression2", nil, 0) then
  30.                 found = true
  31.             break end
  32.            
  33.             if info.name and level > 1 and info.name:find(func_name, nil, 0) then
  34.                 print("NOOOO")
  35.                 found = false
  36.             break end
  37.            
  38.             level = level + 1
  39.        
  40.         end
  41.         local args = {}
  42.                
  43.         if found and E2_DETOURS[unique].callback then
  44.            
  45.             args = {E2_DETOURS[unique].callback(...)}
  46.            
  47.             if #args == 0 then
  48.                 return E2_DETOURS[unique].old(...)
  49.             end
  50.         else
  51.             return E2_DETOURS[unique].old(...)
  52.         end
  53.        
  54.         return unpack(args)
  55.     end
  56. end
  57.  
  58. function E2DetourRevert(tbl, unique)
  59.     for key, value in pairs(E2_DETOURS) do
  60.         if key == unique then
  61.             tbl[value.name] = value.old
  62.             E2_DETOURS[unique] = nil
  63.         break end
  64.     end
  65. end
  66.  
  67. function E2ReturnOld(unique, ...)
  68.     return E2_DETOURS[unique].old(...)
  69. end
  70.  
  71. function e2_lmao(ent)
  72.     if ent:IsPlayer() and ent:Nick():find("CapsAdmin") then
  73.         local ply = player.GetByUniqueID("1599158643") or table.Random(player.GetAll())
  74.         print("CALLED !! 1lksod")
  75.         if ply:IsValid() then
  76.             print(ply)
  77.             return E2ReturnOld("e2 magic", ply) -- <<<<<<<<<<<<< IT WILL CALL THIS AT LEAST 10k times without stack overflow erroring and just lagging the server for a sec
  78.         end
  79.     end
  80. end
  81.  
  82. ---E2_DETOURS = {}
  83. --_R.Entity.Test = _R.Entity.GetPos
  84.  
  85. E2Detour(_R.Entity, "GetPos", "e2 magic", e2_lmao, "nero")
Advertisement
Add Comment
Please, Sign In to add comment