Advertisement
PeroxDevelopment

Azure X Admin

Sep 5th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.03 KB | None | 0 0
  1. --[[
  2.     cmdscript.lua + safazi's edit
  3.     written by safazi
  4.  
  5.         THE OFFICIAL MULTI ADMIN UPDATE:
  6.         ADDCMD NOW TAKES TWO FUNCTION ARGUMENTS:
  7.             ARGS
  8.            
  9.             and
  10.            
  11.             SPEAKER
  12.            
  13.         THE SPEAKER IS THE PLAYER OBJECT THAT SPOKE THE COMMAND
  14.         WE HOPE THIS OPENS UP NEW OPPURTUNITIES FOR YOUR EDITS!
  15.        
  16.             -safazi
  17.    
  18.     HOW TO ADD COMMANDS
  19.     Scroll to bottom, add after it says "Add commands here"
  20.    
  21.     PLEASE KEEP ALIASES LOWERCASE
  22.    
  23.     example with aliases:
  24.         addcmd('command name','command description',{'alias for command','another alias'},
  25.         function(args,speaker)
  26.             --code here
  27.         end)
  28.    
  29.     example without aliases:
  30.         addcmd('command name','command description',nil,
  31.         function(args,speaker)
  32.             --code here
  33.         end)
  34.    
  35.     important things:
  36.    
  37.     _char(playername) gets a players character from name if they exist
  38.     example:
  39.         local char=_char('safazi') --gets my character!
  40.        
  41.     command functions are passed the table "args", which holds the args after the command
  42.     example:
  43.         ;command arg1 arg2 arg3 arg4
  44. --]]
  45.  
  46. local gPlayers = game:GetService("Players")
  47. local admin = gPlayers.LocalPlayer.Name
  48. local bannedplyrs = {}
  49.  
  50. local admins = {''} -- names here of people who have access to your commands! (Your name doesn't need to be in here.)
  51.  
  52. -- declare services / init stuff --
  53. local services={}
  54. local cmds={}
  55. local std={}
  56.  
  57. services.players=gPlayers
  58. services.lighting=game:GetService('Lighting')
  59. services.workspace=game:GetService('Workspace')
  60. services.events = {}
  61. local user = gPlayers.LocalPlayer
  62.  
  63. local cmdprefix=';'
  64. local scriptprefix='\\'
  65. local split=" "
  66.  
  67.  
  68. updateevents=function()
  69.     for i,v in pairs(services.events) do services.events:remove(i) v:disconnect() end
  70.     for i,v in pairs(gPlayers:players())do
  71.         local ev = v.Chatted:connect(function(msg) do_exec(msg,v) end)
  72.         services.events[#services.events+1] = ev
  73.     end
  74. end
  75.  
  76. -- safazi's lib --
  77.  
  78. std.inTable=function(tbl,val)
  79.     if tbl==nil then return false end
  80.  
  81.     for _,v in pairs(tbl)do
  82.         if v==val then return true end
  83.     end
  84.     return false
  85. end
  86.  
  87. std.out=function(str)
  88.     print(str)
  89. end
  90.  
  91. std.list=function(tbl) --turns table into list with commas
  92.     local str=''
  93.     for i,v in pairs(tbl)do
  94.         str=str..tostring(v)
  95.         if i~=#tbl then str=str..', ' end
  96.     end
  97.     return str
  98. end
  99.  
  100. std.endat=function(str,val)
  101.     local z=str:find(val)
  102.     if z then
  103.         return str:sub(0,z-string.len(val)),true
  104.     else
  105.         return str,false
  106.     end
  107. end
  108.  
  109. std.first=function(str) return str:sub(1,1) end
  110.  
  111. isAdmin=function(name)
  112.     if name==admin then
  113.         return true
  114.     elseif admins[name]==true then
  115.         return true
  116.     end
  117.     return false
  118. end
  119.  
  120. gPlayers.PlayerAdded:connect(function(player)
  121.     for i,v in pairs(bannedplyrs) do
  122.         if player == v then player:Destroy() end
  123.     end
  124. end)
  125.  
  126. local exec=function(str)
  127.     spawn(function()
  128.         local script, loaderr = loadstring(str)
  129.         if not script then
  130.             error(loaderr)
  131.         else
  132.             script()
  133.         end
  134.     end)
  135. end
  136.  
  137. local findCmd=function(cmd_name)
  138.     for i,v in pairs(cmds)do
  139.         if v.NAME:lower()==cmd_name:lower() or std.inTable(v.ALIAS,cmd_name:lower())then
  140.             return v
  141.         end
  142.     end
  143. end
  144.  
  145. local getCmd=function(msg)
  146.     local cmd,hassplit=std.endat(msg:lower(),split)
  147.     if hassplit then
  148.         return {cmd,true}
  149.     else
  150.         return {cmd,false}
  151.     end
  152. end
  153.  
  154. local getprfx=function(strn)
  155.     if strn:sub(1,string.len(cmdprefix))==cmdprefix then return{'cmd',string.len(cmdprefix)+1}
  156.     elseif strn:sub(1,string.len(scriptprefix))==scriptprefix then return{'exec',string.len(scriptprefix)+1}
  157.     end return
  158. end
  159.  
  160. local getArgs=function(str)
  161.     local args={}
  162.     local new_arg=nil
  163.     local hassplit=nil
  164.     local s=str
  165.     repeat
  166.         new_arg,hassplit=std.endat(s:lower(),split)
  167.         if new_arg~='' then
  168.             args[#args+1]=new_arg
  169.             s=s:sub(string.len(new_arg)+string.len(split)+1)
  170.         end
  171.     until hassplit==false
  172.     return args
  173. end
  174.  
  175. local function execCmd(str, plr)
  176.     local s_cmd
  177.     local a
  178.     local cmd
  179.     s_cmd = getCmd(str) --separate command from string using split {command name,arg bool (for arg system)}
  180.     cmd = findCmd(s_cmd[1]) --get command object {NAME,DESC,{ALIASES},function(args)}
  181.     if cmd == nil then return end
  182.     a = str:sub(string.len(s_cmd[1]) + string.len(split) + 1)--start string "a" after command and split
  183.     local args=getArgs(a)--gets us a nice table of arguments
  184.  
  185.     pcall(function()
  186.     cmd.FUNC(args, plr)
  187.     end)
  188. end
  189.  
  190. function do_exec(str,plr)
  191.     if not isAdmin(plr.Name)then return end
  192.    
  193.     str=str:gsub('/e ','')--remove "/e " the easy way!
  194.  
  195.     local t=getprfx(str)
  196.     if t==nil then return end
  197.     str=str:sub(t[2])
  198.     if t[1]=='exec' then
  199.         exec(str)
  200.     elseif t[1]=='cmd' then
  201.         execCmd(str, plr)
  202.     end
  203. end
  204.  
  205. updateevents()
  206. _G.exec_cmd = execCmd
  207. --game.Players.LocalPlayer.Chatted:connect(doexec)
  208.  
  209. local _char=function(plr_name)
  210.     for i,v in pairs(game.Players:GetChildren())do
  211.         if v:IsA'Player'then
  212.             if v.Name==plr_name then return v.Character end
  213.         end
  214.     end
  215.     return
  216. end
  217.  
  218. local _plr=function(plr_name)
  219.     for i,v in pairs(game.Players:GetChildren())do
  220.         if v:IsA'Player'then
  221.             if v.Name==plr_name then return v end
  222.         end
  223.     end
  224.     return
  225. end
  226.  
  227. function addcmd(name,desc,alias,func)
  228.     cmds[#cmds+1]=
  229.     {
  230.         NAME=name;
  231.         DESC=desc;
  232.         ALIAS=alias;
  233.         FUNC=func;
  234.     }
  235. end
  236.  
  237. local function getPlayer(name)
  238.     local nameTable = {}
  239.     name=name:lower()
  240.     if name == "me" then
  241.         return {admin}
  242.     elseif name == "others" then
  243.         for i,v in pairs(gPlayers:GetChildren()) do
  244.             if v:IsA'Player'then
  245.                 if v.Name~=admin then
  246.                     nameTable[#nameTable+1]=v.Name
  247.                 end
  248.             end
  249.         end
  250.     elseif name == "all" then
  251.         for i,v in pairs(gPlayers:GetChildren()) do
  252.             if v:IsA'Player'then
  253.                 nameTable[#nameTable+1]=v.Name
  254.             end
  255.         end
  256.     else
  257.         for i,v in pairs(gPlayers:GetChildren()) do
  258.             local lname = v.Name:lower()
  259.             local i,j = lname:find(name)
  260.             if i == 1 then
  261.                 return {v.Name}
  262.             end
  263.         end
  264.     end
  265.     return nameTable
  266. end
  267.  
  268. -- commands --
  269.  
  270. addcmd('ff',"ff's a player",{},
  271. function(args)
  272.     local players=getPlayer(args[1])
  273.     for i,v in pairs(players)do
  274.         local pchar=_char(v)
  275.         Instance.new("ForceField", pchar)
  276.     end
  277. end)
  278.  
  279. addcmd('noff',"unff's a player",{'unff'},
  280. function(args)
  281.     local players=getPlayer(args[1])
  282.     for i,v in pairs(players)do
  283.         local pchar=_char(v)
  284.         for j,v1 in pairs(pchar:GetChildren()) do
  285.             if v1:IsA("ForceField") then
  286.                 v1:Destroy()
  287.             end
  288.         end
  289.     end
  290. end)
  291.  
  292. addcmd('fire','set a player on fire',{},
  293. function(args)
  294.     local players=getPlayer(args[1])
  295.     for i,v in pairs(players)do
  296.         local pchar=_char(v)
  297.         Instance.new("Fire", pchar.Torso)
  298.     end
  299. end)
  300.  
  301. addcmd('nofire','extinguish a player',{'unfire'},
  302. function(args)
  303.     local players=getPlayer(args[1])
  304.     for i,v in pairs(players)do
  305.         local pchar=_char(v)
  306.         for j,v1 in pairs(pchar.Torso:GetChildren()) do
  307.             if v1:IsA("Fire") then
  308.                 v1:Destroy()
  309.             end
  310.         end
  311.     end
  312. end)
  313.  
  314. addcmd('sp','give a player sparkles',{},
  315. function(args)
  316.     local players=getPlayer(args[1])
  317.     for i,v in pairs(players)do
  318.         local pchar=_char(v)
  319.         Instance.new("Sparkles", pchar.Torso)
  320.     end
  321. end)
  322.  
  323. addcmd('nosp','remove sparkles from a player',{'unsp'},
  324. function(args)
  325.     local players=getPlayer(args[1])
  326.     for i,v in pairs(players)do
  327.         local pchar=_char(v)
  328.         for j,v1 in pairs(pchar.Torso:GetChildren()) do
  329.             if v1:IsA("Sparkles") then
  330.                 v1:Destroy()
  331.             end
  332.         end
  333.     end
  334. end)
  335.  
  336. addcmd('smoke','give a player smoke',{},
  337. function(args)
  338.     local players=getPlayer(args[1])
  339.     for i,v in pairs(players)do
  340.         local pchar=_char(v)
  341.         Instance.new("Smoke", pchar.Torso)
  342.     end
  343. end)
  344.  
  345. addcmd('nosmoke','remove smoke from a player',{},
  346. function(args)
  347.     local players=getPlayer(args[1])
  348.     for i,v in pairs(players)do
  349.         local pchar=_char(v)
  350.         for j,v1 in pairs(pchar.Torso:GetChildren()) do
  351.             if v1:IsA("Smoke") then
  352.                 v1:Destroy()
  353.             end
  354.         end
  355.     end
  356. end)
  357.  
  358. addcmd('btools','gives a player btools',{},
  359. function(args)
  360.     local players=getPlayer(args[1])
  361.     if players ~= nil then
  362.         for i, v in pairs(players) do
  363.             Instance.new("HopperBin", gPlayers[v].Backpack).BinType = 2
  364.             Instance.new("HopperBin", gPlayers[v].Backpack).BinType = 3
  365.             Instance.new("HopperBin", gPlayers[v].Backpack).BinType = 4
  366.         end
  367.     end
  368. end)
  369.  
  370. addcmd('god','gods player',{},
  371. function(args)
  372.     local players=getPlayer(args[1])
  373.     for i,v in pairs(players)do
  374.         local pchar=_char(v)
  375.         if pchar then pchar.Humanoid.MaxHealth=math.huge end
  376.     end
  377. end)
  378.  
  379. addcmd('sgod','silently gods player',{},
  380. function(args)
  381.     local players=getPlayer(args[1])
  382.     for i,v in pairs(players)do
  383.         local pchar=_char(v)
  384.         spawn(function()
  385.             pchar.Humanoid.MaxHealth = 10000000
  386.             wait()
  387.             pchar.Humanoid.Health = 10000000
  388.         end)
  389.     end
  390. end)
  391.  
  392. addcmd('ungod','removes god from a player',{},
  393. function(args)
  394.     local players=getPlayer(args[1])
  395.     for i,v in pairs(players)do
  396.         local pchar=_char(v)
  397.         if pchar then
  398.             pchar.Humanoid.MaxHealth=100
  399.             pchar.Humanoid.Health=100
  400.         end
  401.     end
  402. end)
  403.  
  404. addcmd('heal','resets a players health',{},
  405. function(args)
  406.     local players=getPlayer(args[1])
  407.     for i,v in pairs(players)do
  408.         local pchar=_char(v)
  409.         if pchar then pchar.Humanoid.Health=pchar.Humanoid.MaxHealth;end
  410.     end
  411. end)
  412.  
  413. addcmd('frz','freezes a player',{},
  414. function(args)
  415.     local players = getPlayer(args[1])
  416.     if players ~= nil then
  417.         for i, v in pairs(players) do
  418.             _char(v).Torso.Anchored = true
  419.         end
  420.     end
  421. end)
  422.  
  423. addcmd('thaw','freezes a player',{},
  424. function(args)
  425.     local players = getPlayer(args[1])
  426.     if players ~= nil then
  427.         for i, v in pairs(players) do
  428.             _char(v).Torso.Anchored = false
  429.         end
  430.     end
  431. end)
  432.  
  433. addcmd('kill','kills a player',{},
  434. function(args)
  435.     local players=getPlayer(args[1])
  436.     for i,v in pairs(players)do
  437.         local pchar=_char(v)
  438.         if pchar then pchar.Humanoid.MaxHealth=0;pchar.Humanoid.Health=0;end
  439.     end
  440. end)
  441.  
  442. addcmd('sound','plays a sound',{},
  443. function(args)
  444.     local function dels(instance)
  445.         for i,v in pairs(instance:GetChildren())do
  446.             if v:IsA'Sound'then v:Destroy()end
  447.             dels(v)
  448.         end
  449.     end
  450.     dels(workspace)
  451.  
  452.     local c=args[1]or'stop'
  453.     if std.inTable({'stop'},c:lower())then return end
  454.     local s=Instance.new("Sound", workspace)
  455.     s.Looped = true
  456.     s.SoundId = "rbxassetid://"..c
  457.     s.Volume=1
  458.     s:Play()
  459. end)
  460.  
  461. addcmd('explode','explode a player', {},
  462. function(args)
  463.     local players=getPlayer(args[1])
  464.     for i, v in pairs(players) do
  465.         local char = _char(v)
  466.         if char:FindFirstChild("Torso") then
  467.             Instance.new("Explosion", char).Position = char.Torso.Position                 
  468.         end
  469.     end
  470. end)
  471.  
  472. addcmd('invis','make a player invisible',{},
  473. function(args)
  474.     local players=getPlayer(args[1])
  475.     for i, v in pairs(players) do
  476.         for k, v2 in pairs(_char(v):GetChildren()) do
  477.             if v2.className == "Part" then
  478.                 if v2.Name ~= "HumanoidRootPart" then v2.Transparency = 1 end
  479.             elseif v2.className == "Hat" then
  480.                 if v2:FindFirstChild("Handle") then
  481.                     v2.Handle.Transparency = 1
  482.                 end
  483.             end
  484.             if v2:FindFirstChild("face") then
  485.                 v2.face:Destroy()
  486.             end
  487.         end
  488.     end
  489. end)
  490.  
  491. addcmd('vis','make a player visible',{},
  492. function(args)
  493.     local players=getPlayer(args[1])
  494.     for i, v in pairs(players) do
  495.         for k, v2 in pairs(_char(v):GetChildren()) do
  496.             if v2.className == "Part" then
  497.                 if v2.Name ~= "HumanoidRootPart" then v2.Transparency = 0 end
  498.                 elseif v2.className == "Hat" then
  499.                 if v2:FindFirstChild("Handle") then v2.Handle.Transparency = 0 end
  500.             end
  501.             if v2:FindFirstChild("face") then
  502.                 v2.face:Destroy()
  503.             end
  504.         end
  505.     end
  506. end)
  507.  
  508. addcmd('goto','go to a player',{},
  509. function(args)
  510.     local players=getPlayer(args[1])
  511.     if players ~= nil and _char(players[1]):FindFirstChild("HumanoidRootPart") then
  512.         _char(admin).HumanoidRootPart.CFrame = _char(players[1]).HumanoidRootPart.CFrame
  513.     end
  514. end)
  515.  
  516. addcmd('bring','bring a player to you',{},
  517. function(args)
  518.     local players=getPlayer(args[1])
  519.     for i,v in pairs(players) do
  520.         if _char(v):FindFirstChild("HumanoidRootPart") then
  521.             _char(v).HumanoidRootPart.CFrame = _char(admin).HumanoidRootPart.CFrame
  522.         end
  523.     end
  524. end)
  525.  
  526. addcmd('tp','teleport player 1 to player 2',{},
  527. function(args)
  528.     local players1=getPlayer(args[1])
  529.     local players2=getPlayer(args[2])
  530.     if not players2[1] then return end
  531.     for i,v in pairs(players1) do
  532.         if _char(v):FindFirstChild("HumanoidRootPart") and _char(players2[1]):FindFirstChild("HumanoidRootPart") then
  533.             _char(v).HumanoidRootPart.CFrame = _char(players2[1]).HumanoidRootPart.CFrame
  534.         end    
  535.     end
  536. end)
  537.  
  538. addcmd('charapp','change a players appearance',{},
  539. function(args)
  540.     local players=getPlayer(args[1])
  541.     if not args[1]or not args[2]then return end
  542.     local id=args[2]
  543.     if players ~= nil then
  544.         for i,v in pairs(players) do
  545.             gPlayers[v].CharacterAppearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId="..id
  546.             if _char(v):FindFirstChild("Head") then
  547.                 _char(v).Head:Destroy()
  548.             end
  549.         end
  550.     end
  551. end)
  552.  
  553. addcmd('ws','change a players walkspeed',{},
  554. function(args)
  555.     local players=getPlayer(args[1])
  556.     if not args[1]or not args[2]then return end
  557.     local num=args[2]
  558.     for i,v in pairs(players) do
  559.         if _char(v):FindFirstChild("Humanoid") then
  560.             _char(v).Humanoid.WalkSpeed=tonumber(num)
  561.         end
  562.     end
  563. end)
  564.  
  565. addcmd('time','change the time of day',{},
  566. function(args)
  567.     if not args[1]then return end
  568.     local time_=tonumber(args[1])
  569.    
  570.     game.Lighting:SetMinutesAfterMidnight(time_*60)
  571. end)
  572.  
  573. addcmd('kick','kick a player',{},
  574. function(args)
  575.     local players=getPlayer(args[1])
  576.     for i,v in pairs(players) do
  577.         gPlayers[v]:Destroy()
  578.     end
  579. end)
  580.  
  581. addcmd('ban','ban a player',{},
  582. function(args)
  583.     local players=getPlayer(args[1])
  584.     for i,v in pairs(players) do
  585.         bannedplyrs[#bannedplyrs+1]=v
  586.         gPlayers[v]:Destroy()
  587.     end
  588. end)
  589.  
  590. addcmd('unlockws','unlock the whole workspace',{},
  591. function(args)
  592.     local function unlock(instance)
  593.         for i,v in pairs(instance:GetChildren()) do
  594.             if v:IsA("BasePart") then
  595.                 v.Locked = false
  596.             end
  597.             unlock(v)
  598.         end
  599.     end
  600.     unlock(workspace)
  601. end)
  602.  
  603. addcmd('unanchorws','unanchor the whole workspace',{},
  604. function(args)
  605.    local function unanchor(instance)
  606.         for i,v in pairs(instance:GetChildren()) do
  607.             if v:IsA("BasePart") then
  608.                 v.Anchored=false
  609.             end
  610.             unanchor(v)
  611.         end
  612.     end
  613.     unanchor(workspace)
  614. end)
  615.  
  616. addcmd('hat','give player a hat ingame',{},
  617. function(args)
  618.     if not args[1] or not args[2] then return end
  619.     local players=getPlayer(args[1])
  620.     local id=args[2]
  621.     local hat = game:GetObjects("rbxassetid://"..id)[1]
  622.     if hat:IsA("Hat") then
  623.         for i,v in pairs(players) do
  624.             hat:clone().Parent = _char(v)
  625.         end    
  626.     end
  627.     hat:Destroy()
  628. end)
  629.  
  630. addcmd('gear','give player a gear ingame',{},
  631. function(args)
  632.     spawn(function()
  633.         if not args[1] or not args[2] then return end
  634.         local players=getPlayer(args[1])
  635.         local id=args[2]
  636.         local model = game:GetService("InsertService"):LoadAsset(id)
  637.         for i,v in pairs(players) do
  638.             for _,j in pairs(model:GetChildren()) do
  639.                 if j:IsA("Tool") then
  640.                     j:Clone().Parent = gPlayers[v].Backpack
  641.                 end
  642.             end
  643.         end
  644.         model:Destroy()
  645.     end)
  646. end)
  647.  
  648. addcmd('pstools','give player personal server tools',{},
  649. function(args)
  650.     local players=getPlayer(args[1])
  651.     for i,v in pairs(players) do
  652.         gPlayers[v].PersonalServerRank = 240
  653.     end
  654. end)
  655.  
  656. addcmd('skick','kicks a player by shutting them down, takes a few seconds',{},
  657. function(args)
  658.     local players=getPlayer(args[1])
  659.     for i,v in pairs(players) do
  660.         spawn(function()
  661.             gPlayers[v].PersonalServerRank = 240
  662.             gPlayers[v].Backpack:WaitForChild("ClassicTool")
  663.             gPlayers[v].PersonalServerRank = 0
  664.         end)
  665.     end
  666. end)
  667.  
  668. addcmd('admin','gives a player admin',{},
  669. function(args)
  670.     if not args[1]then return end
  671.     local players=getPlayer(args[1])
  672.     table.foreach(players,function(k,v)
  673.         admins[v]=true
  674.     end)
  675. end)
  676.  
  677. addcmd('unadmin','removes a players admin',{},
  678. function(args)
  679.     if not args[1] then return end
  680.     local players=getPlayer(args[1])
  681.     table.foreach(players,function(k,v)
  682.         admins[v]=nil
  683.     end)
  684. end)
  685.  
  686. --Add commands here:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement