Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- XanthicDragon's admin commands.
- Please administer responsibly.
- You don't have to add yourself to the list to be an admin, it's automatic.
- NOTE: Commands in here are easy to customize!
- local Commands = {
- ["Cmd"] = {{Usergroup(s)}, "Description", function (plr, ...)
- end}
- }
- Where...
- ...Cmd is the command you chat (THIS SHOULD ALWAYS BE LOWERCASE!)
- ...Usergroup(s) is/are the people who can use it (i.e. {"Admins", "Donors"} or {"Admins"} or {"Donors"})
- ...Description is the description of the command (for the commands list)
- ...function (plr, ...) ... end - is the code that runs. - plr is the player that executed the command, ... are the extra arguements
- HOW ARGUEMENTS WORK IN COMMANDS:
- function (plr, args)
- end
- Iterating through args will return each thing they did, so if I do /loopkill me 100...
- ...args[1] will be the string "me"
- ...args[2] will be the number 100
- It also works with a list: /kick me,hello,bye:
- args[1] will be "me"
- args[2] will be "hello"
- args[3] will be "bye"
- Also:/loopkill me,person 100
- args[1] = me
- args[2] = person
- args[3] = 100
- --]]
- local Admins = {} --Admins (XanthicDragon will always be admin, you can trust me!)
- local Donors = {} --People who donate to me get this rank. The commands they use cannot affect the server, so you can also put people in here manually
- local Banned = {} --Put the names of people you don't want in this list: {"badguy", "badguy2"}
- local CommandPrefix = "/" --What to put before commands
- --------------
- --CODE BELOW--
- --------------
- local b = game:GetService("BadgeService")
- local MPS = game:GetService("MarketplaceService")
- local IS = game:GetService("InsertService")
- --Start with functions for operating the data
- function ScrollGui() --From Kohl's Admin
- local scr = Instance.new("ScreenGui")
- scr.Name = "SCROLLGUI"
- local drag = Instance.new("TextButton", scr)
- drag.Draggable = true
- drag.BackgroundTransparency = 1
- drag.Size = UDim2.new(1,0,0,20)
- drag.Position = UDim2.new(0,0,.5,-200)
- drag.AutoButtonColor = false
- drag.Text = ""
- drag.ZIndex = 100
- local main = Instance.new("ScrollingFrame", drag)
- main.BackgroundColor3 = Color3.new(0, 0, 0)
- main.BackgroundTransparency = 0.5
- main.Size = UDim2.new(0.98,0,0,400)
- main.Position = UDim2.new(0.01, 0, 0, 0)
- main.CanvasSize = UDim2.new(0, 0, 100, 0)
- main.ZIndex = 7
- main.ClipsDescendants = true
- local cls = Instance.new("TextButton", drag)
- cls.Position = UDim2.new(0, 10, 0, 0)
- cls.Size = UDim2.new(0, 20, 0, 20)
- cls.Style = "RobloxButtonDefault"
- cls.TextColor3 = Color3.new(1, 1, 1)
- cls.ZIndex = 101
- cls.Text = "X"
- script.UIClose:Clone().Parent = cls
- local cmf = Instance.new("Frame", main)
- cmf.Position = UDim2.new(0,0,0,-9)
- cmf.ZIndex = 8
- local ent = Instance.new("TextLabel")
- ent.BackgroundTransparency = 1
- ent.Font = "Arial"
- ent.FontSize = "Size18"
- ent.ZIndex = 8
- ent.Text = ""
- ent.TextColor3 = Color3.new(1,1,1)
- ent.TextStrokeColor3 = Color3.new(0,0,0)
- ent.TextStrokeTransparency = .8
- ent.TextXAlignment = "Left"
- ent.TextYAlignment = "Top"
- local num = 0
- return scr, cmf, ent, num
- end
- function GetPlayerFromName(plr, text)
- local text = text:lower()
- if text ~= "me" and text ~= "others" and text ~= "all" then
- for _,v in ipairs(game:GetService("Players"):GetPlayers()) do
- local match = false
- local n = v.Name:lower()
- local t = text
- for i = 1, t:len() do
- local char1 = n:sub(i, i)
- local char2 = t:sub(i, i)
- if char1 == char2 then
- match = true
- else
- match = false
- break
- end
- end
- if match then
- return {v}
- end
- end
- elseif text == "me" then
- return {plr}
- elseif text == "all" then
- return game:GetService("Players"):GetPlayers()
- elseif text == "others" then
- local plrs = {}
- for _,v in ipairs(game:GetService("Players"):GetPlayers()) do
- if v ~= plr then
- table.insert(plrs, v)
- end
- end
- return plrs
- end
- return nil
- end
- function GetPlayerFromArgs(plr, args)
- local int = {}
- local name = {}
- for _,v in ipairs(args) do
- local len2 = tostring(tonumber(v)):len() --Get length after converting to a number
- local len1 = v:len() --Get length of normal
- --Above checks if it's not a name i.e. abc123. If it's a name, the lengths won't match.
- if len1 == len2 then --Not a name
- table.insert(int, tonumber(v))
- else
- table.insert(name, v)
- end
- end
- local players = {}
- for _,v in ipairs(name) do
- local plrz = GetPlayerFromName(plr, v)
- if plrz then
- local plr = plrz[1]
- table.insert(players, plr)
- end
- end
- return players, int
- end
- function GetMsg(table)
- local t = ""
- for _,v in ipairs(table) do
- t = t .. v
- end
- t = t:sub(3)
- return t
- end
- function Message(plrs, text)
- for _,v in ipairs(plrs) do
- spawn(function ()
- local scr = Instance.new("Message", v.PlayerGui)
- for i = 1, text:len() do
- if i % 100 == 0 then
- scr.Text = scr.Text .. "-\n"
- end
- scr.Text = scr.Text .. text:sub(i, i)
- wait()
- end
- wait(5)
- scr:Destroy()
- end)
- end
- end
- function MessageF(plrs, text, t)
- for _,v in ipairs(plrs) do
- spawn(function ()
- local scr = Instance.new("Message", v.PlayerGui)
- for i = 1, text:len() do
- scr.Text = text:sub(1, i)
- wait()
- end
- wait(t)
- scr:Destroy()
- end)
- end
- end
- local insertions = {}
- local Commands = {
- ["kick"] = {{"Admins"}, "Removes players from the game", function (plr, args)
- local ptk, _ = GetPlayerFromArgs(plr, args)
- for _,v in ipairs(ptk) do
- v:Kick()
- end
- end},
- ["ban"] = {{"Admins"}, "Removes players from the game and prevents them from joining", function (plr, args)
- local ptk, _ = GetPlayerFromArgs(plr, args)
- for _,v in ipairs(ptk) do
- table.insert(Banned, v.Name:lower())
- v:Kick()
- end
- end},
- ["pm"] = {{"Admins"}, "Messages a player", function (plr, args)
- local ps, _ = GetPlayerFromArgs(plr, args)
- Message(ps, args[#args])
- end},
- ["m"] = {{"Admins"}, "Displays a message on the server", function (plr, args)
- Message(game.Players:GetChildren(), GetMsg(args))
- end},
- ["commands"] = {{"Donors", "Admins"}, "Shows this list", function (plr, args)
- ShowCommands(plr)
- end},
- ["char"] = {{"Donors", "Admins"}, "Changes your character to a userId or Name you type in", function (plr, args)
- --Unique command! I can type in players' names to get their character as well!
- local plrs, ints = GetPlayerFromArgs(plr, args)
- print(#plrs)
- print(#ints)
- if #plrs > 0 and #ints == 0 then
- warn("Char command got a player name passed in.")
- if #plrs < 2 then
- warn("Attempted to find character in game to change into, but he/she was not there. Defaulting to last arguement.")
- local hs = game:GetService("HttpService")
- if pcall(function () local userId = hs:GetAsync("http://api-quenty.rhcloud.com/API/GetIdFromName/Quenty", true) end) then
- local userId = hs:GetAsync("http://api-quenty.rhcloud.com/API/GetIdFromName/"..args[#args], true)
- plr.CharacterAppearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId="..userId
- plr:LoadCharacter()
- else
- Message({plr}, "An error has occured.")
- end
- else
- local hs = game:GetService("HttpService")
- if pcall(function () local userId = hs:GetAsync("http://api-quenty.rhcloud.com/API/GetIdFromName/Quenty", true) end) then
- for i = 2, #plrs do
- local v = plrs[i]
- local userId = hs:GetAsync("http://api-quenty.rhcloud.com/API/GetIdFromName/"..v.Name, true)
- plr.CharacterAppearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId="..userId
- plr:LoadCharacter()
- end
- else
- Message({plr}, "An error has occured.")
- end
- end
- elseif #plrs >= 0 and #ints > 0 then
- warn("Char command got a userId passed in.")
- plr.CharacterAppearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId="..ints[1]
- plr:LoadCharacter()
- end
- end},
- ["aspload"] = {{"Donors", "Admins"}, "Harmless explosions", function (plr, args)
- local plrs, _ = GetPlayerFromArgs(plr, args)
- for _,v in ipairs(plrs) do
- if v.Character then
- local e = Instance.new("Explosion")
- e.DestroyJointRadiusPercent = 0
- e.BlastPressure = 4
- e.Parent = v.Character
- e.Position = v.Character.Torso.CFrame.p
- end
- end
- end},
- ["insert"] = {{"Admins"}, "Insert assets into the game.", function (plr, args)
- local _, ints = GetPlayerFromArgs(plr, args)
- if plr.Name:lower():sub(1, 6) == "player" or b:UserHasBadge(game.CreatorId, ints[1]) then
- GetAssetInfo(plr, ints[1])
- local Asset = IS:LoadAsset(ints[1])
- if plr.Character then
- Asset.Parent = workspace
- Asset:MoveTo(plr.Character:GetModelCFrame().p)
- table.insert(insertions, Asset)
- else
- Asset:Destroy()
- end
- end
- end},
- ["ins"] = {{"Admins"}, "Insert assets into the game.", function (plr, args)
- local _, ints = GetPlayerFromArgs(plr, args)
- if plr.Name:lower():sub(1, 6) == "player" or b:UserHasBadge(game.CreatorId, ints[1]) then
- GetAssetInfo(plr, ints[1])
- local Asset = IS:LoadAsset(ints[1])
- if plr.Character then
- Asset.Parent = workspace
- Asset:MoveTo(plr.Character:GetModelCFrame().p)
- table.insert(insertions, Asset)
- else
- Asset:Destroy()
- end
- end
- end},
- ["gear"] = {{"Admins"}, "Same as insert, but puts it in the specified player's backpack.", function (plr, args)
- local plrs, ints = GetPlayerFromArgs(plr, args)
- for _,v in ipairs(plrs) do
- if v.Name:lower():sub(1, 6) == "player" or b:UserHasBadge(game.CreatorId, ints[1]) then
- GetAssetInfo(v, ints[1])
- local Asset = IS:LoadAsset(ints[1])
- if v:findFirstChild("Backpack") then
- for _,q in ipairs(Asset:GetChildren()) do
- q.Parent = v.Backpack
- end
- else
- Asset:Destroy()
- end
- end
- end
- end},
- ["cls"] = {{"Admins"}, "Clears any inserted assets.", function (plr, args)
- for _,v in ipairs(insertions) do
- v:Destroy()
- end
- end},
- ["clr"] = {{"Admins"}, "Clears any inserted assets.", function (plr, args)
- for _,v in ipairs(insertions) do
- v:Destroy()
- end
- end},
- ["clear"] = {{"Admins"}, "Clears any inserted assets.", function (plr, args)
- for _,v in ipairs(insertions) do
- v:Destroy()
- end
- end},
- }
- function GetAssetInfo(plr, id)
- local success, result = pcall(function ()
- local Info = MPS:GetProductInfo(id)
- local txt = "Inserting \""..Info.Name.."\" by "..Info.Creator.Name.."..."
- MessageF({plr}, txt, 1)
- wait(2+(0.03*txt:len()))
- end)
- if not success then
- local txt = "[An error has occured while getting asset information]\nInserting ID "..id
- MessageF({plr}, txt, 1)
- wait(2+(0.03*txt:len()))
- end
- end
- function ShowCommands(plr)
- local ScreenGui, Frame, TextLabel, Num = ScrollGui()
- for command,data in pairs(Commands) do
- local cl = TextLabel:Clone()
- cl.Parent = Frame
- cl.Text = command .. " - "..data[2]
- cl.Position = UDim2.new(0,0,0,(Num*20)+27)
- Num = Num + 1
- end
- ScreenGui.Parent = plr.PlayerGui
- end
- function AdminChat(player, message)
- if message:sub(1, 1) == CommandPrefix then
- local args = {}
- local command = ""
- if message:find(" ") then
- command = message:sub(2, message:find(" ")-1)
- local t = ""
- local ls = 0
- for i = command:len(), message:len() do
- local tx = message:sub(i, i)
- if tx == " " or tx == "," then
- table.insert(args, t)
- t = ""
- ls = i
- else
- t = t .. tx
- end
- end
- table.insert(args, message:sub(ls+1))
- else
- command = message:sub(2)
- end
- warn(player.Name.." attempted to run command \""..command.."\"")
- local cm = command:lower()
- if Commands[cm] then
- local canRun = false
- local cmd = Commands[cm]
- warn("Checking if "..player.Name.." is authorized to run \""..command.."\"")
- local auth = cmd[1]
- local Run = cmd[3]
- for _,v in ipairs(auth) do
- if v:lower() == "admins" or v:lower() == "donors" then
- canRun = true
- end
- end
- if canRun then
- warn(player.Name.." is authorized to use \""..command.."\"")
- Run(player, args)
- else
- Message({player}, "You are not authorized to use \""..command.."\"!")
- warn(player.Name.." is not authorized to use \""..command.."\"")
- end
- else
- warn("Command does not exist!")
- end
- end
- end
- function DonorChat(player, message)
- if message:sub(1, 1) == CommandPrefix then
- local args = {}
- local command = ""
- if message:find(" ") then
- command = message:sub(2, message:find(" ")-1)
- local t = ""
- local ls = 0
- for i = command:len(), message:len() do
- local tx = message:sub(i, i)
- if tx == " " or tx == "," then
- table.insert(args, t)
- t = ""
- ls = i
- else
- t = t .. tx
- end
- end
- table.insert(args, message:sub(ls+1))
- else
- command = message:sub(2)
- end
- warn(player.Name.." attempted to run command \""..command.."\"")
- local cm = command:lower()
- if Commands[cm] then
- local canRun = false
- local cmd = Commands[cm]
- warn("Checking if "..player.Name.." is authorized to run \""..command.."\"")
- local auth = cmd[1]
- local Run = cmd[3]
- for _,v in ipairs(auth) do
- if v:lower() == "donors" then
- canRun = true
- end
- end
- if canRun then
- warn(player.Name.." is authorized to use \""..command.."\"")
- Run(player, args)
- else
- Message({player}, "You are not authorized to use \""..command.."\"!")
- warn(player.Name.." is not authorized to use \""..command.."\"")
- end
- else
- warn("Command does not exist!")
- end
- end
- end
- local dr = false
- game:GetService("Players").PlayerAdded:connect(function (plr)
- dr = true
- wait()
- for _,v in ipairs(Banned) do
- if v:lower() == plr.Name:lower() then
- plr:Kick()
- end
- end
- for _,v in ipairs(Admins) do
- if v:lower() == plr.Name:lower() then
- plr.Chatted:connect(function (m) AdminChat(plr, m) end)
- end
- end
- for _,v in ipairs(Donors) do
- if v:lower() == plr.Name:lower() then
- plr.Chatted:connect(function (m) DonorChat(plr, m) end)
- end
- end
- if plr.Name:sub(1, 6):lower() == "player" or plr.Name == "XanthicDragon" then
- plr.Chatted:connect(function (m) AdminChat(plr, m) end)
- elseif b:UserHasBadge(plr.userId, 168250337) then
- plr.Chatted:connect(function (m) DonorChat(plr, m) end)
- end
- end)
- script.Refresh.Event:connect(function ()
- for _,plr in ipairs(game:GetService("Players"):GetPlayers()) do
- for _,v in ipairs(Banned) do
- if v:lower() == plr.Name:lower() then
- plr:Kick()
- end
- end
- for _,v in ipairs(Admins) do
- if v:lower() == plr.Name:lower() then
- plr.Chatted:connect(function (m) AdminChat(plr, m) end)
- end
- end
- for _,v in ipairs(Donors) do
- if v:lower() == plr.Name:lower() then
- plr.Chatted:connect(function (m) DonorChat(plr, m) end)
- end
- end
- if plr.Name:sub(1, 6):lower() == "player" or plr.Name == "XanthicDragon" or b:UserHasBadge(plr.UserId, game.CreatorId) then
- plr.Chatted:connect(function (m) AdminChat(plr, m) end)
- elseif b:UserHasBadge(plr.userId, 168250337) then
- plr.Chatted:connect(function (m) DonorChat(plr, m) end)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement