Postado Junho 1, 2015 10 anos local config = { storage = 9721, time = 5, --Tempo para fazer a quest, em minutos. interval = 15, --Tempo para poder usar a alavanca novamente, em minutos. timerPos = {x = x, y = y, z = z}, --Posição onde o tempo restante aparecerá. monster = { name = "monster_name", --Nome do monstro. pos = { {x = x, y = y, z = z}, --Posições onde ele vai nascer. {x = x, y = y, z = z}, {x = x, y = y, z = z}, --etc }, }, player = { {{x = x, y = y, z = z}, {x = x, y = y, z = z}}, --{{posição onde o player deve ficar}, {para onde será teleportado}}, {{x = x, y = y, z = z}, {x = x, y = y, z = z}}, {{x = x, y = y, z = z}, {x = x, y = y, z = z}}, --etc }, area = {{x = x, y = y, z = z}, {x = x, y = y, z = z}}, --{{posição superior esquerda da área}, {posição inferior direita da área}}, } local cidPos = {} function clearArea() for x = config.area[1].x, config.area[2].x do for y = config.area[1].y, config.area[2].y do local pos = {x = x, y = y, z = config.area[1].z} local pid = getTopCreature(pos).uid if pid > 0 then if isPlayer(pid) then doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid))) doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_RED, "You didn't get to the reward room in time.") else doRemoveCreature(pid) end end end end setGlobalStorageValue(config.storage, os.time() + config.interval * 60) end function checkPlayer() for x = config.area[1].x, config.area[2].x do for y = config.area[1].y, config.area[2].y do local pos = {x = x, y = y, z = config.area[1].z} local pid = getTopCreature(pos).uid if isPlayer(pid) then return true end end end return false end function convert(time) return {minutes = math.floor(time / 60), seconds = time - math.floor(time / 60) * 60} end function timer(time) if time < 0 or not checkPlayer() then return true end doSendAnimatedText(config.timerPos, convert(time).minutes..":"..convert(time).seconds, 215) addEvent(timer, 1000, time - 1) end function onUse(cid) if getGlobalStorageValue(config.storage) > os.time() then return doPlayerSendCancel(cid, "Wait "..convert(getGlobalStorageValue(config.storage) - os.time()).minutes.."min and "..convert(getGlobalStorageValue(config.storage) - os.time()).seconds.."secs.") elseif checkPlayer() then return doPlayerSendCancel(cid, "There's player(s) doing the quest right now.") end local p = {} for _, pos in pairs(config.player) do local pid = getTopCreature(pos[1]).uid if isPlayer(pid) then p[#p + 1] = pid cidPos[pid] = _ end end if #p < #config.player then return doPlayerSendCancel(cid, "There's some player(s) missing.") end for i = 1, #p do doTeleportThing(p[i], config.player[cidPos[p[i]]][2]) doPlayerSendTextMessage(p[i], 27, "Good luck!") end for _, pos in pairs(config.monster.pos) do doCreateMonster(config.monster.name, pos) end timer(config.time * 60) addEvent(function() clearArea() end, config.time * 60 * 1000) return true end Editado Junho 2, 2015 10 anos por zipter98 (veja o histórico de edições) não respondo pms solicitando suporte em programação/scripting
Postado Junho 1, 2015 10 anos Autor Agora deu certo ,só tem um problema como o tempo ta em minuto ele conta de 1 a 0 ai no estante desaparece ,e o tempo que conta na alavanca é o interval tem como coloca pra ser o time?e pra colocar pra mostra mais de um local só adicionar timerPos = {x = 1127, y = 1152, z = 7}, {x = 1127, y = 1152, z = 7}, {x = 1127, y = 1152, z = 7}, E pra adicionar pra mostra o tempo em outro script acrecento oque?tem como falar Editado Junho 1, 2015 10 anos por damiaotorres (veja o histórico de edições)
Postado Junho 1, 2015 10 anos Ah sim, confundi com o interval e mencionei que o time também era em minutos... time -> segundos interval -> minutos A alteração para o tempo restante aparecer em mais de um lugar é a seguinte: Tabela: timerPos = { {x = x, y = y, z = z}, --Posições onde o tempo restante aparecerá. {x = x, y = y, z = z}, {x = x, y = y, z = z}, --etc }, Troque: doSendAnimatedText(config.timerPos, convert(time).minutes..":"..convert(time).seconds, 215) por: for i = 1, #config.timerPos do doSendAnimatedText(config.timerPos[i], convert(time).minutes..":"..convert(time).seconds, 215) end Para mostrar o tempo em outros códigos, basta usar as funções: function convert(time) return {minutes = math.floor(time / 60), seconds = time - math.floor(time / 60) * 60} end function timer(time, pos) if time < 0 then return true end doSendAnimatedText(pos, convert(time).minutes..":"..convert(time).seconds, 215) addEvent(timer, 1000, time - 1) end Uso: timer(TEMPO, POSIÇÃO) Editado Junho 2, 2015 10 anos por zipter98 (veja o histórico de edições) não respondo pms solicitando suporte em programação/scripting
Postado Junho 1, 2015 10 anos Autor Tentei editar mais deu erro :/ local config = { storage = 9721, time = 2, --Tempo para fazer a quest, em minutos. interval = 0, --Tempo para poder usar a alavanca novamente, em minutos. timerPos = {x = 1127, y = 1152, z = 7}, --Posição onde o tempo restante aparecerá. monster = { name = "Annihilon", --Nome do monstro. pos = { {x = 1121, y = 1151, z = 8}, --Posições onde ele vai nascer. {x = 1121, y = 1153, z = 8}, {x = 1121, y = 1155, z = 8}, {x = 1129, y = 1151, z = 8}, {x = 1129, y = 1153, z = 8}, {x = 1129, y = 1155, z = 8}, }, }, player = { {{x = 1126, y = 1152, z = 7}, {x = 1127, y = 1153, z = 8}}, --{{posição onde o player deve ficar}, {para onde será teleportado}}, {{x = 1125, y = 1152, z = 7}, {x = 1126, y = 1153, z = 8}}, {{x = 1124, y = 1152, z = 7}, {x = 1125, y = 1153, z = 8}}, {{x = 1123, y = 1152, z = 7}, {x = 1124, y = 1153, z = 8}}, {{x = 1122, y = 1152, z = 7}, {x = 1123, y = 1153, z = 8}}, }, area = {{x = 1121, y = 1150, z = 8}, {x = 1129, y = 1156, z = 8}}, --{{posição superior esquerda da área}, {posição inferior direita da área}}, } local cidPos = {} function clearArea() for x = config.area[1].x, config.area[2].x do for y = config.area[1].y, config.area[2].y do local pos = {x = x, y = y, z = config.area[1].z} local pid = getTopCreature(pos).uid if pid > 0 then if isPlayer(pid) then doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid))) doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_RED, "Você não conseguiu completar a Quest.") else doRemoveCreature(pid) end end end end setGlobalStorageValue(config.storage, os.time() + config.interval * 60) end function checkPlayer() for x = config.area[1].x, config.area[2].x do for y = config.area[1].y, config.area[2].y do local pos = {x = x, y = y, z = config.area[1].z} local pid = getTopCreature(pos).uid if isPlayer(pid) then return true end end end return false end function convert(time) return {minutes = math.floor(time / 60), seconds = time - math.floor(time / 60) * 60} end function timer(time) if time < 0 or not checkPlayer() then return true end doSendAnimatedText(config.timerPos, convert(time).minutes..":"..convert(time).seconds, 215) addEvent(timer, 1000, time - 1) end function onUse(cid) if getGlobalStorageValue(config.storage) > os.time() then return doPlayerSendCancel(cid, "Wait "..convert(getGlobalStorageValue(config.storage) - os.time()).minutes.."min and "..convert(getGlobalStorageValue(config.storage) - os.time()).seconds.."secs.") elseif checkPlayer() then return doPlayerSendCancel(cid, "Tem Player fazendo a Quest,Aguarde!.") end local p = {} for _, pos in pairs(config.player) do local pid = getTopCreature(pos[1]).uid if isPlayer(pid) then p[#p + 1] = pid cidPos[pid] = _ end end if #p < #config.player then return doPlayerSendCancel(cid, "Não tem 5 Player necessarios.") end for i = 1, #p do doTeleportThing(p, config.player[cidPos[p]][2]) doPlayerSendTextMessage(p, 27, "Boa sorte!") end for _, pos in pairs(config.monster.pos) do doCreateMonster(config.monster.name, pos) end timer(config.time) addEvent(function() clearArea() end, config.time * 60 * 1000) return true end
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.