Exemplos Práticos
💎 Sistema VIP Baseado em Quantidade de Recursos
local function isVipUser()
local userResourcesJson = LockSystem.LCK.Get("LCK_USER_RESOURCES")
if not userResourcesJson then return false end
local userResources = json:parse(userResourcesJson)
if userResources and type(userResources) == "table" then
return #userResources >= 5 -- VIP com 5+ recursos
end
return false
end
-- Usar em eventos
addEventHandler("onResourceStart", root, function()
if isVipUser() then
outputDebugString("Bem-vindo VIP! Você possui recursos premium.", 3, 255, 75, 59)
end
end)
🔍 Verificar se Usuário Possui Recurso Específico
local function hasResource(resourceName)
local userResourcesJson = LockSystem.LCK.Get("LCK_USER_RESOURCES")
if not userResourcesJson then
return false
end
local userResources = json:parse(userResourcesJson)
if not userResources or type(userResources) ~= "table" then
return false
end
for _, resource in ipairs(userResources) do
if resource == resourceName then
return true
end
end
return false
end
-- Exemplo de uso
if hasResource("Sistema VIP") then
setElementData(player, "vip", true)
outputChatBox("Você tem acesso a uma resource complementar: VIP Integrado!", player, 0, 255, 0)
end
🎉 Sistema de Mensagem Personalizada
local function showWelcomeMessage()
local userName = LockSystem.LCK.Get("LCK_DISCORD_NAME") or "Visitante"
local shopName = LockSystem.LCK.Get("LCK_SHOP_NAME") or "Loja"
local version = LockSystem.LCK.Get("LCK_RESOURCE_VERSION") or "1.0"
local activeUsers = tonumber(LockSystem.LCK.Get("LCK_RESOURCE_ACTIVE_USERS")) or 0
local message = string.format(
"🎉 Bem-vindo %s!\n" ..
"📦 Resource: %s v%s\n" ..
"🏪 Loja: %s\n" ..
"👥 Usuários online: %d",
userName,
LockSystem.LCK.Get("LCK_CURRENT_RESOURCE") or "Resource",
version,
shopName,
activeUsers
)
outputDebugString(message, 4, 255, 75, 59)
end
🏷️ Sistema de Branding da Loja
-- HUD com informações da loja
local function drawShopHUD()
local shopName = LockSystem.LCK.Get("LCK_SHOP_NAME")
local totalUsers = tonumber(LockSystem.LCK.Get("LCK_TOTAL_SHOP_USERS")) or 0
if shopName then
-- Nome da loja no canto superior
dxDrawText(shopName, 10, 10, 0, 0, tocolor(255, 255, 255), 1.2, "default-bold")
-- Informações adicionais
local shopInfo = string.format("Total de clientes: %d", totalUsers)
dxDrawText(shopInfo, 10, 35, 0, 0, tocolor(200, 200, 200), 1.0, "default")
end
end
-- Usar no onClientRender
addEventHandler("onClientRender", root, function()
if Authenticated and Authenticated[1] == "Liberado" then
drawShopHUD()
end
end)
📊 Sistema de Bonificação por Atividade
local function checkShopLoad()
local activeUsers = tonumber(LockSystem.LCK.Get("LCK_RESOURCE_ACTIVE_USERS")) or 0
local totalUsers = tonumber(LockSystem.LCK.Get("LCK_TOTAL_SHOP_USERS")) or 0
if activeUsers < 5 then
-- Shop com pouco load - dar benefícios
outputChatBox("🎁 Bônus por baixa atividade! +50% XP", root, 0, 255, 0)
setGameSpeed(1.1)
elseif activeUsers > 20 then
-- Shop com muito load - eventos especiais
outputChatBox("🔥 Servidor popular! Evento especial ativado!", root, 255, 165, 0)
triggerEvent("startSpecialEvent", root)
end
if totalUsers > 50 then
-- Shop está muito ativa
outputChatBox("🔥 Loja muito ativa! Bônus de XP ativado!", root, 255, 165, 0)
end
end
Atualizado