FpX Posted February 14, 2022 Share Posted February 14, 2022 (edited) addEventHandler('onResourceStart', getResourceRootElement(getThisResource()), function() db = dbConnect('sqlite', 'prisao.db') dbExec(db, 'Create table if not exists presos(login, tempo)') setTimer(function() for _, player in ipairs(getElementsByType('player')) do if getPlayerPreso(player) then local result = dbPoll(dbQuery(db, 'Select * from presos Where login = ?', getAccountName(getPlayerAccount(player))), - 1) if #result ~= 0 then setTimer(function(player) setPlayerPreso(player, result[1]['tempo']) end, 500, 1, player) end end end end, 500, 1) end ) COMO EU PODERIA COLOCAR PARA ESTA FUNÇÃO REINICIAR POR EXEMPLO A CADA 20 SEGUNDOS? ME AJUDE PF Edited February 15, 2022 by Lord Henry Link to comment
Other Languages Moderators Lord Henry Posted February 15, 2022 Other Languages Moderators Share Posted February 15, 2022 Em vez de um evento, utilize um timer de 20 segundos. setTimer(function() db = dbConnect('sqlite', 'prisao.db') dbExec(db, 'Create table if not exists presos(login, tempo)') setTimer(function() for _, player in ipairs(getElementsByType('player')) do if getPlayerPreso(player) then local result = dbPoll(dbQuery(db, 'Select * from presos Where login = ?', getAccountName(getPlayerAccount(player))), - 1) if #result ~= 0 then setTimer(function(player) setPlayerPreso(player, result[1]['tempo']) end, 500, 1, player) end end end end, 500, 1) end, 20000, 0) 1 Link to comment
Recommended Posts