Advertisement
HardBandit

Untitled

Dec 23rd, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.06 KB | None | 0 0
  1. --_G.Admin created by databrain
  2. local Admins = {--Set the admins here
  3. "databrain",
  4. "Player1",
  5. "kylletd123"
  6. }
  7. local Banned = {
  8. "Noli", -- Replace "Noli" with whatever you want. Caps doesn't matter.
  9. }
  10. local KeyBinds = {
  11. --["e"] = "explosion 4 500000",
  12. }
  13. local Commands = { -- Add the ID of commands. All commands will appear in this order (After the kick commands)
  14. 125747874, -- Commands command
  15. 125545035, -- Admin command
  16. 125545364, -- Unadmin command
  17. 125733551, -- Kick command
  18. 125736399, -- Ban command
  19. 125853600, -- Unban command
  20. 125733007, -- Team command
  21. 125863127, -- Score command
  22. 125538538, -- Tp command
  23. 125976136, -- Coords command
  24. 125961432, -- Health command
  25. 125961636, -- MaxHealth command
  26. 125973522, -- Walkspeed command
  27. 125753022, -- Explosion command
  28. 125756868, -- Bind command
  29. 125757398, -- Unbind command
  30. 125761354, -- Call command
  31. 125726947, -- S command
  32. 125762622, -- Ls command
  33. 125838090, -- Clear command
  34. 125841639, -- SetAlias command
  35. 125841731, -- ClearAlias command
  36. }
  37. local Aliases = { --Commands that do the same things other commands
  38. ["help"] = "commands",
  39. ["teleport"] = "tp",
  40. ["t"] = "team",
  41. }
  42.  
  43. --[[--------------------------------------------------------------------------------]]--
  44.  
  45. while not _G.ready do wait() end
  46. local CmdList = {}
  47.  
  48. function createCommand(cmd, adminLevel, func, use, isRaw)
  49. if not use then return end
  50. if not isRaw then isRaw = false end
  51. table.insert(CmdList, {cmd, adminLevel, func, use, isRaw})
  52. end
  53.  
  54. function GetTable(tab)
  55. if tab == "Admins" then return Admins end
  56. if tab == "Banned" then return Banned end
  57. if tab == "KeyBinds" then return KeyBinds end
  58. if tab == "Commands" then return Commands end
  59. if tab == "CmdList" then return CmdList end
  60. if tab == "Aliases" then return Aliases end
  61. end
  62.  
  63. function SetKey(tab, key, value)
  64. if tab == "Admins" then Admins[key] = value end
  65. if tab == "Banned" then Banned[key] = value end
  66. if tab == "KeyBinds" then KeyBinds[key] = value end
  67. if tab == "Commands" then Commands[key] = value end
  68. if tab == "CmdList" then CmdList[key] = value end
  69. if tab == "Aliases" then Aliases[key] = value end
  70. end
  71.  
  72. function Insert(tab, value, val)
  73. if val then
  74. if tab == "Admins" then table.insert(Admins, value, val) end
  75. if tab == "Banned" then table.insert(Banned, value, val) end
  76. if tab == "KeyBinds" then table.insert(KeyBinds, value, val) end
  77. if tab == "Commands" then table.insert(Commands, value, val) end
  78. if tab == "CmdList" then table.insert(CmdList, value, val) end
  79. if tab == "Aliases" then table.insert(Aliases, value, val) end
  80. else
  81. if tab == "Admins" then table.insert(Admins, value) end
  82. if tab == "Banned" then table.insert(Banned, value) end
  83. if tab == "KeyBinds" then table.insert(KeyBinds, value) end
  84. if tab == "Commands" then table.insert(Commands, value) end
  85. if tab == "CmdList" then table.insert(CmdList, value) end
  86. if tab == "Aliases" then table.insert(Aliases, value) end
  87. end
  88. end
  89.  
  90. function Remove(tab, num)
  91. if tab == "Admins" then table.remove(Admins, num) end
  92. if tab == "Banned" then table.remove(Banned, num) end
  93. if tab == "KeyBinds" then table.remove(KeyBinds, num) end
  94. if tab == "Commands" then table.remove(Commands, num) end
  95. if tab == "CmdList" then table.remove(CmdList, num) end
  96. if tab == "Aliases" then table.remove(Aliases, num) end
  97. end
  98.  
  99. --[[
  100. _G.Admin are admin commands made by databrain. It requires _G.Function API V1.5 or greater,
  101. found at http://www.roblox.com/G-Functions-API-item?id=123386757. _G.Functions must be
  102. put in any model inside workspace or just inside Workspace. The same applies with _G.Admin.
  103. _G.Admin includes a useful API for other scripters to use, to add admin commands.
  104. ]]
  105.  
  106. --Example command:
  107.  
  108. --[[Commands command by databrain. This is the source. The value SourceCode is loaded,
  109. not the script. All _G.Admin commands must be open source.
  110. ]]
  111.  
  112.  
  113.  
  114. createCommand("kill", 1, function(speaker, ply, team)
  115. if not speaker then return end
  116. if not ply then showUse("kill <player>") return end
  117. if getPlayerGroup(speaker, ply, team) ~= nil then
  118. if #getPlayerGroup(speaker, ply, team) > 0 then
  119. for _,v in pairs(getPlayerGroup(speaker, ply, team)) do
  120. v.Character:BreakJoints()
  121. end
  122. end
  123. return
  124. end
  125. if not getPlayer(ply) then showError("Player Not Found") return end
  126. ply = getPlayer(ply)
  127. if not ply.Character:FindFirstChild("Humanoid") then return end
  128. humanoid = ply.Character.Humanoid
  129. local creator_tag = Instance.new("ObjectValue")
  130. creator_tag.Value = speaker
  131. creator_tag.Name = "creator"
  132. creator_tag.Parent = humanoid
  133. ply.Character:BreakJoints()
  134. wait(1)
  135. if humanoid ~= nil then
  136. local tag = humanoid:findFirstChild("creator")
  137. if tag ~= nil then
  138. tag:Destroy()
  139. end
  140. end
  141. end, "kill <player>")
  142.  
  143. --Do not edit this last part. This is what detects commands.
  144.  
  145. function showError(err)
  146. if not err then return end
  147. print("Error:", err)
  148. end
  149.  
  150. function showUse(use)
  151. if not use then return end
  152. print("Use:", use)
  153. end
  154.  
  155. function getPlayer(ply)
  156. for _,v in pairs(game.Players:getChildren()) do
  157. if v.Name:sub(1, ply:len()):lower() == ply:lower() then return v end
  158. end
  159. end
  160.  
  161. function getAdminLevel(ply)
  162. local level = 0
  163. for _,v in pairs(Admins) do
  164. if ply.Name:lower() == v:lower() then
  165. level = 1
  166. end
  167. end
  168. return level
  169. end
  170.  
  171. function split(str, pat)
  172. local t = {} -- NOTE: use {n = 0} in Lua-5.0
  173. local fpat = "(.-)" .. pat
  174. local last_end = 1
  175. local s, e, cap = str:find(fpat, 1)
  176. while s do
  177. if s ~= 1 or cap ~= "" then
  178. table.insert(t,cap)
  179. end
  180. last_end = e+1
  181. s, e, cap = str:find(fpat, last_end)
  182. end
  183. if last_end <= #str then
  184. cap = str:sub(last_end)
  185. table.insert(t, cap)
  186. end
  187. return t
  188. end
  189.  
  190. function getPlayerGroup(speaker, group, team)
  191. local listed = {}
  192. group = group:lower()
  193. if group == "all" then
  194. for _,v in pairs(game.Players:getChildren()) do
  195. table.insert(listed, v)
  196. end
  197. if #listed > 0 then
  198. return listed
  199. end
  200. elseif group == "admins" then
  201. for _,v in pairs(game.Players:getChildren()) do
  202. if getAdminLevel(v) > 0 then
  203. table.insert(listed, v)
  204. end
  205. end
  206. if #listed > 0 then
  207. return listed
  208. end
  209. elseif group == "nonadmins" then
  210. for _,v in pairs(game.Players:getChildren()) do
  211. if getAdminLevel(v) == 0 then
  212. table.insert(listed, v)
  213. end
  214. end
  215. if #listed > 0 then
  216.  
  217. return listed
  218. end
  219. elseif group == "others" then
  220. for _,v in pairs(game.Players:getChildren()) do
  221. if v ~= speaker then
  222. table.insert(listed, v)
  223. end
  224. end
  225. if #listed > 0 then
  226. return listed
  227. end
  228. elseif group == "me" then
  229. table.insert(listed, speaker)
  230. if #listed > 0 then
  231. return listed
  232. end
  233. elseif group == "random" or group == "rand" then
  234. if #players > 0 then
  235. table.insert(listed, players[math.random(1, #players)])
  236. end
  237. if #listed > 0 then
  238. return listed
  239. end
  240. elseif group == "team" then
  241. if not team then return end
  242. for _,v in pairs(game.Players:getChildren()) do
  243. if #game.Teams:getChildren() > 0 then
  244. for _,t in pairs(game.Teams:getChildren()) do
  245. if t.Name:sub(1, team:len()):lower() == team:lower() then
  246. if v.TeamColor == t.TeamColor then
  247. table.insert(listed, v)
  248. end
  249. end
  250. end
  251. end
  252. end
  253. if #listed > 0 then
  254. return listed
  255. end
  256. elseif group == "score" then
  257. if not team then return end
  258. for _,v in pairs(game.Players:getChildren()) do
  259. if v:findFirstChild("leaderstats") then
  260. if #split(team, ">") == 2 then
  261. local score = split(team, ">")[1]
  262. local num = split(team, ">")[2]
  263. local gScore
  264. for _,s in pairs(v.leaderstats:getChildren()) do
  265. if s.Name:sub(1, score:len()):lower() == score:lower() then
  266. gScore = s
  267. break
  268. end
  269. end
  270. if gScore then
  271. if tonumber(gScore.Value) and tonumber(num) then
  272. if tonumber(gScore.Value) > tonumber(num) then
  273. table.insert(listed, v)
  274. end
  275. end
  276. end
  277. elseif #split(team, "<") == 2 then
  278. local score = split(team, "<")[1]
  279. local num = split(team, "<")[2]
  280. local gScore
  281. for _,s in pairs(v.leaderstats:getChildren()) do
  282. if s.Name:sub(1, score:len()):lower() == score:lower() then
  283. gScore = s
  284. break
  285. end
  286. end
  287. if gScore then
  288. if tonumber(gScore.Value) and tonumber(num) then
  289. if tonumber(gScore.Value) < tonumber(num) then
  290. table.insert(listed, v)
  291. end
  292. end
  293. end
  294. elseif #split(team, "=") == 2 then
  295. local score = split(team, "=")[1]
  296. local num = split(team, "=")[2]
  297. local gScore
  298. for _,s in pairs(v.leaderstats:getChildren()) do
  299. if s.Name:sub(1, score:len()):lower() == score:lower() then
  300. gScore = s
  301. break
  302. end
  303. end
  304. if gScore then
  305. if tonumber(gScore.Value) and tonumber(num) then
  306. if tonumber(gScore.Value) == tonumber(num) then
  307. table.insert(listed, v)
  308. end
  309. end
  310. end
  311. elseif #split(team, "==") == 2 then
  312. local score = split(team, "==")[1]
  313. local num = split(team, "==")[2]
  314. local gScore
  315. for _,s in pairs(v.leaderstats:getChildren()) do
  316. if s.Name:sub(1, score:len()):lower() == score:lower() then
  317. gScore = s
  318. break
  319. end
  320. end
  321. if gScore then
  322. if tonumber(gScore.Value) and tonumber(num) then
  323. if tonumber(gScore.Value) == tonumber(num) then
  324. table.insert(listed, v)
  325. end
  326. end
  327. end
  328. elseif #split(team, ">=") == 2 then
  329. local score = split(team, ">=")[1]
  330. local num = split(team, ">=")[2]
  331. local gScore
  332. for _,s in pairs(v.leaderstats:getChildren()) do
  333. if s.Name:sub(1, score:len()):lower() == score:lower() then
  334. gScore = s
  335. break
  336. end
  337. end
  338. if gScore then
  339. if tonumber(gScore.Value) and tonumber(num) then
  340. if tonumber(gScore.Value) >= tonumber(num) then
  341. table.insert(listed, v)
  342. end
  343. end
  344. end
  345. elseif #split(team, "<=") == 2 then
  346. local score = split(team, "<=")[1]
  347. local num = split(team, "<=")[2]
  348. local gScore
  349. for _,s in pairs(v.leaderstats:getChildren()) do
  350. if s.Name:sub(1, score:len()):lower() == score:lower() then
  351. gScore = s
  352. break
  353. end
  354. end
  355. if gScore then
  356. if tonumber(gScore.Value) and tonumber(num) then
  357. if tonumber(gScore.Value) <= tonumber(num) then
  358. table.insert(listed, v)
  359. end
  360. end
  361. end
  362. end
  363. end
  364. end
  365. if #listed > 0 then
  366. return listed
  367. end
  368. end
  369. return
  370. end
  371.  
  372. function GetCommandSources() --Credit to Animinus for this function.
  373. local InsertService = game:GetService("InsertService")
  374. if #Commands < 1 then return end
  375. for _,id in pairs(Commands) do
  376. local children = {}
  377. -- gets children from asset or object path
  378. if type(id) == "number" and id > 0 and math.floor(id) == id then
  379. local asset = InsertService:LoadAsset(id)
  380. if asset then
  381. children = asset:GetChildren()
  382. asset.Parent = nil
  383. else
  384. print("Command source: \"",id,"\": cannot access asset")
  385. end
  386. elseif pcall(function() return id:IsA"Instance" end) then -- that type check would be useful
  387. children = {id}
  388. else
  389. print("Command source: \"",id,"\": not an asset id or Object path")
  390. end
  391. -- if the 1st child is a model; make the children the model's children
  392. local first = children[1]
  393. if first then
  394. if first.className == "Model" or first.className == "Backpack" then
  395. if #children == 1 then
  396. local fchildren = first:GetChildren()
  397. if #fchildren > 0 then
  398. children = fchildren
  399. else
  400. print("Command source: \"",id,"\": model does not contain any scripts")
  401. end
  402. else
  403. print("Command source: \"",id,"\": model contains invalid objects")
  404. end
  405. end
  406. else
  407. print("Command source: \"",id,"\": model contains no objects")
  408. end
  409. -- finally process children
  410. for _,child in pairs(children) do
  411. if child.className == "Script" then
  412. if child:FindFirstChild("SourceCode") then
  413. local func,msg = loadstring(child.SourceCode.Value,"")
  414. if func then
  415. func()
  416. else
  417. print("Command source: \"",id,"\": syntax error: ",msg)
  418. end
  419. else
  420. print("Command source: \"",id,"\": model contains invalid objects")
  421. end
  422. else
  423. print("Command source: \"",id,"\": model contains invalid objects")
  424. end
  425. end
  426. end
  427. end
  428.  
  429. GetCommandSources()
  430.  
  431. function checkBanned()
  432. for _,ply in pairs(game.Players:getChildren()) do
  433. if Banned and #Banned > 0 then
  434. for _,v in pairs(Banned) do
  435. if v:lower() == ply.Name:lower() then
  436. ply:Destroy()
  437. end
  438. end
  439. end
  440. end
  441. end
  442.  
  443. game.Players.PlayerAdded:connect(function(p)
  444. print("Player", p)
  445. checkBanned()
  446. p:GetMouse().KeyDown:connect(function(key)
  447. key = key:lower()
  448. for k,v in pairs(KeyBinds) do
  449. if k == key and getAdminLevel(p) == 1 then
  450. _G.Call("Command", v, p)
  451. end
  452. end
  453. end)
  454. end)
  455.  
  456. checkBanned()
  457. for _,p in pairs(game.Players:getChildren()) do
  458. p:GetMouse().KeyDown:connect(function(key)
  459. key = key:lower()
  460. for k,v in pairs(KeyBinds) do
  461. if k == key and getAdminLevel(p) == 1 then
  462. _G.Call("Command", v, p)
  463. end
  464. end
  465. end)
  466. end
  467.  
  468. _G.Connect("Command"):connect(function(...)
  469. args = {...}
  470. if #args == 2 then
  471. local cmds = split(args[1], " ")
  472. local ply = args[2]
  473. if #cmds > 0 then
  474. local cmd = cmds[1]:lower()
  475. local cmdArgs = {}
  476. for i,v in ipairs(cmds) do
  477. if i > 1 then
  478. table.insert(cmdArgs, v)
  479. end
  480. end
  481. for k,v in pairs(Aliases) do
  482. if k == cmd then
  483. cmd = v break
  484. end
  485. end
  486. for _,v in pairs(CmdList) do
  487. if v[1] == cmd then
  488. if getAdminLevel(ply) >= v[2] then
  489. if v[5] == false then
  490. for i,v in ipairs(cmdArgs) do
  491. cmdArgs[i] = v:lower()
  492. end
  493. --pcall(function()
  494. v[3](ply, unpack(cmdArgs))
  495. --end)
  496. else
  497. local raw = ""
  498. for _,v in pairs(cmdArgs) do
  499. raw = raw .. v .. " "
  500. end
  501. v[3](ply, raw)
  502. end
  503. end
  504. end
  505. end
  506. end
  507. end
  508. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement