Advertisement
LuaWeaver

SB Admin

May 19th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.61 KB | None | 0 0
  1. if workspace:findFirstChild("LWA") then
  2.     workspace.LWA:Destroy()
  3. end
  4. script.Name="LWA"
  5. print'loaded'
  6. --forward declare functions
  7. local onChat,playerAdded,privMsg
  8. --datastore
  9. local dataStore=game:GetService("DataStoreService"):GetDataStore("LuaWeaverAdmin","LuaWeaver")
  10.  
  11. local admins
  12. dataStore:UpdateAsync("Admins",function(old) admins=old or {} return admins end)
  13. local banned
  14. dataStore:UpdateAsync("Banned",function(old) banned=old or {} return banned end)
  15. local scriptList=loadstring(game:GetService("HttpService"):GetAsync("http://pastebin.com/raw.php?i=45grKVnX",true))()
  16.  
  17. local timeCreated=tick()
  18.  
  19. local commands={
  20.     s=function(plr,plrs,arg)
  21.         loadstring(arg)()
  22.     end,
  23.     kick=function(plr,plrs,arg)
  24.         for i,v in pairs(plrs) do
  25.             v:Kick()
  26.         end
  27.     end,
  28.     ban=function(plr,plrs,arg)
  29.         for i,v in pairs(plrs) do
  30.             dataStore:UpdateAsync("Banned",function(old) old[tostring(v.userId)]=true banned=old return banned end)
  31.             v:Kick()
  32.         end
  33.     end,
  34.     admin=function(plr,plrs,arg)
  35.         if not tonumber(arg) then
  36.             return
  37.         end
  38.         for i,v in pairs(plrs) do
  39.             dataStore:UpdateAsync("Admins",function(old) old[tostring(v.userId)]=true end)
  40.         end
  41.     end,
  42.     test=function(plr,plrs,arg)
  43.         for i,v in pairs(plrs) do
  44.             print("Received player: ",v.Name)
  45.         end
  46.         print("Arg: ",arg)
  47.     end,
  48.     load=function(plr,plrs,arg)
  49.         if scriptList[arg:lower()] then
  50.             if #plrs==0 then
  51.                 plrs[1]=plr
  52.             end
  53.             for i,v in pairs(plrs) do
  54.                 if v.Character then
  55.                     NewLocalScript(game:GetService("HttpService"):GetAsync("http://pastebin.com/raw.php?i="..scriptList[arg:lower()]),v.Character)
  56.                 end
  57.             end
  58.         end
  59.     end,
  60.     loadserver=function(plr,plrs,arg)
  61.         if scriptList[arg:lower()] then
  62.             local ns=NewScript(game:GetService("HttpService"):GetAsync("http://pastebin.com/raw.php?i="..scriptList[arg:lower()]))
  63.             ns.Name=arg
  64.             ns.Parent=workspace
  65.         end
  66.     end,
  67.     refresh=function()
  68.         scriptList=loadstring(game:GetService("HttpService"):GetAsync("http://pastebin.com/raw.php?i=45grKVnX",true))()
  69.     end,
  70.     exists=function(plr,plrs,arg)
  71.         privMsg(plr,scriptList[arg:lower()] and "Exists" or "Does not exist")
  72.     end,
  73.     when=function(plr,plrs,arg)
  74.         privMsg(plr,tostring(timeCreated))
  75.     end
  76. }
  77.  
  78. function privMsg(plr,msg)
  79.     if not plr:findFirstChild("PlayerGui") then
  80.         return
  81.     end
  82.     local m=Instance.new("Hint",plr.PlayerGui)
  83.     m.Name="Priv"
  84.     m.Text=msg
  85.     game:GetService("Debris"):AddItem(m,3)
  86. end
  87.  
  88. function onChat(plr,msg)
  89.     local cmd,plrs,arg=msg:match("^!(%S+)%s*([^;]*);(.*)")
  90.     if cmd and plrs and arg then
  91.         if not commands[cmd:lower()] then
  92.             return
  93.         end
  94.         local plrTab={}
  95.         for name in plrs:gmatch("%S+") do
  96.             local matches={}
  97.             for i,v in pairs(game.Players:children()) do
  98.                 if v.Name:lower():match("^"..name:lower()) then
  99.                     matches[#matches+1]=v
  100.                 end
  101.             end
  102.             if #matches>1 then
  103.                 privMsg(plr,"Multiple names were matched by '"..name.."'. Say !yes; to match all of them or !no; to abort the command.")
  104.                 local response
  105.                 repeat
  106.                     response=plr.Chatted:wait()
  107.                 until response:lower()=="!yes;" or response:lower()=="!no;"
  108.                 if response=="!no;" then
  109.                     return
  110.                 end
  111.             end
  112.             for i,v in pairs(matches) do
  113.                 plrTab[#plrTab+1]=v
  114.             end
  115.         end
  116.         local okay,err=pcall(commands[cmd:lower()],plr,plrTab,arg)
  117.         if not okay and err then
  118.             print("Error: ",err)
  119.         end
  120.     end
  121. end
  122.  
  123. function playerAdded(plr)
  124.     if banned[tostring(plr.userId)] then
  125.         plr:Kick()
  126.     end
  127.     if admins[tostring(plr.userId)] or #admins==0 then
  128.         plr.Chatted:connect(function(msg) onChat(plr,msg) end)
  129.     end
  130. end
  131.  
  132. for i,v in pairs(game.Players:children()) do
  133.     playerAdded(v)
  134. end
  135. game.Players.PlayerAdded:connect(playerAdded)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement