Exemplos Práticos
🔧 Kill Switch e Controle Global
-- O desenvolvedor define globalmente para TODOS os servidores:
-- SYSTEM_ENABLED = "true"
-- FEATURE_ADVANCED_ENABLED = "false"
-- MAINTENANCE_MODE = "false"
-- ALLOWED_VERSION = "2.1.0"
local function checkSystemStatus()
-- Verificar se o sistema está globalmente ativo
local systemEnabled = LockSystem.Envs.Get("SYSTEM_ENABLED") == "true"
if not systemEnabled then
outputServerLog("❌ Sistema desabilitado pelo desenvolvedor")
return false
end
-- Verificar modo manutenção
local maintenanceMode = LockSystem.Envs.Get("MAINTENANCE_MODE") == "true"
if maintenanceMode then
outputChatBox("🔧 Sistema em manutenção temporária", root, 255, 165, 0)
return false
end
-- Verificar versão permitida
local allowedVersion = LockSystem.Envs.Get("ALLOWED_VERSION")
local currentVersion = "2.1.0" -- versão da sua resource
if allowedVersion and allowedVersion ~= currentVersion then
outputServerLog("⚠️ Versão não autorizada pelo desenvolvedor")
return false
end
return true
end
-- Sistema adaptativo baseado em dados reais
local function adaptiveFeatures()
local featureAdvanced = LockSystem.Envs.Get("FEATURE_ADVANCED_ENABLED") == "true"
local activeUsers = tonumber(LockSystem.LCK.Get("LCK_RESOURCE_ACTIVE_USERS")) or 0
-- Feature avançada só funciona se habilitada pelo dev E tiver usuários suficientes
if featureAdvanced and activeUsers >= 5 then
-- Ativar recursos avançados
setElementData(resourceRoot, "advanced_mode", true)
outputServerLog("✨ Modo avançado ativado")
end
end
🛡️ Proteção Dinâmica e Inteligente
-- Desenvolvedor controla globalmente:
-- SECURITY_LEVEL = "2"
-- ANTI_CRACK_ENABLED = "true"
-- DEBUG_LOGS_ENABLED = "false"
-- EMERGENCY_SHUTDOWN = "false"
local function protectionSystem()
-- Emergency shutdown - dev pode desligar tudo instantaneamente
local emergencyShutdown = LockSystem.Envs.Get("EMERGENCY_SHUTDOWN") == "true"
if emergencyShutdown then
outputServerLog("🚨 EMERGENCY SHUTDOWN ATIVADO PELO DESENVOLVEDOR")
stopResource(getThisResource())
return
end
local securityLevel = tonumber(LockSystem.Envs.Get("SECURITY_LEVEL")) or 1
local antiCrackEnabled = LockSystem.Envs.Get("ANTI_CRACK_ENABLED") == "true"
local debugEnabled = LockSystem.Envs.Get("DEBUG_LOGS_ENABLED") == "true"
-- Proteção baseada em dados LCK_* e configuração do dev
local userResources = LockSystem.LCK.Get("LCK_USER_RESOURCES")
local discordId = LockSystem.LCK.Get("LCK_DISCORD_ID")
local shopName = LockSystem.LCK.Get("LCK_SHOP_NAME")
if antiCrackEnabled then
-- Verificações anti-crack mais rigorosas
if not userResources or userResources == "[]" then
if debugEnabled then
outputServerLog("🔍 DEBUG: Usuário sem recursos detectado - ID: " .. (discordId or "N/A"))
end
if securityLevel >= 2 then
-- Nível 2: Kick player
kickPlayer(source, "Verificação de segurança falhou")
end
end
end
-- Sistema adaptativo baseado na loja
if shopName and securityLevel >= 3 then
-- Proteção especial para certas lojas
if shopName:find("test") or shopName:find("demo") then
outputServerLog("⚠️ Loja de teste detectada: " .. shopName)
end
end
end
-- Verificações inteligentes que se adaptam
local function smartValidation()
local activeUsers = tonumber(LockSystem.LCK.Get("LCK_RESOURCE_ACTIVE_USERS")) or 0
local totalUsers = tonumber(LockSystem.LCK.Get("LCK_TOTAL_SHOP_USERS")) or 0
-- Dev pode definir limites mínimos globalmente
local minActiveUsers = tonumber(LockSystem.Envs.Get("MIN_ACTIVE_USERS")) or 0
if activeUsers < minActiveUsers then
outputServerLog("⚠️ Poucos usuários ativos: " .. activeUsers .. "/" .. minActiveUsers)
-- Dev pode decidir o que fazer
end
end
💬 Sistema de Mensagens Adaptativas
-- Variáveis para personalização de mensagens:
-- MSG_WELCOME_ENABLED = "true"
-- MSG_WELCOME_TEXT = "Bem-vindo ao sistema de empregos!"
-- MSG_LANGUAGE = "pt_BR"
-- MSG_VIP_DIFFERENT = "true"
local messages = {
pt_BR = {
welcome = "Bem-vindo ao sistema!",
vip_welcome = "Bem-vindo VIP! Você tem benefícios especiais!",
error = "Erro no sistema"
},
en_US = {
welcome = "Welcome to the system!",
vip_welcome = "Welcome VIP! You have special benefits!",
error = "System error"
}
}
local function sendAdaptiveMessage(player, messageType)
local enabled = LockSystem.Envs.Get("MSG_WELCOME_ENABLED") == "true"
if not enabled then return end
local language = LockSystem.Envs.Get("MSG_LANGUAGE") or "pt_BR"
local vipDifferent = LockSystem.Envs.Get("MSG_VIP_DIFFERENT") == "true"
-- Verificar se é VIP usando LCK_*
local userResources = LockSystem.LCK.Get("LCK_USER_RESOURCES")
local isVip = userResources and #json.decode(userResources or "[]") >= 3
local messageKey = messageType
if vipDifferent and isVip and messageType == "welcome" then
messageKey = "vip_welcome"
end
local text = messages[language] and messages[language][messageKey] or "Sistema ativo"
-- Usar texto personalizado se definido
local customText = LockSystem.Envs.Get("MSG_WELCOME_TEXT")
if customText and messageType == "welcome" then
text = customText
end
outputChatBox("💬 " .. text, player, 0, 255, 0)
end
-- Sistema que compara dados LCK com configurações Envs
local function createIntelligentFeatures()
local shopName = LockSystem.LCK.Get("LCK_SHOP_NAME")
local discordName = LockSystem.LCK.Get("LCK_DISCORD_NAME")
-- Usar shop para definir comportamento
local shopBehavior = LockSystem.Envs.Get("SHOP_" .. (shopName or "DEFAULT"):upper() .. "_MODE")
if shopBehavior == "premium" then
-- Aplicar recursos premium
setElementData(source, "premium_features", true)
outputChatBox("✨ Recursos premium ativados para " .. shopName, source, 255, 215, 0)
end
end
⚙️ Sistema de Configuração por Ambiente
-- Definir no painel:
-- AMBIENTE = "production" -- ou "development"
-- DEBUG_ATIVO = "false"
-- LOG_LEVEL = "info"
local function isProduction()
local env = LockSystem.Envs.Get("AMBIENTE") or "development"
return env:lower() == "production"
end
local function isDebugEnabled()
local debug = LockSystem.Envs.Get("DEBUG_ATIVO") or "false"
return debug:lower() == "true" or debug == "1"
end
-- Usar configurações condicionais
if isProduction() then
-- Configurações de produção
setGameSpeed(1.0)
setWeather(10)
else
-- Configurações de desenvolvimento
setGameSpeed(1.5)
setWeather(0) -- Sempre ensolarado para testes
if isDebugEnabled() then
outputChatBox("🔧 Modo DEBUG ativado", root, 255, 255, 0)
end
end
🎛️ Controle Remoto de Features
-- Desenvolvedor controla features da resource remotamente:
-- FEATURE_PREMIUM_ENABLED = "false"
-- FEATURE_BETA_TESTING = "true"
-- SYSTEM_MAX_CONCURRENT_USERS = "50"
-- PERFORMANCE_MODE = "optimized"
local function checkFeatureControl()
-- Dev pode desabilitar features premium remotamente
local premiumEnabled = LockSystem.Envs.Get("FEATURE_PREMIUM_ENABLED") == "true"
local betaTesting = LockSystem.Envs.Get("FEATURE_BETA_TESTING") == "true"
local maxUsers = tonumber(LockSystem.Envs.Get("SYSTEM_MAX_CONCURRENT_USERS")) or 100
local performanceMode = LockSystem.Envs.Get("PERFORMANCE_MODE") or "normal"
-- Aplicar limitações globalmente
local activeUsers = tonumber(LockSystem.LCK.Get("LCK_RESOURCE_ACTIVE_USERS")) or 0
if activeUsers > maxUsers then
outputServerLog("⚠️ Limite de usuários atingido: " .. activeUsers .. "/" .. maxUsers)
-- Dev pode definir comportamento quando limite é atingido
return false
end
-- Controlar features baseado em configuração do dev
if not premiumEnabled then
setElementData(resourceRoot, "premium_features", false)
outputServerLog("💎 Features premium desabilitadas pelo desenvolvedor")
end
if betaTesting then
setElementData(resourceRoot, "beta_mode", true)
outputServerLog("🧪 Modo beta ativado pelo desenvolvedor")
end
return true
end
addEventHandler("onResourceStart", resourceRoot, checkFeatureControl)
Atualizado