Postado Dezembro 31, 2017 7 anos Preciso adicionar para que o jogador só possa usar o item novamente após X HORAS ( 24HORAS POR EXEMPLO) Segue script atual: local config = { time = 4, storage = 123456, } function onUse(player, item, fromPosition, target, toPosition, isHotkey) if player:getStorageValue(config.storage) >= os.time() then player:sendTextMessage(MESSAGE_INFO_DESCR, "You still have extra experience time left.") return true end player:setStorageValue(config.storage, os.time() + config.time * 3600) player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You have activated %d hour%s of 10x experience.", config.time, config.time ~= 1 and "s" or "")) item:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) item:remove(1) return true end Agradeço des de ja
Postado Dezembro 31, 2017 7 anos @Andreeyyy time = 24 aqui?? MEU SERVER: http://otpokemonxy.net/ Nosso → Grupo Oficial OtPokemon XY 24 Horas Nosso → Site Oficial OtPokemon XY 24 Horas Nossa → Pagina Oficial OtPokemon XY 24 Horas
Postado Dezembro 31, 2017 7 anos Solução Teste ai, o tempo é configurável Demonstração Spoiler Script Spoiler local config = { time = 4, -- Tempo de double xp (em horas) cd = 24, -- Tempo para usar o item novamente (em horas) storage = 123456, cdstorage = 123457 } function onUse(player, item, fromPosition, target, toPosition, isHotkey) if player:getStorageValue(config.cdstorage) >= os.time() then player:sendTextMessage(MESSAGE_INFO_DESCR, remainTime(player:getStorageValue(config.cdstorage) - os.time())) return true end if player:getStorageValue(config.storage) >= os.time() then player:sendTextMessage(MESSAGE_INFO_DESCR, "You still have extra experience time left.") return true end player:setStorageValue(config.cdstorage, os.time() + config.cd * 3600) player:setStorageValue(config.storage, os.time() + config.time * 3600) player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You have activated %d hour%s of 10x experience.", config.time, config.time ~= 1 and "s" or "")) item:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) item:remove(1) return true end function remainTime(seconds) hrs = math.floor(seconds / 3600) mins = math.floor((seconds - (hrs * 3600)) / 60) secs = math.floor(seconds - (hrs * 3600) - mins * 60) return string.format("Sorry, you can only use this item again in %d hour(s), %d minute(s) and %d second(s).", hrs, mins, secs) end Editado Dezembro 31, 2017 7 anos por Leohige (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.