Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ShitApi = {
- cmds = {},
- prefix = ";"
- }
- function ShitApi.addcmd(name, alias, callback)
- if type(alias) == "function" then
- alias, callback = callback, alias
- end
- assert(type(name) == "string", "bad argument #1 to 'addcmd' (string expected got " .. tostring((type(name) == "nil" and "no value") or typeof(name)) .. ") [Cmd:" .. name .. "]")
- assert(type(alias) == "table" or type(alias) == "nil", "bad argument #2 to 'addcmd' (table expected got " .. typeof(args) .. ") [Cmd:" .. name .. "]")
- assert(type(callback) == "function", "bad argument #3 to 'addcmd' (function expected got " .. tostring((type(callback) == "nil" and "no value") or typeof(callback)) .. ") [Cmd:" .. name .. "]")
- if type(alias) ~= "table" then
- alias = {
- alias
- }
- end
- for _, c in pairs({
- name,
- unpack(alias or {})
- }) do
- cmds[c] = callback
- end
- end
- function ShitApi.parsecmd(str, token)
- assert(type(str) == "string", "bad argument #1 to 'parsecmd' (string expected, got " .. tostring((type(str) == "nil" and "no value") or typeof(str)) .. ")")
- assert(type(token) == "string" or type(token) == "nil", "bad argument #2 to 'parsecmd' (string expected, got " .. typeof(token) .. ")")
- token = token or " "
- local args = {}
- local nstr = str
- if string.sub(nstr, 1, string.len(tostring(ShitApi.prefix))):lower() == tostring(ShitApi.prefix):lower() then
- nstr = string.sub(nstr, string.len(tostring(ShitApi.prefix)) + 1)
- end
- if string.sub(nstr, 1, 3) == "/w " then
- nstr = string.sub(nstr, 4)
- end
- nstr = string.match(nstr, "^%s*(.-)%s*$") .. token
- local t = time()
- local escape = false
- while wait() and string.len(nstr) > 0 and time() - t < 10 do
- local s, e = string.find(nstr, token, nil, true)
- local d, r = string.find(nstr, "[[", nil, true)
- if s and d and s > d then
- s, e = r + 1, (string.find(nstr, "]]"))
- if e then
- e = e - 1
- escape = string.sub(nstr, s, e)
- if string.sub(escape, 1, 2) == "[[" then
- escape = string.sub(escape, 3)
- end
- if string.sub(escape, -2) == "]]" then
- escape = string.sub(escape, 1, -3)
- end
- end
- end
- if s and e then
- local cstr = escape or string.sub(nstr, 1, s - 1)
- if cstr ~= "]]" and token ~= cstr and cstr ~= "" then
- table.insert(args, cstr)
- end
- nstr = string.sub(nstr, e + 1)
- escape = false
- elseif nstr ~= "]]" and nstr ~= token and "" ~= nstr then
- table.insert(args, nstr)
- nstr = ""
- break
- else
- nstr = ""
- break
- end
- end
- local cmd = table.remove(args, 1)
- if not cmd then
- return
- end
- local Command = cmds[string.lower(cmd)]
- if type(Command) ~= "function" then
- return warn("Invalid Command:", cmd)
- end
- for i, v in pairs(args) do
- if tonumber(v) then
- v = tonumber(v)
- elseif v == "nil" then
- v = nil
- elseif v == "false" then
- v = false
- elseif v == "true" then
- v = true
- end
- rawset(args, i, v)
- end
- local a, b = pcall(Command, unpack(args))
- if not a and c then
- return warn(Command, ":", c)
- end
- end
- function ShitApi.FindPlayer(plr)
- local Found = {}
- if tostring(plr):lower() == "me" then
- table.insert(Found, game:GetService("Players").LocalPlayer)
- return Found
- elseif tostring(plr):lower() == "all" then
- for _, v in pairs(game:GetService("Players"):GetPlayers()) do
- if v.Name ~= game:GetService("Players").LocalPlayer.Name then
- table.insert(Found, game:GetService("Players")[v.Name])
- end
- end
- return Found
- elseif tostring(plr):lower() == "friends" then
- for i, v in pairs(game:GetService("Players"):GetPlayers()) do
- if v:IsFriendsWith(game:GetService("Players").LocalPlayer.UserId) and v.Name ~= game:GetService("Players").LocalPlayer.Name then
- table.insert(Found, v)
- end
- end
- elseif tostring(plr):lower() == "enemies" then
- for i, v in pairs(game:GetService("Players"):GetPlayers()) do
- if not v:IsFriendsWith(game:GetService("Players").LocalPlayer.UserId) and v.Name ~= game:GetService("Players").LocalPlayer.Name then
- table.insert(Found, v)
- end
- end
- elseif tostring(plr):lower() == "random" then
- table.insert(Found, game:GetService("Players"):GetPlayers()[math.random(1, #game:GetService("Players"):GetPlayers())])
- return Found
- else
- for _, v in pairs(game:GetService("Players"):GetPlayers()) do
- if string.sub(v.Name, 1, #tostring(plr):lower()):lower() == tostring(plr):lower() then
- table.insert(Found, game:GetService("Players")[v.Name])
- end
- end
- end
- return Found
- end
- function ShitApi.Create(arg1, arg2, arg3)
- local sucess, NewInstance = pcall(Instance.new, tostring(arg1), arg2)
- if not sucess then
- return warn("Error:", tostring(NewInstance))
- end
- if arg3 and type(arg3) == "table" then
- for i, v in pairs(arg3) do
- local a, b = pcall(function()
- NewInstance[i] = v
- end)
- if not a then
- return warn("Error:", tostring(b))
- end
- end
- end
- if NewInstance:IsA("Instance") and NewInstance:IsA("GuiBase") and type(syn) == "table" and type(syn.protect_gui) == "function" then
- pcall(syn.protect_gui, NewInstance)
- end
- return NewInstance
- end
Advertisement
Add Comment
Please, Sign In to add comment