SHARE
TWEET

---

a guest Jul 17th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --v1.0.2 BETA
  2. --[[              Lilith`s Admin            ]]
  3. --
  4. --[[          Created by Lilith on 07/05/2019       ]]
  5. --[[     Last modified by Lilith on 07/05/2019      ]]
  6. --[[    Copyright © 2019 Lilith. All rights reserved   ]]
  7.  
  8. --Thanks drifttwo for the split strings function and the commands display idea :)
  9. local function has_value (tab, val) --Oka @ StackOverflow // https://stackoverflow.com/questions/33510736/check-if-array-contains-specific-value
  10.     for index, value in ipairs(tab) do
  11.         if value == val then
  12.             return true
  13.         end
  14.     end
  15.  
  16.     return false
  17. end
  18.  
  19. local split = function(regex, str) --drifttwo
  20.     local tab = {}
  21.     local startt = 1
  22.     local s1, e1 = string.find(str, regex, startt)
  23.     while s1 do
  24.         table.insert(tab, string.sub(str, startt, s1-1))
  25.         startt = e1 + 1
  26.         s1, e1 = string.find(str, regex, startt)
  27.     end
  28.     table.insert(tab, string.sub(str, startt, -1))
  29.     return(tab)
  30. end
  31.  
  32. local function isempty(str) -- StackOverflow, forgot the link where i found it though
  33.     return str == nil or str == ''
  34. end
  35.  
  36. local prefix = ";" --change this to whatever you want, heck, even remove it!
  37. local banlist = {"somebodyyoureallyhate", "anotherpersonyoureallyhate", "yougettheidea"} --perm ban list
  38. local adminlist = {Game:GetOwnerUsername(), "KronextheOrder"}
  39. local joinmessage = false
  40. local serverlock = false
  41.  
  42. commands = [[
  43. ;admin [plr] - Grants [plr] administration access on your server
  44. ;unadmin [plr] - Removes [plr] administration access on your server
  45. ;ban [plr] - Bans [plr] from the current session
  46. ;unban [plr] - Unbans [plr] from the current session
  47. ;kick [plr] [str] - Kicks [plr] and tells them [str] (the string is optional)
  48. ;lock - Locks the server
  49. ;unlock - Unlocks the server
  50. ;shutdown - Shuts the server down
  51. ;announcer - Toggles player joining messages (Enabled by default)
  52. ;broadcast [str] - Broadcasts [str] to the entire server in chat
  53. ;kill [plr] - Kills [plr]
  54. ;damage [plr] [val] - Inflicts [val] damage on [plr]
  55. ;heal [plr] - Heals [plr]
  56. ;god [plr] - Makes [plr] indestructible
  57. ;ungod [plr] - Makes [plr] killable
  58. ;freeze [plr] - Freezes [plr]
  59. ;thaw [plr] - Un-freezes [plr]
  60. ;tp [plr1] [plr2] - Teleports [plr1] to [plr2]
  61. ;goto [plr] - Teleports you to [plr]
  62. ;bring [plr] - Teleports [plr] to you
  63. ;walkspeed [plr] [val] - Sets [plr] walkspeed to [val]
  64. ;clone [plr] - Creates a clone of [plr]
  65.  
  66. ;night- Forces night time on the server
  67. ;day - Forces day time on the server
  68. ;cmds - Displays this help message
  69. ]]
  70.  
  71. Chat.Received:connect(function(player, msg)
  72.     plrname = player.Username
  73.  
  74.     local fired = string.lower(msg) --makes commands not case sensitive
  75.    
  76.     if string.find(fired, prefix) then
  77.         if has_value(adminlist, plrname) then --verify the user has admin
  78.             print("Lilith`s Admin: Prefix + Admin user detected. Player: " .. plrname .. "; Contents: " .. msg)
  79.             --COMMANDS         
  80.    
  81.             if string.find(fired, "ban") then --Only bans the player from the running server, working on a way of adding a pban
  82.                 local array = {}
  83.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  84.        
  85.                 local user = string.lower(array[2])
  86.                 if not isempty(user) then --checks if string is empty
  87.                     if not has_value(adminlist, user) then --checks to make sure the player isnt an admin
  88.                         table.insert(banlist, user)
  89.                         if Players.GetPlayerByUsername(array[2]) then
  90.                             Players.GetPlayerByUsername(array[2]):Kick('You have been banned.')
  91.                         end
  92.                     end
  93.                 end
  94.             end
  95.  
  96.             if string.find(fired, "admin") then
  97.                 local array = {}
  98.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  99.        
  100.                 local user = string.lower(array[2])
  101.                 if not isempty(user) then --checks if string is empty
  102.                     if not has_value(adminlist, user) then --checks to make sure the player isnt already an admin
  103.                         table.insert(adminlist, array[2])
  104.                        
  105.                         Chat.ServerBroadcast(player, "You've been given admin!")
  106.                     end
  107.                 end
  108.             end
  109.  
  110.             if string.find(fired, "unadmin") then
  111.                 local array = {}
  112.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  113.        
  114.                 local user = string.lower(array[2])
  115.                 if not isempty(user) then --checks if string is empty
  116.                     for i,v in pairs(adminlist) do
  117.                                     if v == array[2] then --check if admin was found in table
  118.                                             if not array[2] == Game:GetOwnerUsername() then --make sure not owner owner
  119.                                                     table.remove(adminlist, i) --removes admin from table
  120.                                 break
  121.                                             end
  122.                                     end
  123.                                 end
  124.                 end
  125.             end
  126.  
  127.             if string.find(fired, "unban") then
  128.                 local array = {}
  129.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  130.        
  131.                 local user = string.lower(array[2])
  132.                 if not isempty(user) then --checks if string is empty
  133.                     for i,v in pairs(banlist) do
  134.                                     if v == array[2] then --check if ban was found in table
  135.  
  136.                                                 table.remove(banlist, i) --removes ban from table
  137.                             break
  138.                                     end
  139.                                 end
  140.                 end
  141.             end
  142.  
  143.             if string.find(fired, "kill") then
  144.                 local array = {}
  145.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  146.                
  147.                 local user = string.lower(array[2])
  148.                 local idxplayer = Players.GetPlayerByUsername(array[2])
  149.                 if not isempty(user) then
  150.                     if idxplayer ~= nil then
  151.                         idxplayer.Health = 0
  152.                     end
  153.                 end
  154.             end
  155.  
  156.             if string.find(fired, "god") then
  157.                 local array = {}
  158.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  159.                
  160.                 local user = string.lower(array[2])
  161.                 local idxplayer = Players.GetPlayerByUsername(array[2])
  162.                 if not isempty(user) then
  163.                     if idxplayer ~= nil then
  164.                         idxplayer.MaxHealth = 9999999
  165.                         idxplayer.Health = 9999999
  166.                     end
  167.                 end
  168.             end
  169.  
  170.             if string.find(fired, "ungod") then
  171.                 local array = {}
  172.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  173.                
  174.                 local user = string.lower(array[2])
  175.                 local idxplayer = Players.GetPlayerByUsername(array[2])
  176.                 if not isempty(user) then
  177.                     if idxplayer ~= nil then
  178.                         idxplayer.MaxHealth = 100
  179.                         idxplayer.Health = 100
  180.                     end
  181.                 end
  182.             end
  183.  
  184.             if string.find(fired, "damage") or string.find(fired, "hurt") then
  185.                 local array = {}
  186.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  187.                
  188.                 local user = string.lower(array[2])
  189.                 local damage = tonumber(array[3])
  190.                 local idxplayer = Players.GetPlayerByUsername(array[2])
  191.                 if not isempty(user) then
  192.                     if damage ~= nil then
  193.                         if idxplayer ~= nil then
  194.                             idxplayer.Health = idxplayer.Health - damage
  195.                         end
  196.                     end
  197.                 end
  198.             end
  199.  
  200.             if string.find(fired, "heal") then
  201.                 local array = {}
  202.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  203.                
  204.                 local user = string.lower(array[2])
  205.                 local idxplayer = Players.GetPlayerByUsername(array[2])
  206.                 if not isempty(user) then
  207.                     if idxplayer ~= nil then
  208.                         currentmaxhealth = idxplayer.MaxHealth
  209.                         idxplayer.Health = currentmaxhealth
  210.                     end
  211.                 end
  212.             end
  213.  
  214.             if string.find(fired, "walkspeed") or string.find(fired, "speed") then
  215.                 local array = {}
  216.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  217.  
  218.                 local user = string.lower(array[2])
  219.                 local idxplayer = Players.GetPlayerByUsername(array[2])
  220.                 if not isempty(user) then
  221.                     if idxplayer ~= nil then
  222.                         idxplayer.WalkSpeed = tonumber(array[3])
  223.                     end
  224.                 end
  225.             end
  226.  
  227.             if string.find(fired, "freeze") then
  228.                 local array = {}
  229.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  230.  
  231.                 local user = string.lower(array[2])
  232.                 local idxplayer = Players.GetPlayerByUsername(array[2])
  233.                 if not isempty(user) then
  234.                     if idxplayer ~= nil then
  235.                         idxplayer.WalkSpeed = 0
  236.                     end
  237.                 end
  238.             end
  239.  
  240.             if string.find(fired, "thaw") or string.find(fired, "unfreeze") then
  241.                 local array = {}
  242.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  243.  
  244.                 local user = string.lower(array[2])
  245.                 local idxplayer = Players.GetPlayerByUsername(array[2])
  246.                 if not isempty(user) then
  247.                     if idxplayer ~= nil then
  248.                         idxplayer.WalkSpeed = 1
  249.                     end
  250.                 end
  251.             end
  252.  
  253.             if string.find(fired, "tp") or string.find(fired, "teleport") then
  254.                 local array = {}
  255.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  256.                 local user1 = string.lower(array[2])
  257.                 local user2 = string.lower(array[3])
  258.                 local idxplayer1 = Players.GetPlayerByUsername(array[2])
  259.                 local idxplayer2 = Players.GetPlayerByUsername(array[3])
  260.                 if not isempty(user1) then
  261.                     if not isempty(user2) then
  262.                         if idxplayer1 ~= nil then
  263.                             if idxplayer2 ~= nil then
  264.                                 idxplayer1:MoveTo(idxplayer2.Position + Vector3.new(0, 1, 0))
  265.                             end
  266.                         end
  267.                     end
  268.                 end
  269.             end
  270.            
  271.             if string.find(fired, "goto") or string.find(fired, "to") then
  272.                 local array = {}
  273.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  274.                 local user2 = string.lower(array[2])
  275.                 local idxplayer1 = Players.GetPlayerByUsername(plrname)
  276.                 local idxplayer2 = Players.GetPlayerByUsername(array[2])
  277.                 if not isempty(user2) then
  278.                     if idxplayer1 ~= nil then
  279.                         if idxplayer2 ~= nil then
  280.                             idxplayer1:MoveTo(idxplayer2.Position + Vector3.new(0, 1, 0))
  281.                         end
  282.                     end
  283.                 end
  284.             end
  285.  
  286.             if string.find(fired, "cmds") or string.find(fired, "help") then
  287.                         local commands1 = string.sub(commands, 1, 991)
  288.                             local commands2 = string.sub(commands, 992, 1991)
  289.  
  290.                             Chat.ServerBroadcast(player, commands1)
  291.                             Chat.ServerBroadcast(player, commands2)
  292.             end
  293.  
  294.             if string.find(fired, "kick") then
  295.                 local array = {}
  296.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  297.                 local user = string.lower(array[2])
  298.                 local idxplayer = Players.GetPlayerByUsername(array[2])
  299.                 if not isempty(user) then
  300.                     if idxplayer ~= nil then
  301.                         if idxplayer.Username ~= nil then
  302.                             if idxplayer.Username~= Game:GetOwnerUsername() then  --temporary solution for this check
  303.                                 local kickreason = split(idxplayer.Username, msg)
  304.                                 idxplayer:Kick(kickreason[2])
  305.                             end
  306.                         end
  307.                     end
  308.                 end
  309.             end
  310.  
  311.             if string.find(fired, "clone") then
  312.                 local array = {}
  313.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  314.                 local user = string.lower(array[2])
  315.                 local idxplayer = Players.GetPlayerByUsername(array[2])
  316.                 if not isempty(user) then
  317.                     if idxplayer ~= nil then
  318.                         lilithadminclone = idxplayer:Clone()
  319.                     end
  320.                 end
  321.             end
  322.  
  323.             if string.find(fired, "bring") then
  324.                 local array = {}
  325.                 for word in fired:gmatch("%w+") do table.insert(array, word) end
  326.                 local user1 = string.lower(array[2])
  327.                 local idxplayer1 = Players.GetPlayerByUsername(array[2])
  328.                 local idxplayer2 = Players.GetPlayerByUsername(plrname)
  329.                 if not isempty(user2) then
  330.                     if idxplayer1 ~= nil then
  331.                         if idxplayer2 ~= nil then
  332.                             idxplayer1:MoveTo(idxplayer2.Position + Vector3.new(0, 1, 0))
  333.                         end
  334.                     end
  335.                 end
  336.             end
  337.  
  338.  
  339.             if string.find(fired, "shutdown") then
  340.                 for _,v in ipairs(Players.GetPlayers()) do
  341.                     v:Kick("Server shutdown.")
  342.                 end
  343.             end
  344.  
  345.             if string.find(fired, "broadcast") then --Still pretty buggy, thanks Xenight for some help with grabbing the message
  346.                         local array = split("broadcast", msg) --not using fired global because its lowercased
  347.  
  348.                             Chat.ServerBroadcastAll(array[2])
  349.                          --Chat:ServerBroadcastAll(array[2])
  350.                     end
  351.  
  352.            
  353.             if string.find(fired, "day") then
  354.                 Scenery.Skybox = 0
  355.             end
  356.  
  357.             if string.find(fired, "night") then
  358.                 Scenery.Skybox = 3
  359.             end
  360.  
  361.             if string.find(fired, "announcer") then
  362.                 joinmessage = not joinmessage --flips toggle, pretty simple
  363.             end
  364.  
  365.             if string.find(fired, "lock") then
  366.                 serverlock = true
  367.             end
  368.  
  369.             if string.find(fired, "unlock") then
  370.                 serverlock = false
  371.             end
  372.         else
  373.             Chat.ServerBroadcast(player, "You don't have admin!")
  374.         end
  375.     end
  376. end)
  377.  
  378. --[Players.PlayerLeft:connect(function(plr)
  379. --  if joinmessage then
  380. --      local message = plr.username .. " has dipped!" --Edit this if you want to change the player disconnect message (idea from drifttwo)
  381. --      Chat.ServerBroadcastAll(message)
  382. --  end
  383. --end)
  384.  
  385. Players.PlayerJoined:connect(function(plr)
  386.     if serverlock then
  387.         plr:Kick("The server has been locked by Lilith's Admin") --Checks for server lock, disabled by default
  388.     end
  389.     if has_value(banlist, plr.username) then
  390.         plr:Kick("You're currently banned from the game.") --Edit this to change the ban message
  391.     end
  392.     if joinmessage then
  393.         if has_value(adminlist, plr.username) then
  394.            
  395.             local message = "Administrator: " .. plr.username .. " has joined the party! A1"
  396.             Chat.ServerBroadcastAll(message)
  397.         else
  398.             local message = plr.username .. " has joined the party!" --Edit this if you want to change the player connect message (idea from drifttwo)
  399.             Chat.ServerBroadcastAll(message)
  400.         end
  401.     end
  402. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top