Advertisement
Zaktak

Zaktak's Anti Fire Lag

Apr 24th, 2020
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. --[[
  2. How to add this? either create an addon folder in /addons/custom_name/lua/autorun/server/..
  3. Or in lua/autorun/server/
  4. Also, Edit maxFires for whatever number u feel :P
  5. This should not do any lag as it runs on creation of entities and aborts immediatly if not fire entities.
  6. Script made by Zaktak ;)
  7. Please note I made this very fast and it's very "early stage".
  8. --]]
  9.  
  10. ZKFireAntiLag = ZKFireAntiLag or {}
  11. ZKFireAntiLag.config = ZKFireAntiLag.config or {}
  12.  
  13. ZKFireAntiLag.config.maxFires = 40 -- Max fires, would extinguish when reached.
  14.  
  15. function checkFire()
  16.     local f = 0
  17.     for k, v in pairs(ents.FindByClass("vfire")) do -- Find vFire entities.
  18.         f = f + 1 -- Count them up
  19.     end
  20.     return f -- Return amount of fires
  21. end
  22.  
  23. hook.Add("OnEntityCreated", "ZK_CheckEntforFire", function(ent) -- Hook is called on creation of Entity, so pretty much we want on fire creation and fire spread.
  24.     if (!vFireInstalled) then return end -- If vFire isn't installed, abort.
  25.     if (ent:GetClass() == "vfire") then -- If it's a vFire entity continue. If not, nothing will happen.
  26.         if (checkFire() > ZKFireAntiLag.config.maxFires) then -- If amount of fires is bigger then set max
  27.             local fires = 0
  28.             for k, v in pairs(ents.FindByClass("vfire")) do
  29.                 v:Remove() -- Remove fires
  30.                 fires = fires + 1 -- Count them
  31.             end
  32.             ServerLog("[ZAL]: Automatically extinguished ".. fires .. " Fires \n") -- Log it to the server.
  33.             fires = 0
  34.         end
  35.     end
  36. end)
  37.  
  38. if (vFireInstalled) then -- Please don't remove these lines? author's credit?
  39.     local version = "v1.01"
  40.     print("")
  41.     print("<<<===================================================>>>")
  42.     print("         Zaktak's Anti Fire Lag Running: ".. version)
  43.     print("<<<===================================================>>>")
  44.     print("")
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement