Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- ╔═══════════════════════════════════════════════════════════╗
- ║ SISTEMA UNIFICADO DE SCRIPTS v1.0.0 ║
- ║ Gerenciador Multi-Script Robusto ║
- ║ By: NickZScripts ║
- ╚═══════════════════════════════════════════════════════════╝
- 📋 Scripts Carregados:
- 1️⃣ https://pastebin.com/raw/PUN7TTtj
- 2️⃣ https://pastebin.com/raw/U1qgKfw6
- 3️⃣ https://pastebin.com/raw/hvRNk6ak
- ✅ Sistema Anti-Conflitos
- ✅ Ambientes Isolados
- ✅ Gerenciamento de Erros
- ✅ Logs Detalhados
- ]]
- --// ========== SERVICES ========== //
- local HttpService = game:GetService("HttpService")
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- --// ========== CONFIGURAÇÕES ========== //
- local LocalPlayer = Players.LocalPlayer
- local SYSTEM_VERSION = "1.0.0"
- --// ========== LISTA DE SCRIPTS ========== //
- local ScriptList = {
- {
- Name = "Script 1 - PUN7TTtj",
- URL = "https://pastebin.com/raw/PUN7TTtj",
- Priority = 1,
- Enabled = true,
- LoadTimeout = 10,
- RetryAttempts = 3,
- },
- {
- Name = "Script 2 - U1qgKfw6",
- URL = "https://pastebin.com/raw/U1qgKfw6",
- Priority = 2,
- Enabled = true,
- LoadTimeout = 10,
- RetryAttempts = 3,
- },
- {
- Name = "Script 3 - hvRNk6ak",
- URL = "https://pastebin.com/raw/hvRNk6ak",
- Priority = 3,
- Enabled = true,
- LoadTimeout = 10,
- RetryAttempts = 3,
- },
- }
- --// ========== SISTEMA DE LOGS AVANÇADO ========== //
- local Logger = (function()
- local logs = {}
- local maxLogs = 1000
- local colors = {
- INFO = "\27[36m", -- Cyan
- SUCCESS = "\27[32m", -- Green
- WARNING = "\27[33m", -- Yellow
- ERROR = "\27[31m", -- Red
- DEBUG = "\27[35m", -- Magenta
- RESET = "\27[0m"
- }
- local function getTimestamp()
- return os.date("%H:%M:%S")
- end
- local function log(level, message, scriptName)
- local timestamp = getTimestamp()
- local prefix = scriptName and ("[" .. scriptName .. "] ") or ""
- local fullMessage = string.format("[%s] %s%s%s", timestamp, prefix, level, message)
- table.insert(logs, {
- timestamp = timestamp,
- level = level,
- message = message,
- scriptName = scriptName,
- fullMessage = fullMessage
- })
- if #logs > maxLogs then
- table.remove(logs, 1)
- end
- local color = colors[level] or colors.RESET
- print(color .. fullMessage .. colors.RESET)
- end
- return {
- Info = function(msg, script) log("INFO", msg, script) end,
- Success = function(msg, script) log("SUCCESS", msg, script) end,
- Warning = function(msg, script) log("WARNING", msg, script) end,
- Error = function(msg, script) log("ERROR", msg, script) end,
- Debug = function(msg, script) log("DEBUG", msg, script) end,
- GetLogs = function() return logs end,
- Clear = function() logs = {} end
- }
- end)()
- --// ========== SISTEMA DE DOWNLOAD ROBUSTO ========== //
- local Downloader = (function()
- local cache = {}
- local function downloadWithRetry(url, maxAttempts, timeout)
- maxAttempts = maxAttempts or 3
- timeout = timeout or 10
- for attempt = 1, maxAttempts do
- local success, result = pcall(function()
- Logger.Debug("Tentativa " .. attempt .. "/" .. maxAttempts .. " de download: " .. url)
- local startTime = tick()
- local scriptContent = game:HttpGet(url)
- local downloadTime = tick() - startTime
- if not scriptContent or scriptContent == "" then
- error("Conteúdo vazio recebido")
- end
- Logger.Success(string.format("Download completo em %.2fs (%d bytes)", downloadTime, #scriptContent))
- return scriptContent
- end)
- if success then
- cache[url] = result
- return true, result
- else
- Logger.Warning("Tentativa " .. attempt .. " falhou: " .. tostring(result))
- if attempt < maxAttempts then
- local waitTime = attempt * 2
- Logger.Info("Aguardando " .. waitTime .. "s antes de tentar novamente...")
- task.wait(waitTime)
- end
- end
- end
- return false, "Falha após " .. maxAttempts .. " tentativas"
- end
- return {
- Download = downloadWithRetry,
- GetCache = function() return cache end,
- ClearCache = function() cache = {} end
- }
- end)()
- --// ========== SISTEMA DE AMBIENTE ISOLADO ========== //
- local EnvironmentManager = (function()
- local environments = {}
- local function createIsolatedEnvironment(scriptName)
- local env = {}
- -- Copia ambiente global de forma segura
- for k, v in pairs(getfenv()) do
- env[k] = v
- end
- -- Serviços importantes
- env.game = game
- env.workspace = workspace
- env.Game = game
- env.Workspace = workspace
- -- Funções essenciais
- env.print = function(...)
- Logger.Info(table.concat({...}, " "), scriptName)
- end
- env.warn = function(...)
- Logger.Warning(table.concat({...}, " "), scriptName)
- end
- env.error = function(...)
- Logger.Error(table.concat({...}, " "), scriptName)
- end
- -- Namespace único para cada script
- env._SCRIPT_NAME = scriptName
- env._SCRIPT_ENV = env
- -- Previne conflitos globais
- env.getgenv = function()
- return env
- end
- env.getfenv = function()
- return env
- end
- -- Armazena ambiente
- environments[scriptName] = env
- Logger.Debug("Ambiente isolado criado para: " .. scriptName)
- return env
- end
- return {
- Create = createIsolatedEnvironment,
- Get = function(name) return environments[name] end,
- GetAll = function() return environments end
- }
- end)()
- --// ========== GERENCIADOR DE SCRIPTS ========== //
- local ScriptManager = (function()
- local loadedScripts = {}
- local failedScripts = {}
- local function loadScript(scriptInfo)
- Logger.Info("════════════════════════════════════════")
- Logger.Info("Carregando: " .. scriptInfo.Name)
- Logger.Info("URL: " .. scriptInfo.URL)
- Logger.Info("Prioridade: " .. scriptInfo.Priority)
- Logger.Info("════════════════════════════════════════")
- -- Download do script
- local downloadSuccess, scriptContent = Downloader.Download(
- scriptInfo.URL,
- scriptInfo.RetryAttempts,
- scriptInfo.LoadTimeout
- )
- if not downloadSuccess then
- Logger.Error("Falha no download: " .. tostring(scriptContent), scriptInfo.Name)
- table.insert(failedScripts, {
- info = scriptInfo,
- reason = scriptContent,
- timestamp = tick()
- })
- return false
- end
- -- Cria ambiente isolado
- local env = EnvironmentManager.Create(scriptInfo.Name)
- -- Compila o script
- local compileSuccess, compiledFunction = pcall(function()
- return loadstring(scriptContent)
- end)
- if not compileSuccess then
- Logger.Error("Erro na compilação: " .. tostring(compiledFunction), scriptInfo.Name)
- table.insert(failedScripts, {
- info = scriptInfo,
- reason = "Compilation error: " .. tostring(compiledFunction),
- timestamp = tick()
- })
- return false
- end
- -- Define ambiente
- setfenv(compiledFunction, env)
- -- Executa o script com proteção
- local executeSuccess, executeResult = pcall(function()
- return compiledFunction()
- end)
- if not executeSuccess then
- Logger.Error("Erro na execução: " .. tostring(executeResult), scriptInfo.Name)
- table.insert(failedScripts, {
- info = scriptInfo,
- reason = "Execution error: " .. tostring(executeResult),
- timestamp = tick()
- })
- return false
- end
- -- Script carregado com sucesso
- table.insert(loadedScripts, {
- info = scriptInfo,
- env = env,
- result = executeResult,
- loadedAt = tick()
- })
- Logger.Success("✅ " .. scriptInfo.Name .. " carregado com sucesso!")
- Logger.Info("════════════════════════════════════════\n")
- return true
- end
- local function loadAll()
- Logger.Info("╔════════════════════════════════════════╗")
- Logger.Info("║ INICIANDO SISTEMA UNIFICADO v" .. SYSTEM_VERSION .. " ║")
- Logger.Info("╚════════════════════════════════════════╝\n")
- -- Ordena por prioridade
- table.sort(ScriptList, function(a, b)
- return a.Priority < b.Priority
- end)
- local totalScripts = 0
- local successCount = 0
- local failCount = 0
- for i, scriptInfo in ipairs(ScriptList) do
- if scriptInfo.Enabled then
- totalScripts = totalScripts + 1
- Logger.Info("📥 Carregando script " .. i .. "/" .. #ScriptList)
- local success = loadScript(scriptInfo)
- if success then
- successCount = successCount + 1
- else
- failCount = failCount + 1
- end
- -- Pequeno delay entre scripts para evitar sobrecarga
- if i < #ScriptList then
- task.wait(0.5)
- end
- else
- Logger.Warning("Script desabilitado: " .. scriptInfo.Name)
- end
- end
- -- Relatório final
- Logger.Info("\n╔════════════════════════════════════════╗")
- Logger.Info("║ RELATÓRIO DE CARREGAMENTO ║")
- Logger.Info("╠════════════════════════════════════════╣")
- Logger.Info("║ Total de Scripts: " .. totalScripts)
- Logger.Success("║ ✅ Carregados: " .. successCount)
- if failCount > 0 then
- Logger.Error("║ ❌ Falharam: " .. failCount)
- end
- Logger.Info("╚════════════════════════════════════════╝\n")
- -- Detalhes dos scripts carregados
- if #loadedScripts > 0 then
- Logger.Success("Scripts carregados com sucesso:")
- for i, data in ipairs(loadedScripts) do
- Logger.Success(" " .. i .. ". " .. data.info.Name)
- end
- print("")
- end
- -- Detalhes dos scripts que falharam
- if #failedScripts > 0 then
- Logger.Error("Scripts que falharam:")
- for i, data in ipairs(failedScripts) do
- Logger.Error(" " .. i .. ". " .. data.info.Name)
- Logger.Error(" Motivo: " .. data.reason)
- end
- print("")
- end
- return {
- total = totalScripts,
- success = successCount,
- failed = failCount,
- loadedScripts = loadedScripts,
- failedScripts = failedScripts
- }
- end
- return {
- LoadAll = loadAll,
- GetLoaded = function() return loadedScripts end,
- GetFailed = function() return failedScripts end
- }
- end)()
- --// ========== SISTEMA DE MONITORAMENTO ========== //
- local Monitor = (function()
- local monitoring = false
- local stats = {
- startTime = tick(),
- errors = 0,
- warnings = 0,
- }
- local function start()
- if monitoring then return end
- monitoring = true
- Logger.Info("🔍 Monitor de sistema iniciado")
- -- Monitor de performance
- task.spawn(function()
- while monitoring do
- task.wait(10)
- local memoryUsage = gcinfo()
- local uptime = tick() - stats.startTime
- Logger.Debug(string.format(
- "Status: Uptime %.0fs | Memória: %.2f MB",
- uptime,
- memoryUsage / 1024
- ))
- end
- end)
- end
- local function stop()
- monitoring = false
- Logger.Info("🔍 Monitor de sistema parado")
- end
- local function getStats()
- return {
- uptime = tick() - stats.startTime,
- memory = gcinfo() / 1024,
- errors = stats.errors,
- warnings = stats.warnings
- }
- end
- return {
- Start = start,
- Stop = stop,
- GetStats = getStats
- }
- end)()
- --// ========== SISTEMA DE VERIFICAÇÃO DE SAÚDE ========== //
- local HealthCheck = (function()
- local function checkEnvironment()
- local checks = {
- {name = "HttpService", test = function() return game:GetService("HttpService") end},
- {name = "Players", test = function() return game:GetService("Players") end},
- {name = "LocalPlayer", test = function() return Players.LocalPlayer end},
- {name = "HttpGet", test = function() return type(game.HttpGet) == "function" end},
- {name = "loadstring", test = function() return type(loadstring) == "function" end},
- }
- local allPassed = true
- Logger.Info("🔍 Verificando ambiente de execução...")
- for _, check in ipairs(checks) do
- local success, result = pcall(check.test)
- if success and result then
- Logger.Success(" ✅ " .. check.name)
- else
- Logger.Error(" ❌ " .. check.name)
- allPassed = false
- end
- end
- return allPassed
- end
- return {
- CheckEnvironment = checkEnvironment
- }
- end)()
- --// ========== SISTEMA DE RECUPERAÇÃO DE ERROS ========== //
- local ErrorRecovery = (function()
- local function handleCriticalError(err, scriptName)
- Logger.Error("╔════════════════════════════════════════╗")
- Logger.Error("║ ERRO CRÍTICO DETECTADO ║")
- Logger.Error("╠════════════════════════════════════════╣")
- if scriptName then
- Logger.Error("║ Script: " .. scriptName)
- end
- Logger.Error("║ Erro: " .. tostring(err))
- Logger.Error("╚════════════════════════════════════════╝")
- -- Tenta recuperação
- Logger.Warning("Tentando recuperar...")
- task.wait(2)
- Logger.Info("Sistema continua operacional")
- end
- return {
- Handle = handleCriticalError
- }
- end)()
- --// ========== INTERFACE DE CONTROLE (OPCIONAL) ========== //
- local ControlInterface = (function()
- local function createSimpleUI()
- -- Cria uma UI simples para controle
- local screenGui = Instance.new("ScreenGui")
- screenGui.Name = "UnifiedScriptManager"
- screenGui.ResetOnSpawn = false
- screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- pcall(function()
- screenGui.Parent = game:GetService("CoreGui")
- end)
- if not screenGui.Parent then
- screenGui.Parent = LocalPlayer:WaitForChild("PlayerGui")
- end
- -- Frame principal (minimizado no canto)
- local mainFrame = Instance.new("Frame")
- mainFrame.Size = UDim2.new(0, 200, 0, 40)
- mainFrame.Position = UDim2.new(1, -210, 0, 10)
- mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 40)
- mainFrame.BackgroundTransparency = 0.1
- mainFrame.BorderSizePixel = 0
- mainFrame.Active = true
- mainFrame.Draggable = true
- mainFrame.Parent = screenGui
- local corner = Instance.new("UICorner")
- corner.CornerRadius = UDim.new(0, 8)
- corner.Parent = mainFrame
- -- Label de status
- local statusLabel = Instance.new("TextLabel")
- statusLabel.Size = UDim2.new(1, -10, 1, -10)
- statusLabel.Position = UDim2.new(0, 5, 0, 5)
- statusLabel.BackgroundTransparency = 1
- statusLabel.Text = "🔗 Sistema Unificado v" .. SYSTEM_VERSION
- statusLabel.TextColor3 = Color3.fromRGB(100, 255, 100)
- statusLabel.TextSize = 14
- statusLabel.Font = Enum.Font.GothamBold
- statusLabel.TextXAlignment = Enum.TextXAlignment.Left
- statusLabel.Parent = mainFrame
- Logger.Success("Interface de controle criada")
- return screenGui
- end
- return {
- Create = createSimpleUI
- }
- end)()
- --// ========== EXECUÇÃO PRINCIPAL ========== //
- local function main()
- -- Banner de inicialização
- print("\n" .. string.rep("=", 60))
- print(" 🔗 SISTEMA UNIFICADO DE SCRIPTS v" .. SYSTEM_VERSION)
- print(" By: NickZScripts")
- print(" Jogador: " .. LocalPlayer.Name)
- print(string.rep("=", 60) .. "\n")
- -- Verificação de saúde do ambiente
- if not HealthCheck.CheckEnvironment() then
- Logger.Error("⚠️ Ambiente não está pronto! Alguns recursos podem não funcionar.")
- task.wait(2)
- end
- -- Inicia monitor
- Monitor.Start()
- -- Cria interface (opcional)
- pcall(function()
- ControlInterface.Create()
- end)
- -- Carrega todos os scripts
- local result = ScriptManager.LoadAll()
- -- Verifica se pelo menos um script foi carregado
- if result.success > 0 then
- Logger.Success("╔════════════════════════════════════════╗")
- Logger.Success("║ SISTEMA OPERACIONAL! ✅ ║")
- Logger.Success("╚════════════════════════════════════════╝")
- else
- Logger.Error("╔════════════════════════════════════════╗")
- Logger.Error("║ NENHUM SCRIPT CARREGADO! ❌ ║")
- Logger.Error("╚════════════════════════════════════════╝")
- end
- -- Estatísticas finais
- task.wait(1)
- local stats = Monitor.GetStats()
- Logger.Info("\n📊 Estatísticas do Sistema:")
- Logger.Info(string.format(" Uptime: %.1fs", stats.uptime))
- Logger.Info(string.format(" Memória: %.2f MB", stats.memory))
- Logger.Info(string.format(" Scripts Ativos: %d", result.success))
- end
- --// ========== PROTEÇÃO CONTRA ERROS CRÍTICOS ========== //
- local mainSuccess, mainError = pcall(main)
- if not mainSuccess then
- ErrorRecovery.Handle(mainError)
- warn("\n╔════════════════════════════════════════╗")
- warn("║ FALHA CRÍTICA NO SISTEMA! ║")
- warn("╠════════════════════════════════════════╣")
- warn("║ Erro: " .. tostring(mainError))
- warn("╚════════════════════════════════════════╝\n")
- else
- print("\n✅ Sistema inicializado com sucesso!\n")
- end
- --// ========== LIMPEZA AO SAIR ========== //
- game:GetService("Players").LocalPlayer.CharacterRemoving:Connect(function()
- Logger.Info("🧹 Limpando sistema...")
- Monitor.Stop()
- Downloader.ClearCache()
- end)
- --// ========== API GLOBAL (OPCIONAL) ========== //
- getgenv().UnifiedScriptManager = {
- Version = SYSTEM_VERSION,
- Logger = Logger,
- ScriptManager = ScriptManager,
- Monitor = Monitor,
- Reload = function()
- Logger.Warning("Recarregando sistema...")
- task.wait(1)
- main()
- end,
- GetStats = function()
- return {
- monitor = Monitor.GetStats(),
- loaded = ScriptManager.GetLoaded(),
- failed = ScriptManager.GetFailed()
- }
- end
- }
- print([[
- ╔═══════════════════════════════════════════════════════════╗
- ║ SISTEMA PRONTO! ✅ ║
- ║ ║
- ║ Use: getgenv().UnifiedScriptManager ║
- ║ ║
- ║ Funções disponíveis: ║
- ║ • UnifiedScriptManager.Reload() ║
- ║ • UnifiedScriptManager.GetStats() ║
- ║ • UnifiedScriptManager.Logger.Info("msg") ║
- ╚═══════════════════════════════════════════════════════════╝
- ]])
Advertisement
Add Comment
Please, Sign In to add comment