diff --git a/config.lua b/config.lua index baa44bb..3981d0b 100644 --- a/config.lua +++ b/config.lua @@ -7,7 +7,7 @@ Config.Debug = true Config.PlaceTime = 2500 -- Segurança do PIN -Config.PinMaxAttempts = 3 -- tentativas erradas de PIN antes de bloquear o jogador +Config.PinMaxAttempts = 1 -- tentativas erradas de PIN antes de bloquear o jogador Config.PinBlockTime = 30 -- segundos de bloqueio após exceder as tentativas -- Distância máxima (metros) para abrir ou recolher um safe diff --git a/server.lua b/server.lua index 86000e2..2f85e1e 100644 --- a/server.lua +++ b/server.lua @@ -193,11 +193,11 @@ end) RegisterNetEvent('safe:open', function(id, pin) local src = source local now = os.time() - local attempt = pinAttempts[src] + local attempt = pinAttempts[id] -- bloqueio é do cofre, não do jogador if attempt and now < attempt.blockedUntil then local remaining = math.ceil(attempt.blockedUntil - now) - return TriggerClientEvent('ox_lib:notify', src, {type='error', description=('Muitas tentativas erradas. Aguarde %d segundos.'):format(remaining)}) + return TriggerClientEvent('ox_lib:notify', src, {type='error', description=('Este safe está bloqueado. Aguarde %d segundos.'):format(remaining)}) end local safe = safes[id] @@ -217,14 +217,17 @@ RegisterNetEvent('safe:open', function(id, pin) if attempt.count >= Config.PinMaxAttempts then attempt.blockedUntil = now + Config.PinBlockTime attempt.count = 0 - dbg('Jogador', src, 'bloqueado por tentativas de PIN erradas') + pinAttempts[id] = attempt + dbg('Safe', id, 'bloqueado por tentativas de PIN erradas') + return TriggerClientEvent('ox_lib:notify', src, {type='error', description=('PIN incorreto. Safe bloqueado por %d segundos.'):format(Config.PinBlockTime)}) end - pinAttempts[src] = attempt - return TriggerClientEvent('ox_lib:notify', src, {type='error', description='PIN incorreto.'}) + pinAttempts[id] = attempt + local remainingAttempts = Config.PinMaxAttempts - attempt.count + return TriggerClientEvent('ox_lib:notify', src, {type='error', description=('PIN incorreto. Mais %d tentativa(s) antes do safe ser bloqueado.'):format(remainingAttempts)}) end - pinAttempts[src] = nil + pinAttempts[id] = nil local cfg = Config.SafeTypes[safe.type] TriggerClientEvent('safe:openInventory', src, {id=id, slots=cfg.slots, weight=cfg.weight})