βBest Practices
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
Support i18n in NUI
Last updated