Advertisement
DrawingJhon

Include Passive Command

Jun 4th, 2023
851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.21 KB | None | 0 0
  1. if pcall(function() return owner.Explode end) then
  2.     error("Disable sandbox to run this script")
  3. end
  4.  
  5. local server = shared.Server
  6. local Settings = server.Settings
  7. local Variables = server.Variables
  8. local Functions = server.Functions
  9. local service = server.Service
  10.  
  11. Variables.PassivePlayers = {}
  12.  
  13. local selfish = true
  14. local notif = false
  15.  
  16. local realGetPlayers = _G.realGetPlayers or Functions.GetPlayers
  17. _G.realGetPlayers = realGetPlayers
  18. Functions.GetPlayers = function(plr, argument, options)
  19.     local list = realGetPlayers(plr, argument, options)
  20.     local passives = Variables.PassivePlayers
  21.     local filteredList = {}
  22.  
  23.     if list and type(list) == "table" then
  24.         for i, v in pairs(list) do
  25.             if plr and v ~= plr and (passives[tostring(v.UserId)] or (not selfish and passives[tostring(plr.UserId)])) then
  26.                 if notif then
  27.                     Functions.Hint(v.Name.." is not targetable if you or they are in passive mode.", {plr})
  28.                 end
  29.             else
  30.                 table.insert(filteredList, v)
  31.             end
  32.         end
  33.     end
  34.  
  35.     return filteredList
  36. end
  37. service.GetPlayers = Functions.GetPlayers
  38.  
  39. server.Commands.TogglePassiveMode = {
  40.     Prefix = Settings.PlayerPrefix;
  41.     Commands = {"passive"};
  42.     Args = {};
  43.     Hidden = false;
  44.     Description = "Toggles passive mode (Prevents players targeting you)";
  45.     Fun = false;
  46.     AdminLevel = "HeadAdmins";
  47.     Function = function(plr, args, data)
  48.         local tab = Variables.PassivePlayers
  49.         local enabled = not tab[tostring(plr.UserId)]
  50.         tab[tostring(plr.UserId)] = enabled
  51.         service.StopLoop("Passive-"..plr.UserId)
  52.         if enabled then
  53.             service.StartLoop("Passive-"..plr.UserId, 2, function()
  54.                 local char = plr.Character
  55.                 if char then
  56.                     local hum = char:findFirstChildOfClass("Humanoid")
  57.                     if hum and (hum.MaxHealth ~= math.huge or hum.Health < 9e9) then
  58.                         hum.MaxHealth = math.huge
  59.                         hum.Health = 9e9
  60.                     end
  61.                     local FFName = "__ADONIS_PASSIVEFF"
  62.                     if not char:findFirstChild(FFName) then
  63.                         service.New("ForceField", {Name = FFName;Visible = false;Parent = char})
  64.                     end
  65.                 end
  66.             end, true)
  67.         end
  68.         Functions.Hint("Passive mode is now "..(enabled and "active" or "inactive"), {plr})
  69.     end
  70. }
  71.  
  72. print("Done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement