Postado Abril 13, 2013 12 anos Testado em TFS 0.3.6pl1 8.54 Como isso funciona: Cada período de tempo (exhausttime) as pessoas podem obter uma recompensa do chest. Esta recompensa é um item aleatório. Você pode mudar ou adicionar mais itens no rewarditems. Adicione a tag em actions.xml - <action uniqueid="4005" event="script" value="quests/timechest.lua"/> Vá em data/actions/scripts, crie um arquivo .lua com nome de timechest, e cole isto - local config = { exhausttime = 7200, -- time in seconds exhauststorage = 2301, level = 50 -- minimum level to open the chest } function onUse(cid, item, fromPosition, itemEx, toPosition) local rewarditems = { {id = 2152, count = math.random(1, 50)}, {id = 2498, count = 1}, {id = 2492, count = 1}, {id = 2488, count = 1} } if getPlayerLevel(cid) < config.level then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) doPlayerSendCancel(cid, "You need to be level "..config.level.." to open the chest.") return true end if exhaustion.check(cid, config.exhauststorage) then local time = exhaustion.get(cid, config.exhauststorage) local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60) if time >= 3600 then text = hours.." "..(hours > 1 and "hours" or "hour")..", "..minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second") elseif time >= 120 then text = minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second") else text = seconds.." "..(seconds > 1 and "seconds" or "second") end doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "It is empty. You need to wait "..text.." before you can get a reward again.") return true end local i = math.random(1, #rewarditems) local info = getItemInfo(rewarditems[i].id) if rewarditems[i].count > 1 then text = rewarditems[i].count .. " " .. info.plural else text = info.article .. " " .. info.name end local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count) if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) text = "You have found a reward. It is to heavy or you have not enough space." else text = "You have found " .. text .. "." exhaustion.set(cid, config.exhauststorage, config.exhausttime) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text) return true end Versão com chance: timechest.lua local config = { exhausttime = 7200, -- time in seconds exhauststorage = 2301, level = 50 -- minimum level to open the chest } function onUse(cid, item, fromPosition, itemEx, toPosition) local rewarditems = { {id = 2492, chance = 5, count = 1}, -- start with the lowest chances {id = 2498, chance = 10, count = 1}, {id = 2488, chance = 15, count = 1}, {id = 2152, chance = 70, count = math.random(1, 50)} } if getPlayerLevel(cid) < config.level then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) doPlayerSendCancel(cid, "You need to be level "..config.level.." to open the chest.") return true end if exhaustion.check(cid, config.exhauststorage) then local time = exhaustion.get(cid, config.exhauststorage) local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60) if time >= 3600 then text = hours.." "..(hours > 1 and "hours" or "hour")..", "..minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second") elseif time >= 120 then text = minutes.." "..(minutes > 1 and "minutes" or "minute").." and "..seconds.." "..(seconds > 1 and "seconds" or "second") else text = seconds.." "..(seconds > 1 and "seconds" or "second") end doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "It is empty. You need to wait "..text.." before you can get a reward again.") return true end local chance = math.random(1,100) for i = 1, #rewarditems, 1 do if chance < rewarditems[i].chance then local info = getItemInfo(rewarditems[i].id) if rewarditems[i].count > 1 then text = rewarditems[i].count .. " " .. info.plural else text = info.article .. " " .. info.name end local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count) if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) text = "You have found a reward. It is to heavy or you have not enough space." else text = "You have found " .. text .. "." exhaustion.set(cid, config.exhauststorage, config.exhausttime) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text) return true else chance = chance - rewarditems[i].chance end end end Créditos - Limos ►[Mega Topic] Seu Primeiro Open Tibia Server◄ ►Lista Dos Meus Trabalhos◄
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.