vTrxgicv

Untitled

May 3rd, 2020
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. ShitApi = {
  2. cmds = {},
  3. prefix = ";"
  4. }
  5. function ShitApi.addcmd(name, alias, callback)
  6. if type(alias) == "function" then
  7. alias, callback = callback, alias
  8. end
  9. assert(type(name) == "string", "bad argument #1 to 'addcmd' (string expected got " .. tostring((type(name) == "nil" and "no value") or typeof(name)) .. ") [Cmd:" .. name .. "]")
  10. assert(type(alias) == "table" or type(alias) == "nil", "bad argument #2 to 'addcmd' (table expected got " .. typeof(args) .. ") [Cmd:" .. name .. "]")
  11. assert(type(callback) == "function", "bad argument #3 to 'addcmd' (function expected got " .. tostring((type(callback) == "nil" and "no value") or typeof(callback)) .. ") [Cmd:" .. name .. "]")
  12. if type(alias) ~= "table" then
  13. alias = {
  14. alias
  15. }
  16. end
  17. for _, c in pairs({
  18. name,
  19. unpack(alias or {})
  20. }) do
  21. cmds[c] = callback
  22. end
  23. end
  24. function ShitApi.parsecmd(str, token)
  25. assert(type(str) == "string", "bad argument #1 to 'parsecmd' (string expected, got " .. tostring((type(str) == "nil" and "no value") or typeof(str)) .. ")")
  26. assert(type(token) == "string" or type(token) == "nil", "bad argument #2 to 'parsecmd' (string expected, got " .. typeof(token) .. ")")
  27. token = token or " "
  28. local args = {}
  29. local nstr = str
  30. if string.sub(nstr, 1, string.len(tostring(ShitApi.prefix))):lower() == tostring(ShitApi.prefix):lower() then
  31. nstr = string.sub(nstr, string.len(tostring(ShitApi.prefix)) + 1)
  32. end
  33. if string.sub(nstr, 1, 3) == "/w " then
  34. nstr = string.sub(nstr, 4)
  35. end
  36. nstr = string.match(nstr, "^%s*(.-)%s*$") .. token
  37. local t = time()
  38. local escape = false
  39. while wait() and string.len(nstr) > 0 and time() - t < 10 do
  40. local s, e = string.find(nstr, token, nil, true)
  41. local d, r = string.find(nstr, "[[", nil, true)
  42. if s and d and s > d then
  43. s, e = r + 1, (string.find(nstr, "]]"))
  44. if e then
  45. e = e - 1
  46. escape = string.sub(nstr, s, e)
  47. if string.sub(escape, 1, 2) == "[[" then
  48. escape = string.sub(escape, 3)
  49. end
  50. if string.sub(escape, -2) == "]]" then
  51. escape = string.sub(escape, 1, -3)
  52. end
  53. end
  54. end
  55. if s and e then
  56. local cstr = escape or string.sub(nstr, 1, s - 1)
  57. if cstr ~= "]]" and token ~= cstr and cstr ~= "" then
  58. table.insert(args, cstr)
  59. end
  60. nstr = string.sub(nstr, e + 1)
  61. escape = false
  62. elseif nstr ~= "]]" and nstr ~= token and "" ~= nstr then
  63. table.insert(args, nstr)
  64. nstr = ""
  65. break
  66. else
  67. nstr = ""
  68. break
  69. end
  70. end
  71. local cmd = table.remove(args, 1)
  72. if not cmd then
  73. return
  74. end
  75. local Command = cmds[string.lower(cmd)]
  76. if type(Command) ~= "function" then
  77. return warn("Invalid Command:", cmd)
  78. end
  79. for i, v in pairs(args) do
  80. if tonumber(v) then
  81. v = tonumber(v)
  82. elseif v == "nil" then
  83. v = nil
  84. elseif v == "false" then
  85. v = false
  86. elseif v == "true" then
  87. v = true
  88. end
  89. rawset(args, i, v)
  90. end
  91. local a, b = pcall(Command, unpack(args))
  92. if not a and c then
  93. return warn(Command, ":", c)
  94. end
  95. end
  96. function ShitApi.FindPlayer(plr)
  97. local Found = {}
  98. if tostring(plr):lower() == "me" then
  99. table.insert(Found, game:GetService("Players").LocalPlayer)
  100. return Found
  101. elseif tostring(plr):lower() == "all" then
  102. for _, v in pairs(game:GetService("Players"):GetPlayers()) do
  103. if v.Name ~= game:GetService("Players").LocalPlayer.Name then
  104. table.insert(Found, game:GetService("Players")[v.Name])
  105. end
  106. end
  107. return Found
  108. elseif tostring(plr):lower() == "friends" then
  109. for i, v in pairs(game:GetService("Players"):GetPlayers()) do
  110. if v:IsFriendsWith(game:GetService("Players").LocalPlayer.UserId) and v.Name ~= game:GetService("Players").LocalPlayer.Name then
  111. table.insert(Found, v)
  112. end
  113. end
  114. elseif tostring(plr):lower() == "enemies" then
  115. for i, v in pairs(game:GetService("Players"):GetPlayers()) do
  116. if not v:IsFriendsWith(game:GetService("Players").LocalPlayer.UserId) and v.Name ~= game:GetService("Players").LocalPlayer.Name then
  117. table.insert(Found, v)
  118. end
  119. end
  120. elseif tostring(plr):lower() == "random" then
  121. table.insert(Found, game:GetService("Players"):GetPlayers()[math.random(1, #game:GetService("Players"):GetPlayers())])
  122. return Found
  123. else
  124. for _, v in pairs(game:GetService("Players"):GetPlayers()) do
  125. if string.sub(v.Name, 1, #tostring(plr):lower()):lower() == tostring(plr):lower() then
  126. table.insert(Found, game:GetService("Players")[v.Name])
  127. end
  128. end
  129. end
  130. return Found
  131. end
  132. function ShitApi.Create(arg1, arg2, arg3)
  133. local sucess, NewInstance = pcall(Instance.new, tostring(arg1), arg2)
  134. if not sucess then
  135. return warn("Error:", tostring(NewInstance))
  136. end
  137. if arg3 and type(arg3) == "table" then
  138. for i, v in pairs(arg3) do
  139. local a, b = pcall(function()
  140. NewInstance[i] = v
  141. end)
  142. if not a then
  143. return warn("Error:", tostring(b))
  144. end
  145. end
  146. end
  147. if NewInstance:IsA("Instance") and NewInstance:IsA("GuiBase") and type(syn) == "table" and type(syn.protect_gui) == "function" then
  148. pcall(syn.protect_gui, NewInstance)
  149. end
  150. return NewInstance
  151. end
Advertisement
Add Comment
Please, Sign In to add comment