ForeverDev

Untitled

Oct 25th, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.19 KB | None | 0 0
  1. local data = game:GetService("DataStoreService"):GetDataStore("ForeverDevAdmin" .. game.Name)
  2.  
  3. local admins = {
  4.     ["-1"] = 3,
  5.     ["1210210"] = 3
  6. }
  7.  
  8. local each = function(array, callback)
  9.     for index, value in pairs(array) do
  10.         callback(index, value)
  11.     end
  12. end
  13.  
  14. local attr = function(object, property, value)
  15.     if type(property) == "table" then
  16.         for key, set in pairs(property) do
  17.             object[key] = set
  18.         end
  19.     else
  20.         object[property] = value
  21.     end
  22. end
  23.  
  24. local removeElement = function(array, element)
  25.     for index, value in ipairs(array) do
  26.         if value == element then
  27.             table.remove(array, index)
  28.             break
  29.         end
  30.     end
  31.     return array
  32. end
  33.  
  34. local findElement = function(array, element)
  35.     for index, value in ipairs(array) do
  36.         if value == element then
  37.             return true
  38.         end
  39.     end
  40.     return false
  41. end
  42.  
  43. local alert;
  44. alert = function(player, receiver, message, isMsg)
  45.     local sgui = Instance.new("ScreenGui", receiver.PlayerGui)
  46.     local frame = Instance.new("Frame", sgui)
  47.     local title = Instance.new("TextLabel", frame)
  48.     local body = Instance.new("TextLabel", frame)
  49.     local ignore = Instance.new("TextButton", frame)
  50.     local submit, reply;
  51.     if not isMsg then
  52.         submit = Instance.new("TextButton", frame)
  53.         reply = Instance.new("TextBox", frame)
  54.     end
  55.     attr(frame, {
  56.         Size = UDim2.new(0, 400, 0, 250),
  57.         Position = UDim2.new(0.5, -200, 0, -250),
  58.         ZIndex = 8
  59.     })
  60.     attr(title, {
  61.         Size = UDim2.new(1, 0, 0, 50),
  62.         Text = (isMsg and "Message" or "PM") .. " from " .. player.Name,
  63.         TextColor3 = Color3.new(1, 1, 1),
  64.         TextStrokeTransparency = 0,
  65.         TextWrapped = true,
  66.         FontSize = Enum.FontSize.Size18,
  67.         ZIndex = 9
  68.     })
  69.     attr(body, {
  70.         Size = UDim2.new(1, 0, 1, -110),
  71.         Position = UDim2.new(0, 0, 0, 60),
  72.         Text = message,
  73.         TextColor3 = Color3.new(1, 1, 1),
  74.         TextWrapped = true,
  75.         TextYAlignment = Enum.TextYAlignment.Top,
  76.         TextStrokeTransparency = 0,
  77.         FontSize = Enum.FontSize.Size14,
  78.         BorderSizePixel = 0,
  79.         ZIndex = 9
  80.     })
  81.     attr(ignore, {
  82.         Size = UDim2.new(0, 50, 0, 50),
  83.         Position = UDim2.new(0, 0, 1, -50),
  84.         Text = "Close",
  85.         TextColor3 = Color3.new(1, 0, 0),
  86.         FontSize = Enum.FontSize.Size12,
  87.         ZIndex = 10
  88.     })
  89.     if not isMsg then
  90.         attr(submit, {
  91.             Size = UDim2.new(0, 50, 0, 50),
  92.             Position = UDim2.new(0, 50, 1, -50),
  93.             Text = "Reply",
  94.             TextColor3 = Color3.new(0, 1, 0),
  95.             FontSize = Enum.FontSize.Size12,
  96.             ZIndex = 10
  97.         })
  98.         attr(reply, {
  99.             Size = UDim2.new(1, -100, 0, 50),
  100.             Position = UDim2.new(0, 100, 1, -50),
  101.             Text = "Type what you want to reply here.",
  102.             TextColor3 = Color3.new(0, 1, 0),
  103.             FontSize = Enum.FontSize.Size12,
  104.             ZIndex = 10
  105.         })
  106.         submit.MouseButton1Down:connect(function()
  107.             frame:TweenPosition(
  108.                 UDim2.new(0.5, -200, 0, -250),
  109.                 Enum.EasingDirection.Out,
  110.                 Enum.EasingStyle.Quad,
  111.                 1
  112.             )
  113.             game.Debris:AddItem(sgui, 3)
  114.             alert(receiver, player, reply.Text)
  115.         end)
  116.     end
  117.     ignore.MouseButton1Down:connect(function()
  118.         frame:TweenPosition(
  119.             UDim2.new(0.5, -200, 0, -250),
  120.             Enum.EasingDirection.Out,
  121.             Enum.EasingStyle.Quad,
  122.             1
  123.         )
  124.         game.Debris:AddItem(sgui, 3)
  125.     end)
  126.     frame:TweenPosition(
  127.         UDim2.new(0.5, -200, 0.5, -125),
  128.         Enum.EasingDirection.Out,
  129.         Enum.EasingStyle.Back,
  130.         1
  131.     )
  132. end
  133.  
  134. local target = function(targ, speaker)
  135.     if targ:lower() == "all" then
  136.         return game.Players:GetPlayers()
  137.     elseif targ:lower() == "others" then
  138.         return removeElement(game.Players:GetPlayers(), speaker)
  139.     elseif targ:lower() == "me" then
  140.         return {speaker}
  141.     elseif targ:find(",") then
  142.         local people = {}
  143.         targ:gsub("(%a+)", function(catch)
  144.             table.insert(people, catch)
  145.         end)
  146.         local players = {}
  147.         each(game.Players:GetPlayers(), function(_, this)
  148.             each(people, function(_, name)
  149.                 if this.Name:lower():sub(1, name:len()) == name:lower() then
  150.                     table.insert(players, this)
  151.                 end
  152.             end)
  153.         end)
  154.         return players
  155.     else
  156.         local people;
  157.         each(game.Players:GetPlayers(), function(_, this)
  158.             if this.Name:lower():sub(1, targ:len()) == targ:lower() then
  159.                 people = {this}
  160.             end
  161.         end)
  162.         return people or {}
  163.     end
  164. end
  165.  
  166. local chat = function(message, speaker)
  167.     if admins[tostring(speaker.userId)] and message:sub(1, 1) == "#" then
  168.         local words = {}
  169.         message:gsub("([%a%d,]+)", function(catch)
  170.             table.insert(words, catch:lower())
  171.         end)
  172.         if owner[words[1]] or perm[words[1]] or temp[words[1]] then
  173.             local success;
  174.             local level = admins[tostring(speaker.userId)]
  175.             repeat
  176.                 local stringLevel = level == 3 and "owner" or level == 2 and "perm" or level == 1 and "temp" or "false"
  177.                 if getfenv()[stringLevel][words[1]] then
  178.                     success = getfenv()[stringLevel][words[1]](speaker, message, words)
  179.                 end
  180.                 level = level - 1
  181.             until success or level == 0
  182.         end
  183.     end
  184. end
  185.    
  186. game.Players.PlayerAdded:connect(function(player)
  187.     local bans = data:GetAsync("banList")
  188.     if findElement(bans, player.Name) then
  189.         player:Kick()
  190.     end
  191.     player.Chatted:connect(function(message)
  192.         chat(message, player)
  193.     end)
  194. end)
  195.  
  196. local commands = {}
  197. local meta = {
  198.     __newindex = function(this, key, value)
  199.         rawset(this, key, value)
  200.         table.insert(commands, {key, this.level})
  201.     end
  202. }
  203.  
  204. owner, perm, temp = setmetatable({level = "3"}, meta), setmetatable({level = "2"}, meta), setmetatable({level = "1"}, meta)
  205.  
  206. owner.ban = function(speaker, message, words)
  207.     each(target(words[2], speaker), function(_, this)
  208.         if this ~= speaker then
  209.             local bans = data:GetAsync("banList")
  210.             if not findElement(bans, this.Name:lower()) then
  211.                 data:UpdateAsync("banList", function(current)
  212.                     table.insert(current, this.Name:lower())
  213.                     return current
  214.                 end)
  215.                 this:Kick()
  216.             end
  217.         end
  218.     end)
  219. end
  220.  
  221. owner.unban = function(speaker, message, words)
  222.     local target = message:match("%s.+"):gsub("%s+", "")
  223.     local bans = data:GetAsync("banList")
  224.     if findElement(bans, target:lower()) then
  225.         data:UpdateAsync("banList", function(current)
  226.             removeElement(current, target:lower())
  227.             return current
  228.         end)
  229.     end
  230. end
  231.  
  232. owner.kick = function(speaker, message, words)
  233.     each(target(words[2], speaker), function(_, this)
  234.         this:Kick()
  235.     end)
  236.     return 1
  237. end
  238.  
  239. owner.perm = function(speaker, message, words)
  240.     each(target(words[2], speaker), function(_, this)
  241.         if this ~= speaker then
  242.             admins[tostring(this.userId)] = 2
  243.         end
  244.         print(admins[tostring(this.userId)])
  245.     end)
  246.     return 1
  247. end
  248.  
  249. owner.temp = function(speaker, message, words)
  250.     each(target(words[2], speaker), function(_, this)
  251.         if this ~= speaker then
  252.             admins[tostring(this.userId)] = 1
  253.         end
  254.     end)
  255.     return 1
  256. end
  257.  
  258. owner.unadmin = function(speaker, message, words)
  259.     each(target(words[2], speaker), function(_, this)
  260.         if this.Name == speaker.Name then
  261.             return
  262.         end
  263.         if admins[tostring(this.userId)] then
  264.             if admins[tostring(this.userId)] < 3 then
  265.                 admins[tostring(this.userId)] = false
  266.             end
  267.         end
  268.     end)
  269.     return 1
  270. end
  271.  
  272. owner.script = function(speaker, message, words)
  273.     pcall(function()
  274.         if game.ServerScriptService.LoadStringEnabled then
  275.             loadstring(message:sub(message:find("script") + 7))()
  276.         end
  277.     end)
  278.     return 1
  279. end
  280.  
  281. perm.kill = function(speaker, message, words)
  282.     each(target(words[2], speaker), function(_, this)
  283.         if this.Character then
  284.             this.Character:BreakJoints()
  285.         end
  286.     end)
  287.     return 1
  288. end
  289.  
  290. perm.loopkill = function(speaker, message, words)
  291.     each(target(words[2], speaker), function(_, this)
  292.         if not this:FindFirstChild("Loopkill") then
  293.             Instance.new("BoolValue", this).Name = "Loopkill"
  294.             local event;
  295.             coroutine.wrap(function()
  296.                 event = this.CharacterAdded:connect(function(character)
  297.                     wait()
  298.                     character:BreakJoints()
  299.                 end)
  300.                 this.Character:BreakJoints()
  301.                 while wait(1) do
  302.                     if not this:FindFirstChild("Loopkill") then
  303.                         event:disconnect()
  304.                         break
  305.                     end
  306.                 end
  307.                 coroutine.yield()
  308.             end)()
  309.         end
  310.     end)
  311.     return 1
  312. end
  313.  
  314. perm.unloopkill = function(speaker, message, words)
  315.     each(target(words[2], speaker), function(_, this)
  316.         if this:FindFirstChild("Loopkill") then
  317.             this.Loopkill:Destroy()
  318.         end
  319.     end)
  320.     return 1
  321. end
  322.  
  323. perm.punish = function(speaker, message, words)
  324.     each(target(words[2], speaker), function(_, this)
  325.         this.Character:Destroy()
  326.     end)
  327.     return 1
  328. end
  329.  
  330. perm.unpunish = function(speaker, message, words)
  331.     each(target(words[2], speaker), function(_, this)
  332.         if not Workspace:FindFirstChild(this.Name) then
  333.             this:LoadCharacter()
  334.         end
  335.     end)
  336.     return 1
  337. end
  338.  
  339. temp.pm = function(speaker, message, words)
  340.     each(target(words[2], speaker), function(_, this)
  341.         alert(speaker, this, message:sub(message:find(words[2]) + (words[2]:len() + 1)))
  342.     end)
  343.     return 1
  344. end
  345.  
  346. temp.m = function(speaker, message, words)
  347.     each(game.Players:GetPlayers(), function(_, this)
  348.         alert(speaker, this, message:sub(4), true)
  349.     end)
  350.     return 1
  351. end
  352.  
  353. temp.commands = function(speaker)
  354.     local sgui = Instance.new("ScreenGui", speaker.PlayerGui)
  355.     local frame = Instance.new("Frame", sgui)
  356.     local search = Instance.new("TextBox", frame)
  357.     local results = Instance.new("ScrollingFrame", frame)
  358.     local close = Instance.new("TextButton", frame)
  359.     local h1 = Instance.new("TextLabel", results)
  360.     local h2 = Instance.new("TextLabel", results)
  361.     attr(frame, {
  362.         Size = UDim2.new(0, 226, 0, 336),
  363.         Position = UDim2.new(0.5, -113, 0, -336),
  364.         ZIndex = 8
  365.     })
  366.     attr(search, {
  367.         Size = UDim2.new(1, 0, 0, 50),
  368.         Text = "Search for a command here.",
  369.         TextColor3 = Color3.new(1, 1, 1),
  370.         BackgroundColor3 = Color3.new(120/255, 120/255, 120/255),
  371.         FontSize = Enum.FontSize.Size12,
  372.         BorderSizePixel = 0,
  373.         ZIndex = 9
  374.     })
  375.     attr(results, {
  376.         Size = UDim2.new(1, 0, 1, -100),
  377.         Position = UDim2.new(0, 0, 0, 50),
  378.         ZIndex = 9
  379.     })
  380.     attr(close, {
  381.         Size = UDim2.new(1, 0, 0, 50),
  382.         Position = UDim2.new(0, 0, 1, -50),
  383.         BackgroundColor3 = Color3.new(120/255, 120/255, 120/255),
  384.         Text = "Close",
  385.         TextColor3 = Color3.new(1, 0, 0),
  386.         FontSize = Enum.FontSize.Size12,
  387.         ZIndex = 9
  388.     })
  389.     attr(h1, {
  390.         Size = UDim2.new(0.7, -6, 0, 30),
  391.         BackgroundColor3 = Color3.new(1, 1, 1),
  392.         FontSize = Enum.FontSize.Size14,
  393.         TextColor3 = Color3.new(0, 0, 1),
  394.         Text = "Command",
  395.         ZIndex = 9
  396.     })
  397.     attr(h2, {
  398.         Size = UDim2.new(0.3, -6, 0, 30),
  399.         Position = UDim2.new(0.7, -6, 0, 0),
  400.         BackgroundColor3 = Color3.new(1, 1, 1),
  401.         FontSize = Enum.FontSize.Size14,
  402.         TextColor3 = Color3.new(0, 0, 1),
  403.         Text = "Level",
  404.         ZIndex = 9
  405.     })
  406.     close.MouseButton1Click:connect(function()
  407.         frame:TweenPosition(
  408.             UDim2.new(0.5, -113, 0, -336),
  409.             Enum.EasingDirection.Out,
  410.             Enum.EasingStyle.Quad,
  411.             1
  412.         )
  413.         game.Debris:AddItem(sgui, 3)
  414.     end)
  415.     search.Changed:connect(function(change)
  416.         local finds = {}
  417.         if change == "Text" then
  418.             if search.Text ~= "" then
  419.                 for _, v in ipairs(commands) do
  420.                     if v[1]:lower():sub(1, search.Text:len()) == search.Text:lower() then
  421.                         table.insert(finds, v)
  422.                     end
  423.                 end
  424.                 for index, value in ipairs(finds) do
  425.                     results["cmd" .. index].Transparency = 0
  426.                     results["cmd" .. index].Text = value[1]
  427.                     results["lvl" .. index].Transparency = 0
  428.                     results["lvl" .. index].Text = value[2]
  429.                 end
  430.                 for i = #finds + 1, #commands do
  431.                     results["cmd" .. i].Transparency = 1
  432.                     results["lvl" .. i].Transparency = 1
  433.                 end
  434.             else
  435.                 for index, value in ipairs(commands) do
  436.                     results["cmd" .. index].Transparency = 0
  437.                     results["cmd" .. index].Text = value[1]
  438.                     results["lvl" .. index].Transparency = 0
  439.                     results["lvl" .. index].Text = value[2]
  440.                 end
  441.             end
  442.         end
  443.     end)
  444.     for i = 1, #commands do
  445.         local l1, l2 = Instance.new("TextLabel", results), Instance.new("TextLabel", results)
  446.         attr(l1, {
  447.             Size = UDim2.new(0.7, -6, 0, 30),
  448.             Position = UDim2.new(0, 0, 0, i * 30),
  449.             BackgroundColor3 = Color3.new(1, 1, 1),
  450.             FontSize = Enum.FontSize.Size12,
  451.             ZIndex = 9,
  452.             Text = commands[i][1],
  453.             Name = "cmd" .. i
  454.         })
  455.         attr(l2, {
  456.             Size = UDim2.new(0.3, -6, 0, 30),
  457.             Position = UDim2.new(0.7, -6, 0, i * 30),
  458.             BackgroundColor3 = Color3.new(1, 1, 1),
  459.             FontSize = Enum.FontSize.Size12,
  460.             ZIndex = 9,
  461.             Text = commands[i][2],
  462.             Name = "lvl" .. i
  463.         })
  464.     end
  465.     frame:TweenPosition(
  466.         UDim2.new(0.5, -113, 0.5, -153),
  467.         Enum.EasingDirection.Out,
  468.         Enum.EasingStyle.Back,
  469.         1
  470.     )
  471.     return 1
  472. end
  473. temp.cmds = temp.commands
  474.  
  475. table.sort(commands, function(a, b)
  476.     return a[2] < b[2]
  477. end)
Advertisement
Add Comment
Please, Sign In to add comment