ForeverDev

Untitled

Oct 24th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.81 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. local commands = {}
  174. local meta = {}
  175. meta.__newindex = function(this, key)
  176.     table.insert(commands, key)
  177. end
  178.  
  179. owner, perm, temp = {}, {}, {}
  180.  
  181. setmetatable(owner, meta)
  182. setmetatable(perm, meta)
  183. setmetatable(temp, meta)
  184.  
  185. owner.kick = function(speaker, message, words)
  186.     each(target(words[2], speaker), function(_, this)
  187.         this:Kick()
  188.     end)
  189.     return 1
  190. end
  191.  
  192. owner.perm = function(speaker, message, words)
  193.     each(target(words[2], speaker), function(_, this)
  194.         admins[tostring(this.userId)] = 2
  195.     end)
  196.     return 1
  197. end
  198.  
  199. owner.temp = function(speaker, message, words)
  200.     each(target(words[2], speaker), function(_, this)
  201.         admins[tostring(this.userId)] = 1
  202.     end)
  203.     return 1
  204. end
  205.  
  206. owner.unadmin = function(speaker, message, words)
  207.     each(target(words[2], speaker), function(_, this)
  208.         if this.Name == speaker.Name then
  209.             return
  210.         end
  211.         if admins[tostring(this.userId)] then
  212.             if admins[tostring(this.userId)] < 3 then
  213.                 admins[tostring(this.userId)] = false
  214.             end
  215.         end
  216.     end)
  217.     return 1
  218. end
  219.  
  220. owner.script = function(speaker, message, words)
  221.     pcall(function()
  222.         if game.ServerScriptService.LoadStringEnabled then
  223.             loadstring(message:sub(message:find("script") + 7))()
  224.         end
  225.     end)
  226.     return 1
  227. end
  228.  
  229. perm.kill = function(speaker, message, words)
  230.     each(target(words[2], speaker), function(_, this)
  231.         if this.Character then
  232.             this.Character:BreakJoints()
  233.         end
  234.     end)
  235.     return 1
  236. end
  237.  
  238. perm.punish = function(speaker, message, words)
  239.     each(target(words[2], speaker), function(_, this)
  240.         this.Character:Destroy()
  241.     end)
  242.     return 1
  243. end
  244.  
  245. perm.unpunish = function(speaker, message, words)
  246.     each(target(words[2], speaker), function(_, this)
  247.         if not Workspace:FindFirstChild(this.Name) then
  248.             this:LoadCharacter()
  249.         end
  250.     end)
  251.     return 1
  252. end
  253.  
  254. temp.pm = function(speaker, message, words)
  255.     each(target(words[2], speaker), function(_, this)
  256.         alert(speaker, this, message:sub(message:find(words[2]) + (words[2]:len() + 1)))
  257.     end)
  258.     return 1
  259. end
  260.  
  261. temp.commands = function(speaker)
  262.     local sgui = Instance.new("ScreenGui", speaker.PlayerGui)
  263.     local frame = Instance.new("Frame", sgui)
  264.     local search = Instance.new("TextBox", frame)
  265.     local results = Instance.new("ScrollingFrame", frame)
  266.     local close = Instance.new("TextButton", frame)
  267.     attr(frame, {
  268.         Size = UDim2.new(0, 226, 0, 336),
  269.         Position = UDim2.new(0.5, -113, 0, -336),
  270.         ZIndex = 8
  271.     })
  272.     attr(search, {
  273.         Size = UDim2.new(1, 0, 0, 50),
  274.         Text = "Search for a command here.",
  275.         TextColor3 = Color3.new(1, 1, 1),
  276.         BackgroundColor3 = Color3.new(120/255, 120/255, 120/255),
  277.         FontSize = Enum.FontSize.Size12,
  278.         BorderSizePixel = 0,
  279.         ZIndex = 9
  280.     })
  281.     attr(results, {
  282.         Size = UDim2.new(1, 0, 1, -100),
  283.         Position = UDim2.new(0, 0, 0, 50),
  284.         ZIndex = 9
  285.     })
  286.     attr(close, {
  287.         Size = UDim2.new(1, 0, 0, 50),
  288.         Position = UDim2.new(0, 0, 1, -50),
  289.         Text = "Close",
  290.         TextColor3 = Color3.new(1, 0, 0),
  291.         FontSize = Enum.FontSize.Size12,
  292.         ZIndex = 9
  293.     })
  294.     close.MouseButton1Click:connect(function()
  295.         frame:TweenPosition(
  296.             UDim2.new(0.5, -113, 0, -336),
  297.             Enum.EasingDirection.Out,
  298.             Enum.EasingStyle.Quad,
  299.             1
  300.         )
  301.         game.Debris:AddItem(sgui, 3)
  302.     end)
  303.     search.Changed:connect(function(change)
  304.         if change == "Text" then
  305.            
  306.         end
  307.     end)
  308.     frame:TweenPosition(
  309.         UDim2.new(0.5, -113, 0.5, -153),
  310.         Enum.EasingDirection.Out,
  311.         Enum.EasingStyle.Back,
  312.         1
  313.     )
  314.     return 1
  315. end
  316. temp.cmds = temp.commands
  317.  
  318. print(table.concat(commands, ", "))
  319.  
  320. wait(2)
  321. chat("#cmds", game.Players.Player)
Advertisement
Add Comment
Please, Sign In to add comment