Postado Novembro 23, 2017 7 anos function onCastSpell(cid, var) local tempo = 10 local time = os.time() local storage = 17900 if getPlayerStorageValue(cid, storage) <= time then setPlayerStorageValue(cid, storage, time + tempo) doPlayerSendTextMessage(cid, 27, "Usou") else local segundos = getPlayerStorageValue(cid, storage) - time if segundos > 0 then doPlayerSendCancel(cid, "Ainda restam: " .. segundos .." segundos.") doSendAnimatedText(getPlayerPosition(cid),'.' ..segundos.. '.',18) end end end Estou tentando colocar uma contagem regressiva saindo em cima do player, está muito difícil, não estou usando o addEvent direito eu suponho. Alguém pode me ajudar?
Postado Novembro 23, 2017 7 anos Deixa eu tentar entender.. function onCastSpell(cid, var) local tempo = 10 // 10 o que ? local time = os.time() local storage = 17900 if getPlayerStorageValue(cid, storage) <= time then // se o player tiver a storage <= 17910 então, setPlayerStorageValue(cid, storage, time + tempo) // adiciona ao player o storage 17900, 14:10:10(exemplo) + 10 (10 o que, não está explicito, pode ser tanto 14+10, ou 14:10+10, ou 14:10:10+10) doPlayerSendTextMessage(cid, 27, "Usou") else local segundos = getPlayerStorageValue(cid, storage) - time // segundos = 17900 - 14:10:10 if segundos > 0 then // 14:10:10 isso vai ser sempre maior que 0 e vai retornar true doPlayerSendCancel(cid, "Ainda restam: " .. segundos .." segundos.") doSendAnimatedText(getPlayerPosition(cid),'.' ..segundos.. '.',18) end end end Você nao usou nenhum addEvent. Tenta isso: function onCastSpell(cid, var) local tempo = 10 * 60 local time = os.time() local storage = 17900 if getPlayerStorageValue(cid, storage) <= time then setPlayerStorageValue(cid, storage, time + tempo) doPlayerSendTextMessage(cid, 27, "Usou") else local segundos = getPlayerStorageValue(cid, storage) - time if segundos > 0 then doPlayerSendCancel(cid, "Ainda restam: " .. segundos .." segundos.") doSendAnimatedText(getPlayerPosition(cid),'.' ..segundos.. '.',18) end end end Editado Novembro 23, 2017 7 anos por Enzo Caue (veja o histórico de edições)
Postado Novembro 23, 2017 7 anos Autor Você entendeu o script tudo errado. O script não funciona dessa forma de você falou. Ele funciona deste modo, preste atenção. function onCastSpell(cid, var) local tempo = 10 // tempo que ira demorar para usar novamente local time = os.time() local storage = 17900 if getPlayerStorageValue(cid, storage) <= time then // se o player tiver a storage <= (17900 == os.time()) então, setPlayerStorageValue(cid, storage, time + tempo) // adiciona ao player o storage (17900 == os.time() + 10), exemplo, o tempo agora que usei é 10:00:00 ele adicionou na storage mais 10 segundos então a storage vai ser 17900 == 10:00:10. doPlayerSendTextMessage(cid, 27, "Usou") else local segundos = getPlayerStorageValue(cid, storage) - time // segundos = 17900 == 10:00:10 - 10:00:(Tempo aumentando por segundo) que o resoltado será 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0. if segundos > 0 then // se o resultado não for 0 ele irá dizer doPlayerSendCancel(cid, "Ainda restam: " .. segundos .." segundos.") doSendAnimatedText(getPlayerPosition(cid),'.' ..segundos.. '.',18) end end end Editado Novembro 23, 2017 7 anos por koete (veja o histórico de edições)
Postado Novembro 23, 2017 7 anos Ve se é isso que vc quer: local tempo = 10 local time = os.time() local storage = 17900 function CountDown(cid, segundos)-- By Vabrindox if segundos == 0 then return false else doPlayerSendCancel(cid, "Ainda restam: " .. segundos .." segundos.") doSendAnimatedText(getPlayerPosition(cid),'.' ..segundos.. '.',18) return addEvent(CountDown, 1000, cid, segundos-1) end end function onCastSpell(cid, var) local get_stg_value = getPlayerStorageValue(cid, storage) local segundos = getPlayerStorageValue(cid, storage) - time if get_stg_value <= time then setPlayerStorageValue(cid, storage, time + tempo) doPlayerSendTextMessage(cid, 27, "Usou") CountDown(cid, tempo) end end @Edit melhorei o script pq tava meio feio antes Editado Novembro 23, 2017 7 anos por Vabrindox (veja o histórico de edições)
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.