
Math17
Membro
-
Registro em
-
Última visita
Histórico de Curtidas
-
Math17 deu reputação a Dwarfer em (Resolvido)Quest por TempoCaso seja tfs 0.4:
Em talkactions/scripts crie um arquivo.lua:
local quests = { ["demon"] = { min_level = 10, enter_pos = {x = 1, y = 1, z = 1}, area = {fromPos = {x = 1, y = 1, z = 1}, toPos = {x = 1, y = 1, z = 1}}, time_to_finish = {10, "min"}, time_to_make_again = {1, "hour"} }, ["dragon"] = { min_level = 10, enter_pos = {x = 1, y = 1, z = 1}, area = {fromPos = {x = 1, y = 1, z = 1}, toPos = {x = 1, y = 1, z = 1}}, time_to_finish = {10, "min"}, time_to_make_again = {1, "hour"} } } local time_storage = 87870 -- só modifique se necessário function onSay(cid, words, param, channel) local param, p, check = param:lower(), getPlayerPosition(cid), false if not param or param == "" then local str, n = '~~ [Available Quests] ~~\n\n', 1 for quest, info in pairs(quests) do str = str .. n .. " - " .. Fupper(quest) .. " (Level: "..info.min_level..")\n" n = n + 1 end doShowTextDialog(cid, 1955, str) return true end local t = quests[param] if not t then return doPlayerSendCancel(cid, "Quest not found.") end if getPlayerLevel(cid) < t.min_level then return doPlayerSendCancel(cid, "Only players level "..t.min_level.." or higher can go the "..param.." quest.") end if isInRange(p, t.area.fromPos, t.area.toPos) then return doPlayerSendCancel(cid, "You are already inside the "..param.." quest area.") end for quest, info in pairs(quests) do if isInRange(p, info.area.fromPos, info.area.toPos) then check = true end end if check then return doPlayerSendCancel(cid, "You cannot go to another quest inside a quest.") end local stor = getPlayerStorageValue(cid, time_storage) if stor > os.time() then return doPlayerSendCancel(cid, "You can go to a quest again at "..os.date("%d %B %Y %X", stor)..".") end doSendMagicEffect(p, CONST_ME_POFF) local destination = t.enter_pos doTeleportThing(cid, destination) doSendMagicEffect(destination, CONST_ME_TELEPORT) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Good luck in "..param.." quest! You have "..getStrTime(t.time_to_finish).." to finish or you will be kicked.") setPlayerStorageValue(cid, time_storage, mathtime(t.time_to_make_again) + os.time()) addEvent(function() if isPlayer(cid) then if isInRange(getPlayerPosition(cid), t.area.fromPos, t.area.toPos) then doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) local temple = getTownTemplePosition(getPlayerTown(cid)) doTeleportThing(cid, temple) doSendMagicEffect(temple, CONST_ME_TELEPORT) doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Your time is over!") end end end, mathtime(t.time_to_finish) * 1000) return true end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end function getStrTime(table) -- by dwarfer local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"} return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or "")) end function Fupper(str) return (str:gsub("^%l", string.upper)) end Em talkactions.xml, adicione a tag:
<talkaction words="!quest" event="script" value="NOMEDOARQUIVO.lua"/>
Configuração:
["demon"] = { -- nome da quest min_level = 10, -- level mínimo para ir para a quest enter_pos = {x = 1, y = 1, z = 1}, -- posição de entrada na quest area = { fromPos = {x = 1, y = 1, z = 1}, -- posição do canto superior esquerdo da área toPos = {x = 1, y = 1, z = 1} -- posição do canto inferior direito da área }, time_to_finish = {10, "min"}, -- tempo que o player terá para finalizar a quest ("sec", "min", "hour", "day") time_to_make_again = {1, "hour"} -- tempo para poder fazer uma quest novamente },
Utilização:
!quest -> mostra as quests disponíveis !quest nome da quest -> leva o player para a quest Ex.: !quest demon
-
Math17 deu reputação a Vodkart em [HELP] Alguns scripts dando erro !1° adc na lib
function isInRange(position, fromPosition, toPosition) return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z) end
a função agora é chamada de hasCreatureCondition
vai em :
data / lib / 100-compat.lua
ve se acha essa linha:
hasCondition = hasCreatureCondition getCreatureCondition = hasCreatureCondition
se não achar, adc ela no mesmo.
3°
https://tibiaking.com/forums/topic/34780-eliminando-erros-ao-passar-do-npcs-036/