XaskeL

Untitled

Jul 22nd, 2019
120
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local middleclass = loadstring(exports.shared:modules('shared.middleclass'))()
  2.  
  3. local NPCBase = middleclass.class('NPCBase')
  4. NPCBase.alive = {}
  5.  
  6. function NPCBase:initialize(params)
  7.     self.params = params;
  8. end
  9.  
  10. function NPCBase:setHealth(n)
  11.     self.params.health = n;
  12. end
  13.  
  14. function table.findIn(t, In, value)
  15.     if type( t ) ~= 'table' then
  16.         error( 'Bad argument #1, got ' .. type( t ), 2 )
  17.     end
  18.     if In == nil then
  19.         error( 'Bad argument #2, got nil', 2 )
  20.     end
  21.     for i, data in pairs( t ) do
  22.         if data[In] == value then
  23.             return i, data
  24.         end
  25.     end
  26.     return false
  27. end
  28.  
  29. function NPCBase:destroy()
  30.     local i, data = table.findIn(NPCBase.alive, 'table', self.id)
  31.     return table.remove(NPCBase.alive, i)
  32. end
  33.  
  34. for i = 1, 1000000 do
  35.     local bot = NPCBase:new({id=i;type="zombie";health=100;skin=0});
  36.     table.insert(NPCBase.alive, bot)
  37.     bot:destroy()
  38. end
  39.  
  40. collectgarbage()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×