Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --_G.Admin created by databrain
- local Admins = {--Set the admins here
- "databrain",
- "Player1",
- "kylletd123"
- }
- local Banned = {
- "Noli", -- Replace "Noli" with whatever you want. Caps doesn't matter.
- }
- local KeyBinds = {
- --["e"] = "explosion 4 500000",
- }
- local Commands = { -- Add the ID of commands. All commands will appear in this order (After the kick commands)
- 125747874, -- Commands command
- 125545035, -- Admin command
- 125545364, -- Unadmin command
- 125733551, -- Kick command
- 125736399, -- Ban command
- 125853600, -- Unban command
- 125733007, -- Team command
- 125863127, -- Score command
- 125538538, -- Tp command
- 125976136, -- Coords command
- 125961432, -- Health command
- 125961636, -- MaxHealth command
- 125973522, -- Walkspeed command
- 125753022, -- Explosion command
- 125756868, -- Bind command
- 125757398, -- Unbind command
- 125761354, -- Call command
- 125726947, -- S command
- 125762622, -- Ls command
- 125838090, -- Clear command
- 125841639, -- SetAlias command
- 125841731, -- ClearAlias command
- }
- local Aliases = { --Commands that do the same things other commands
- ["help"] = "commands",
- ["teleport"] = "tp",
- ["t"] = "team",
- }
- --[[--------------------------------------------------------------------------------]]--
- while not _G.ready do wait() end
- local CmdList = {}
- function createCommand(cmd, adminLevel, func, use, isRaw)
- if not use then return end
- if not isRaw then isRaw = false end
- table.insert(CmdList, {cmd, adminLevel, func, use, isRaw})
- end
- function GetTable(tab)
- if tab == "Admins" then return Admins end
- if tab == "Banned" then return Banned end
- if tab == "KeyBinds" then return KeyBinds end
- if tab == "Commands" then return Commands end
- if tab == "CmdList" then return CmdList end
- if tab == "Aliases" then return Aliases end
- end
- function SetKey(tab, key, value)
- if tab == "Admins" then Admins[key] = value end
- if tab == "Banned" then Banned[key] = value end
- if tab == "KeyBinds" then KeyBinds[key] = value end
- if tab == "Commands" then Commands[key] = value end
- if tab == "CmdList" then CmdList[key] = value end
- if tab == "Aliases" then Aliases[key] = value end
- end
- function Insert(tab, value, val)
- if val then
- if tab == "Admins" then table.insert(Admins, value, val) end
- if tab == "Banned" then table.insert(Banned, value, val) end
- if tab == "KeyBinds" then table.insert(KeyBinds, value, val) end
- if tab == "Commands" then table.insert(Commands, value, val) end
- if tab == "CmdList" then table.insert(CmdList, value, val) end
- if tab == "Aliases" then table.insert(Aliases, value, val) end
- else
- if tab == "Admins" then table.insert(Admins, value) end
- if tab == "Banned" then table.insert(Banned, value) end
- if tab == "KeyBinds" then table.insert(KeyBinds, value) end
- if tab == "Commands" then table.insert(Commands, value) end
- if tab == "CmdList" then table.insert(CmdList, value) end
- if tab == "Aliases" then table.insert(Aliases, value) end
- end
- end
- function Remove(tab, num)
- if tab == "Admins" then table.remove(Admins, num) end
- if tab == "Banned" then table.remove(Banned, num) end
- if tab == "KeyBinds" then table.remove(KeyBinds, num) end
- if tab == "Commands" then table.remove(Commands, num) end
- if tab == "CmdList" then table.remove(CmdList, num) end
- if tab == "Aliases" then table.remove(Aliases, num) end
- end
- --[[
- _G.Admin are admin commands made by databrain. It requires _G.Function API V1.5 or greater,
- found at http://www.roblox.com/G-Functions-API-item?id=123386757. _G.Functions must be
- put in any model inside workspace or just inside Workspace. The same applies with _G.Admin.
- _G.Admin includes a useful API for other scripters to use, to add admin commands.
- ]]
- --Example command:
- --[[Commands command by databrain. This is the source. The value SourceCode is loaded,
- not the script. All _G.Admin commands must be open source.
- ]]
- createCommand("kill", 1, function(speaker, ply, team)
- if not speaker then return end
- if not ply then showUse("kill <player>") return end
- if getPlayerGroup(speaker, ply, team) ~= nil then
- if #getPlayerGroup(speaker, ply, team) > 0 then
- for _,v in pairs(getPlayerGroup(speaker, ply, team)) do
- v.Character:BreakJoints()
- end
- end
- return
- end
- if not getPlayer(ply) then showError("Player Not Found") return end
- ply = getPlayer(ply)
- if not ply.Character:FindFirstChild("Humanoid") then return end
- humanoid = ply.Character.Humanoid
- local creator_tag = Instance.new("ObjectValue")
- creator_tag.Value = speaker
- creator_tag.Name = "creator"
- creator_tag.Parent = humanoid
- ply.Character:BreakJoints()
- wait(1)
- if humanoid ~= nil then
- local tag = humanoid:findFirstChild("creator")
- if tag ~= nil then
- tag:Destroy()
- end
- end
- end, "kill <player>")
- --Do not edit this last part. This is what detects commands.
- function showError(err)
- if not err then return end
- print("Error:", err)
- end
- function showUse(use)
- if not use then return end
- print("Use:", use)
- end
- function getPlayer(ply)
- for _,v in pairs(game.Players:getChildren()) do
- if v.Name:sub(1, ply:len()):lower() == ply:lower() then return v end
- end
- end
- function getAdminLevel(ply)
- local level = 0
- for _,v in pairs(Admins) do
- if ply.Name:lower() == v:lower() then
- level = 1
- end
- end
- return level
- end
- function split(str, pat)
- local t = {} -- NOTE: use {n = 0} in Lua-5.0
- local fpat = "(.-)" .. pat
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- s, e, cap = str:find(fpat, last_end)
- end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
- end
- return t
- end
- function getPlayerGroup(speaker, group, team)
- local listed = {}
- group = group:lower()
- if group == "all" then
- for _,v in pairs(game.Players:getChildren()) do
- table.insert(listed, v)
- end
- if #listed > 0 then
- return listed
- end
- elseif group == "admins" then
- for _,v in pairs(game.Players:getChildren()) do
- if getAdminLevel(v) > 0 then
- table.insert(listed, v)
- end
- end
- if #listed > 0 then
- return listed
- end
- elseif group == "nonadmins" then
- for _,v in pairs(game.Players:getChildren()) do
- if getAdminLevel(v) == 0 then
- table.insert(listed, v)
- end
- end
- if #listed > 0 then
- return listed
- end
- elseif group == "others" then
- for _,v in pairs(game.Players:getChildren()) do
- if v ~= speaker then
- table.insert(listed, v)
- end
- end
- if #listed > 0 then
- return listed
- end
- elseif group == "me" then
- table.insert(listed, speaker)
- if #listed > 0 then
- return listed
- end
- elseif group == "random" or group == "rand" then
- if #players > 0 then
- table.insert(listed, players[math.random(1, #players)])
- end
- if #listed > 0 then
- return listed
- end
- elseif group == "team" then
- if not team then return end
- for _,v in pairs(game.Players:getChildren()) do
- if #game.Teams:getChildren() > 0 then
- for _,t in pairs(game.Teams:getChildren()) do
- if t.Name:sub(1, team:len()):lower() == team:lower() then
- if v.TeamColor == t.TeamColor then
- table.insert(listed, v)
- end
- end
- end
- end
- end
- if #listed > 0 then
- return listed
- end
- elseif group == "score" then
- if not team then return end
- for _,v in pairs(game.Players:getChildren()) do
- if v:findFirstChild("leaderstats") then
- if #split(team, ">") == 2 then
- local score = split(team, ">")[1]
- local num = split(team, ">")[2]
- local gScore
- for _,s in pairs(v.leaderstats:getChildren()) do
- if s.Name:sub(1, score:len()):lower() == score:lower() then
- gScore = s
- break
- end
- end
- if gScore then
- if tonumber(gScore.Value) and tonumber(num) then
- if tonumber(gScore.Value) > tonumber(num) then
- table.insert(listed, v)
- end
- end
- end
- elseif #split(team, "<") == 2 then
- local score = split(team, "<")[1]
- local num = split(team, "<")[2]
- local gScore
- for _,s in pairs(v.leaderstats:getChildren()) do
- if s.Name:sub(1, score:len()):lower() == score:lower() then
- gScore = s
- break
- end
- end
- if gScore then
- if tonumber(gScore.Value) and tonumber(num) then
- if tonumber(gScore.Value) < tonumber(num) then
- table.insert(listed, v)
- end
- end
- end
- elseif #split(team, "=") == 2 then
- local score = split(team, "=")[1]
- local num = split(team, "=")[2]
- local gScore
- for _,s in pairs(v.leaderstats:getChildren()) do
- if s.Name:sub(1, score:len()):lower() == score:lower() then
- gScore = s
- break
- end
- end
- if gScore then
- if tonumber(gScore.Value) and tonumber(num) then
- if tonumber(gScore.Value) == tonumber(num) then
- table.insert(listed, v)
- end
- end
- end
- elseif #split(team, "==") == 2 then
- local score = split(team, "==")[1]
- local num = split(team, "==")[2]
- local gScore
- for _,s in pairs(v.leaderstats:getChildren()) do
- if s.Name:sub(1, score:len()):lower() == score:lower() then
- gScore = s
- break
- end
- end
- if gScore then
- if tonumber(gScore.Value) and tonumber(num) then
- if tonumber(gScore.Value) == tonumber(num) then
- table.insert(listed, v)
- end
- end
- end
- elseif #split(team, ">=") == 2 then
- local score = split(team, ">=")[1]
- local num = split(team, ">=")[2]
- local gScore
- for _,s in pairs(v.leaderstats:getChildren()) do
- if s.Name:sub(1, score:len()):lower() == score:lower() then
- gScore = s
- break
- end
- end
- if gScore then
- if tonumber(gScore.Value) and tonumber(num) then
- if tonumber(gScore.Value) >= tonumber(num) then
- table.insert(listed, v)
- end
- end
- end
- elseif #split(team, "<=") == 2 then
- local score = split(team, "<=")[1]
- local num = split(team, "<=")[2]
- local gScore
- for _,s in pairs(v.leaderstats:getChildren()) do
- if s.Name:sub(1, score:len()):lower() == score:lower() then
- gScore = s
- break
- end
- end
- if gScore then
- if tonumber(gScore.Value) and tonumber(num) then
- if tonumber(gScore.Value) <= tonumber(num) then
- table.insert(listed, v)
- end
- end
- end
- end
- end
- end
- if #listed > 0 then
- return listed
- end
- end
- return
- end
- function GetCommandSources() --Credit to Animinus for this function.
- local InsertService = game:GetService("InsertService")
- if #Commands < 1 then return end
- for _,id in pairs(Commands) do
- local children = {}
- -- gets children from asset or object path
- if type(id) == "number" and id > 0 and math.floor(id) == id then
- local asset = InsertService:LoadAsset(id)
- if asset then
- children = asset:GetChildren()
- asset.Parent = nil
- else
- print("Command source: \"",id,"\": cannot access asset")
- end
- elseif pcall(function() return id:IsA"Instance" end) then -- that type check would be useful
- children = {id}
- else
- print("Command source: \"",id,"\": not an asset id or Object path")
- end
- -- if the 1st child is a model; make the children the model's children
- local first = children[1]
- if first then
- if first.className == "Model" or first.className == "Backpack" then
- if #children == 1 then
- local fchildren = first:GetChildren()
- if #fchildren > 0 then
- children = fchildren
- else
- print("Command source: \"",id,"\": model does not contain any scripts")
- end
- else
- print("Command source: \"",id,"\": model contains invalid objects")
- end
- end
- else
- print("Command source: \"",id,"\": model contains no objects")
- end
- -- finally process children
- for _,child in pairs(children) do
- if child.className == "Script" then
- if child:FindFirstChild("SourceCode") then
- local func,msg = loadstring(child.SourceCode.Value,"")
- if func then
- func()
- else
- print("Command source: \"",id,"\": syntax error: ",msg)
- end
- else
- print("Command source: \"",id,"\": model contains invalid objects")
- end
- else
- print("Command source: \"",id,"\": model contains invalid objects")
- end
- end
- end
- end
- GetCommandSources()
- function checkBanned()
- for _,ply in pairs(game.Players:getChildren()) do
- if Banned and #Banned > 0 then
- for _,v in pairs(Banned) do
- if v:lower() == ply.Name:lower() then
- ply:Destroy()
- end
- end
- end
- end
- end
- game.Players.PlayerAdded:connect(function(p)
- print("Player", p)
- checkBanned()
- p:GetMouse().KeyDown:connect(function(key)
- key = key:lower()
- for k,v in pairs(KeyBinds) do
- if k == key and getAdminLevel(p) == 1 then
- _G.Call("Command", v, p)
- end
- end
- end)
- end)
- checkBanned()
- for _,p in pairs(game.Players:getChildren()) do
- p:GetMouse().KeyDown:connect(function(key)
- key = key:lower()
- for k,v in pairs(KeyBinds) do
- if k == key and getAdminLevel(p) == 1 then
- _G.Call("Command", v, p)
- end
- end
- end)
- end
- _G.Connect("Command"):connect(function(...)
- args = {...}
- if #args == 2 then
- local cmds = split(args[1], " ")
- local ply = args[2]
- if #cmds > 0 then
- local cmd = cmds[1]:lower()
- local cmdArgs = {}
- for i,v in ipairs(cmds) do
- if i > 1 then
- table.insert(cmdArgs, v)
- end
- end
- for k,v in pairs(Aliases) do
- if k == cmd then
- cmd = v break
- end
- end
- for _,v in pairs(CmdList) do
- if v[1] == cmd then
- if getAdminLevel(ply) >= v[2] then
- if v[5] == false then
- for i,v in ipairs(cmdArgs) do
- cmdArgs[i] = v:lower()
- end
- --pcall(function()
- v[3](ply, unpack(cmdArgs))
- --end)
- else
- local raw = ""
- for _,v in pairs(cmdArgs) do
- raw = raw .. v .. " "
- end
- v[3](ply, raw)
- end
- end
- end
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement