⭐Best Practices

Follow these guidelines to build high-quality NOVA scripts.

Security

Always Validate Server-Side

-- ❌ BAD: Trusting client data
RegisterNetEvent('shop:buyItem')
AddEventHandler('shop:buyItem', function(item, price)
    local player = Nova.Functions.GetPlayer(source)
    player:RemoveMoney(price)  -- Client could send price = 0!
    player:AddItem(item, 1)
end)

-- βœ… GOOD: Server validates everything
RegisterNetEvent('shop:buyItem')
AddEventHandler('shop:buyItem', function(itemName)
    local source = source
    local player = Nova.Functions.GetPlayer(source)
    if not player then return end
    
    local item = Config.ShopItems[itemName]
    if not item then return end  -- Item doesn't exist
    
    if player:GetMoney() < item.price then
        Nova.Functions.Notify(source, 'Not enough money', 'error')
        return
    end
    
    player:RemoveMoney(item.price)
    player:AddItem(itemName, 1)
    Nova.Functions.Notify(source, 'Purchased ' .. item.label, 'success')
end)

Never Expose Sensitive Data to Client

Performance

Use Callbacks Instead of Polling

Minimize Database Queries

Use Proper Wait Times

Code Organization

Namespace Your Events

Use the Locale System

UI Guidelines

Follow the NOVA Theme

  • Background: rgba(15, 15, 25, 0.95) with backdrop-filter: blur(20px)

  • Accent Color: #84cc16 (lime green)

  • Border: 1px solid rgba(132, 204, 22, 0.3)

  • Border Radius: 16px for containers, 8px for buttons

  • Font: 'Segoe UI', sans-serif

  • Text Color: #e4e4e7

Support i18n in NUI

Always pass locale strings to your NUI and apply them dynamically. Never hardcode text in HTML.

Last updated