ForeverDev

Untitled

Oct 24th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.58 KB | None | 0 0
  1. local data = game:GetService("DataStoreService"):GetDataStore("ForeverDevAdmin")
  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 alert;
  35. alert = function(player, receiver, message)
  36.     local sgui = Instance.new("ScreenGui", receiver.PlayerGui)
  37.     local frame = Instance.new("Frame", sgui)
  38.     local title = Instance.new("TextLabel", frame)
  39.     local body = Instance.new("TextLabel", frame)
  40.     local ignore = Instance.new("TextButton", frame)
  41.     local submit = Instance.new("TextButton", frame)
  42.     local reply = Instance.new("TextBox", frame)
  43.     attr(frame, {
  44.         Size = UDim2.new(0, 400, 0, 250),
  45.         Position = UDim2.new(0.5, -200, 0, -250),
  46.         ZIndex = 8
  47.     })
  48.     attr(title, {
  49.         Size = UDim2.new(1, 0, 0, 50),
  50.         Text = "PM from " .. player.Name,
  51.         TextColor3 = Color3.new(1, 1, 1),
  52.         TextStrokeTransparency = 0,
  53.         TextWrapped = true,
  54.         FontSize = Enum.FontSize.Size18,
  55.         ZIndex = 9
  56.     })
  57.     attr(body, {
  58.         Size = UDim2.new(1, 0, 1, -110),
  59.         Position = UDim2.new(0, 0, 0, 60),
  60.         Text = message,
  61.         TextColor3 = Color3.new(1, 1, 1),
  62.         TextWrapped = true,
  63.         TextYAlignment = Enum.TextYAlignment.Top,
  64.         TextStrokeTransparency = 0,
  65.         FontSize = Enum.FontSize.Size14,
  66.         BorderSizePixel = 0,
  67.         ZIndex = 9
  68.     })
  69.     attr(ignore, {
  70.         Size = UDim2.new(0, 50, 0, 50),
  71.         Position = UDim2.new(0, 0, 1, -50),
  72.         Text = "Close",
  73.         TextColor3 = Color3.new(1, 0, 0),
  74.         FontSize = Enum.FontSize.Size12,
  75.         ZIndex = 10
  76.     })
  77.     attr(submit, {
  78.         Size = UDim2.new(0, 50, 0, 50),
  79.         Position = UDim2.new(0, 50, 1, -50),
  80.         Text = "Reply",
  81.         TextColor3 = Color3.new(0, 1, 0),
  82.         FontSize = Enum.FontSize.Size12,
  83.         ZIndex = 10
  84.     })
  85.     attr(reply, {
  86.         Size = UDim2.new(1, -100, 0, 50),
  87.         Position = UDim2.new(0, 100, 1, -50),
  88.         Text = "Type what you want to reply here.",
  89.         TextColor3 = Color3.new(0, 1, 0),
  90.         FontSize = Enum.FontSize.Size12,
  91.         ZIndex = 10
  92.     })
  93.     submit.MouseButton1Down:connect(function()
  94.         frame:TweenPosition(
  95.             UDim2.new(0.5, -200, 0, -250),
  96.             Enum.EasingDirection.Out,
  97.             Enum.EasingStyle.Quad,
  98.             1
  99.         )
  100.         game.Debris:AddItem(sgui, 3)
  101.         alert(receiver, player, reply.Text)
  102.     end)
  103.     ignore.MouseButton1Down:connect(function()
  104.         frame:TweenPosition(
  105.             UDim2.new(0.5, -200, 0, -250),
  106.             Enum.EasingDirection.Out,
  107.             Enum.EasingStyle.Quad,
  108.             1
  109.         )
  110.         game.Debris:AddItem(sgui, 3)
  111.     end)
  112.     frame:TweenPosition(
  113.         UDim2.new(0.5, -200, 0.5, -125),
  114.         Enum.EasingDirection.Out,
  115.         Enum.EasingStyle.Back,
  116.         1
  117.     )
  118. end
  119.  
  120. local target = function(targ, speaker)
  121.     if targ:lower() == "all" then
  122.         return game.Players:GetPlayers()
  123.     elseif targ:lower() == "others" then
  124.         return removeElement(game.Players:GetPlayers(), speaker)
  125.     elseif targ:lower() == "me" then
  126.         return {speaker}
  127.     else
  128.         each(game.Players:GetPlayers(), function(_, this)
  129.             if this.Name:lower():sub(1, targ:len()) == targ:lower() then
  130.                 return {this}
  131.             end
  132.         end)
  133.         return {}
  134.     end
  135. end
  136.  
  137. local chat = function(message, speaker)
  138.     if admins[tostring(speaker.userId)] and message:sub(1, 1) == "#" then
  139.         local words = {}
  140.         message:gsub("([%a%d,]+)", function(catch)
  141.             table.insert(words, catch:lower())
  142.         end)
  143.         if owner[words[1]] or perm[words[1]] or temp[words[1]] then
  144.             local success;
  145.             local level = admins[tostring(speaker.userId)]
  146.             repeat
  147.                 local stringLevel = level == 3 and "owner" or level == 2 and "perm" or level == 1 and "temp" or "false"
  148.                 if getfenv()[stringLevel][words[1]] then
  149.                     success = getfenv()[stringLevel][words[1]](speaker, message, words)
  150.                 end
  151.                 level = level - 1
  152.             until success or level == 0
  153.         end
  154.     end
  155. end
  156.    
  157. game.Players.PlayerAdded:connect(function(player)
  158.     player.Chatted:connect(function(message)
  159.         chat(message, player)
  160.     end)
  161. end)
  162.  
  163. --[[
  164.     levels:
  165.         3 = owner
  166.         2 = perm
  167.         1 = temp
  168.     you can access commands from your level and under.
  169.     ex) perm admins can access commands @ level 2 and 1
  170.    
  171.     must be global so getfenv() can be used to find these tables
  172. ]]
  173.  
  174. owner, perm, temp = {}, {}, {}
  175.  
  176. owner.kick = function(speaker, message, words)
  177.     each(target(words[2], speaker), function(_, this)
  178.         this:Kick()
  179.     end)
  180.     return 1
  181. end
  182.  
  183. owner.perm = function(speaker, message, words)
  184.     each(target(words[2], speaker), function(_, this)
  185.         admins[tostring(this.userId)] = 2
  186.     end)
  187.     return 1
  188. end
  189.  
  190. owner.temp = function(speaker, message, words)
  191.     each(target(words[2], speaker), function(_, this)
  192.         admins[tostring(this.userId)] = 1
  193.     end)
  194.     return 1
  195. end
  196.  
  197. owner.unadmin = function(speaker, message, words)
  198.     each(target(words[2], speaker), function(_, this)
  199.         if this.Name == speaker.Name then
  200.             return
  201.         end
  202.         if admins[tostring(this.userId)] then
  203.             if admins[tostring(this.userId)] < 3 then
  204.                 admins[tostring(this.userId)] = false
  205.             end
  206.         end
  207.     end)
  208.     return 1
  209. end
  210.  
  211. owner.script = function(speaker, message, words)
  212.     pcall(function()
  213.         if game.ServerScriptService.LoadStringEnabled then
  214.             loadstring(message:sub(message:find("script") + 7))()
  215.         end
  216.     end)
  217.     return 1
  218. end
  219.  
  220. perm.kill = function(speaker, message, words)
  221.     each(target(words[2], speaker), function(_, this)
  222.         if this.Character then
  223.             this.Character:BreakJoints()
  224.         end
  225.     end)
  226.     return 1
  227. end
  228.  
  229. perm.punish = function(speaker, message, words)
  230.     each(target(words[2], speaker), function(_, this)
  231.         this.Character:Destroy()
  232.     end)
  233.     return 1
  234. end
  235.  
  236. perm.unpunish = function(speaker, message, words)
  237.     each(target(words[2], speaker), function(_, this)
  238.         if not Workspace:FindFirstChild(this.Name) then
  239.             this:LoadCharacter()
  240.         end
  241.     end)
  242.     return 1
  243. end
  244.  
  245. temp.pm = function(speaker, message, words)
  246.     each(target(words[2], speaker), function(_, this)
  247.         alert(speaker, this, message:sub(message:find(words[2]) + (words[2]:len() + 1)))
  248.     end)
  249.     return 1
  250. end
  251.  
  252. temp.commands = function(speaker)
  253.     local sgui = Instance.new("ScreenGui", speaker.PlayerGui)
  254.     local frame = Instance.new("Frame", sgui)
  255.     local search = Instance.new("TextBox", frame)
  256.     local results = Instance.new("ScrollingFrame", frame)
  257.     local close = Instance.new("TextButton", frame)
  258.     attr(frame, {
  259.         Size = UDim2.new(0, 226, 0, 336),
  260.         Position = UDim2.new(0.5, -113, 0, -336),
  261.         ZIndex = 8
  262.     })
  263.     attr(search, {
  264.         Size = UDim2.new(1, 0, 0, 50),
  265.         Text = "Search for a command here.",
  266.         TextColor3 = Color3.new(1, 1, 1),
  267.         BackgroundColor3 = Color3.new(120/255, 120/255, 120/255),
  268.         FontSize = Enum.FontSize.Size12,
  269.         BorderSizePixel = 0,
  270.         ZIndex = 9
  271.     })
  272.     attr(results, {
  273.         Size = UDim2.new(1, 0, 1, -100),
  274.         Position = UDim2.new(0, 0, 0, 50),
  275.         ZIndex = 9
  276.     })
  277.     attr(close, {
  278.         Size = UDim2.new(1, 0, 0, 50),
  279.         Position = UDim2.new(0, 0, 1, -50),
  280.         Text = "Close",
  281.         TextColor3 = Color3.new(1, 0, 0),
  282.         FontSize = Enum.FontSize.Size12,
  283.         ZIndex = 9
  284.     })
  285.     close.MouseButton1Click:connect(function()
  286.         frame:TweenPosition(
  287.             UDim2.new(0.5, -113, 0, -336),
  288.             Enum.EasingDirection.Out,
  289.             Enum.EasingStyle.Quad,
  290.             1
  291.         )
  292.         game.Debris:AddItem(sgui, 3)
  293.     end)
  294.     search.Changed:connect(function(change)
  295.         if change == "Text" then
  296.            
  297.         end
  298.     end)
  299.     frame:TweenPosition(
  300.         UDim2.new(0.5, -113, 0.5, -153),
  301.         Enum.EasingDirection.Out,
  302.         Enum.EasingStyle.Back,
  303.         1
  304.     )
  305.     return 1
  306. end
  307. temp.cmds = temp.commands
  308.  
  309. wait(2)
  310. chat("#cmds", game.Players.Player)
Advertisement
Add Comment
Please, Sign In to add comment