Jump to content
Close
Semideus

Normal Npc task virar task diaria

Recommended Posts

Boa noite, possuo um npc de task onde eu configurei totalmente de acordo com meu servidor e está funcional, 

porém gostaria que depois de 24 horas o jogador pudesse refazer todas as tasks que existem nele e pegar o premio novamente.

 

Segue o script do npc: 


-- Monster Tasks by Limos
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local xmsg = {}
 
function onCreatureAppear(cid)  npcHandler:onCreatureAppear(cid)  end
function onCreatureDisappear(cid)  npcHandler:onCreatureDisappear(cid)  end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg)  end
function onThink()  npcHandler:onThink()  end
 
local storage = 62003
 
--   ["Demons"] = {storage = 5013, mstorage = 19003, amount = 10, exp = 400000, items = {{id = 1991, count = 1}, {id = 2160, count = 40}}}

local monsters = {
   ["Dragons"] = {storage = 5010, mstorage = 19000, amount = 100, exp = 150000, items = {{id = 2160, count = 10}}},
   ["Dragon Lords"] = {storage = 5011, mstorage = 19001, amount = 150, exp = 300000, items = {{id = 2160, count = 20}}},
   ["Frost Dragon"] = {storage = 5019, mstorage = 19009, amount = 300, exp = 800000, items = {{id = 2160, count = 25}}},
   ["Hydras"] = {storage = 5012, mstorage = 19002, amount = 200, exp = 400000, items = {{id = 2160, count = 30}}},
   ["Seacrest Serpent"] = {storage = 5017, mstorage = 19007, amount = 500, exp = 1200000, items = {{id = 2160, count = 35}}},
   ["Kollos"] = {storage = 5018, mstorage = 19008, amount = 500, exp = 1800000, items = {{id = 2160, count = 38}}},
   ["Deepling Tyrant"] = {storage = 5020, mstorage = 19010, amount = 600, exp = 25000000, items = {{id = 2160, count = 100}}},
   ["Demons"] = {storage = 5013, mstorage = 19003, amount = 350, exp = 850000, items = {{id = 2160, count = 40}}},
   ["Grim Reaper"] = {storage = 5023, mstorage = 19013, amount = 1000, exp = 12000000, items = {{id = 2160, count = 70}}},
   ["Lava Golem"] = {storage = 5014, mstorage = 19004, amount = 250, exp = 950000, items = {{id = 2160, count = 50}}},
   ["Mawhawk"] = {storage = 5015, mstorage = 19005, amount = 150, exp = 1000000, items = {{id = 2160, count = 60}}},
   ["Hellgorak"] = {storage = 5016, mstorage = 19006, amount = 100, exp = 1500000, items = {{id = 2160, count = 80}}},
   ["Midnight Asura"] = {storage = 5021, mstorage = 19011, amount = 500, exp = 10000000, items = {{id = 2160, count = 50}}},
   ["Dawnfire Asura"] = {storage = 5022, mstorage = 19012, amount = 500, exp = 10000000, items = {{id = 2160, count = 50}}},
   ["Hades"] = {storage = 5024, mstorage = 19014, amount = 1, exp = 25000000, items = {{id = 1991, count = 1}, {id = 2160, count = 50}}}
}
 
 
local function getItemsFromTable(itemtable)
     local text = ""
     for v = 1, #itemtable do
         count, info = itemtable[v].count, ItemType(itemtable[v].id)
         local ret = ", "
         if v == 1 then
             ret = ""
         elseif v == #itemtable then
             ret = " and "
         end
         text = text .. ret
         text = text .. (count > 1 and count or info:getArticle()).." "..(count > 1 and info:getPluralName() or info:getName())
     end
     return text
end
 
local function Cptl(f, r)
     return f:upper()..r:lower()
end
 
function creatureSayCallback(cid, type, msg)
 
     local player, cmsg = Player(cid), msg:gsub("(%a)([%w_']*)", Cptl)
     if not npcHandler:isFocused(cid) then
         if msg == "hi" or msg == "hello" then
             npcHandler:addFocus(cid)
             if player:getStorageValue(storage) == -1 then
                 local text, n = "",  0
                 for k, x in pairs(monsters) do
                     if player:getStorageValue(x.mstorage) < x.amount then
                         n = n + 1
                         text = text .. ", "
                         text = text .. ""..x.amount.." {"..k.."}"
                     end
                 end
                 if n > 1 then
                     npcHandler:say("I have several tasks for you to kill monsters"..text..", which one do you choose? I can also show you a {list} with rewards and you can {stop} a task if you want.", cid)
                     npcHandler.topic[cid] = 1
                     xmsg[cid] = msg
                 elseif n == 1 then
                     npcHandler:say("I have one last task for you"..text..".", cid)
                     npcHandler.topic[cid] = 1
                 else
                     npcHandler:say("You already did all tasks, I have nothing for you to do anymore, good job though.", cid)
                 end
             elseif player:getStorageValue(storage) == 1 then
                 for k, x in pairs(monsters) do
                     if player:getStorageValue(x.storage) == 1 then
                         npcHandler:say("Did you kill "..x.amount.." "..k.."?", cid)
                         npcHandler.topic[cid] = 2
                         xmsg[cid] = k
                     end
                 end
             end
         else
             return false
         end
     elseif monsters[cmsg] and npcHandler.topic[cid] == 1 then
         if player:getStorageValue(monsters[cmsg].storage) == -1 then
             npcHandler:say("Good luck, come back when you killed "..monsters[cmsg].amount.." "..cmsg..".", cid)
             player:setStorageValue(storage, 1)
             player:setStorageValue(monsters[cmsg].storage, 1)
         else
             npcHandler:say("You already did the "..cmsg.." mission.", cid)
         end
         npcHandler.topic[cid] = 0
     elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
         local x = monsters[xmsg[cid]]
         if player:getStorageValue(x.mstorage) >= x.amount then
             npcHandler:say("Good job, here is your reward, "..getItemsFromTable(x.items)..".", cid)
             for g = 1, #x.items do
                 player:addItem(x.items[g].id, x.items[g].count)
             end
             player:addExperience(x.exp)
             player:setStorageValue(x.storage, 2)
             player:setStorageValue(storage, -1)
             npcHandler.topic[cid] = 3
         else
             npcHandler:say("You didn't kill them all, you still need to kill "..x.amount -(player:getStorageValue(x.mstorage) + 1).." "..xmsg[cid]..".", cid)
         end
     elseif msgcontains(msg, "task") and npcHandler.topic[cid] == 3 then
         local text, n = "",  0
         for k, x in pairs(monsters) do
             if player:getStorageValue(x.mstorage) < x.amount then
                 n = n + 1
                 text = text .. (n == 1 and "" or ", ")
                 text = text .. "{"..k.."}"
             end
         end
         if text ~= "" then
             npcHandler:say("Want to do another task? You can choose "..text..".", cid)
             npcHandler.topic[cid] = 1
         else
             npcHandler:say("You already did all tasks.", cid)
         end
     elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 1 then
         npcHandler:say("Ok then.", cid)
         npcHandler.topic[cid] = 0
     elseif msgcontains(msg, "stop") then
         local text, n = "",  0
         for k, x in pairs(monsters) do
             if player:getStorageValue(x.mstorage) < x.amount then
                 n = n + 1
                 text = text .. (n == 1 and "" or ", ")
                 text = text .. "{"..k.."}"
                 if player:getStorageValue(x.storage) == 1 then
                      player:setStorageValue(x.storage, -1)
                 end
             end
         end
         if player:getStorageValue(storage) == 1 then
             npcHandler:say("Alright, let me know if you want to continue an other task, you can still choose "..text..".", cid)
         else
             npcHandler:say("You didn't start any new task yet, if you want to start one, you can choose "..text..".", cid)
         end
         player:setStorageValue(storage, -1)
         npcHandler.topic[cid] = 1
     elseif msgcontains(msg, "list") then
         local text = "Tasks\n\n"
         for k, x in pairs(monsters) do
             if player:getStorageValue(x.mstorage) < x.amount then
                 text = text ..k .." ["..(player:getStorageValue(x.mstorage) + 1).."/"..x.amount.."]:\n  Rewards:\n  "..getItemsFromTable(x.items).."\n  "..x.exp.." experience \n\n"
             else
                 text = text .. k .." [DONE]\n"
             end
         end
         player:showTextDialog(1949, "" .. text)
         npcHandler:say("Here you are.", cid)
     elseif msgcontains(msg, "bye") then
         npcHandler:say("Bye.", cid)
         npcHandler:releaseFocus(cid)
     else
         npcHandler:say("What?", cid)
     end
     return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

 


Share this post


Link to post
Share on other sites
-- Monster Tasks by Limos
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local xmsg = {}
 
function onCreatureAppear(cid)  npcHandler:onCreatureAppear(cid)  end
function onCreatureDisappear(cid)  npcHandler:onCreatureDisappear(cid)  end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg)  end
function onThink()  npcHandler:onThink()  end
 
local storage = 62003

local tempo = 12 -- tempo em horas para poder fazer as tasks novamente


--   ["Demons"] = {storage = 5013, mstorage = 19003, amount = 10, exp = 400000, items = {{id = 1991, count = 1}, {id = 2160, count = 40}}}

local monsters = {
   ["Dragons"] = {storage = 5010, mstorage = 19000, amount = 100, exp = 150000, items = {{id = 2160, count = 10}}},
   ["Dragon Lords"] = {storage = 5011, mstorage = 19001, amount = 150, exp = 300000, items = {{id = 2160, count = 20}}},
   ["Frost Dragon"] = {storage = 5019, mstorage = 19009, amount = 300, exp = 800000, items = {{id = 2160, count = 25}}},
   ["Hydras"] = {storage = 5012, mstorage = 19002, amount = 200, exp = 400000, items = {{id = 2160, count = 30}}},
   ["Seacrest Serpent"] = {storage = 5017, mstorage = 19007, amount = 500, exp = 1200000, items = {{id = 2160, count = 35}}},
   ["Kollos"] = {storage = 5018, mstorage = 19008, amount = 500, exp = 1800000, items = {{id = 2160, count = 38}}},
   ["Deepling Tyrant"] = {storage = 5020, mstorage = 19010, amount = 600, exp = 25000000, items = {{id = 2160, count = 100}}},
   ["Demons"] = {storage = 5013, mstorage = 19003, amount = 350, exp = 850000, items = {{id = 2160, count = 40}}},
   ["Grim Reaper"] = {storage = 5023, mstorage = 19013, amount = 1000, exp = 12000000, items = {{id = 2160, count = 70}}},
   ["Lava Golem"] = {storage = 5014, mstorage = 19004, amount = 250, exp = 950000, items = {{id = 2160, count = 50}}},
   ["Mawhawk"] = {storage = 5015, mstorage = 19005, amount = 150, exp = 1000000, items = {{id = 2160, count = 60}}},
   ["Hellgorak"] = {storage = 5016, mstorage = 19006, amount = 100, exp = 1500000, items = {{id = 2160, count = 80}}},
   ["Midnight Asura"] = {storage = 5021, mstorage = 19011, amount = 500, exp = 10000000, items = {{id = 2160, count = 50}}},
   ["Dawnfire Asura"] = {storage = 5022, mstorage = 19012, amount = 500, exp = 10000000, items = {{id = 2160, count = 50}}},
   ["Hades"] = {storage = 5024, mstorage = 19014, amount = 1, exp = 25000000, items = {{id = 1991, count = 1}, {id = 2160, count = 50}}},
   ["Ares"] = {storage = 5025, mstorage = 19015, amount = 1, exp = 25000000, items = {{id = 1996, count = 1}, {id = 2160, count = 50}}},
   ["Poseidon"] = {storage = 5026, mstorage = 19016, amount = 1, exp = 25000000, items = {{id = 1992, count = 1}, {id = 2160, count = 50}}}
}
 
 
local function getItemsFromTable(itemtable)
     local text = ""
     for v = 1, #itemtable do
         count, info = itemtable[v].count, ItemType(itemtable[v].id)
         local ret = ", "
         if v == 1 then
             ret = ""
         elseif v == #itemtable then
             ret = " and "
         end
         text = text .. ret
         text = text .. (count > 1 and count or info:getArticle()).." "..(count > 1 and info:getPluralName() or info:getName())
     end
     return text
end
 
local function Cptl(f, r)
     return f:upper()..r:lower()
end
 
function creatureSayCallback(cid, type, msg)
 
     local player, cmsg = Player(cid), msg:gsub("(%a)([%w_']*)", Cptl)
     if not npcHandler:isFocused(cid) then
         if msg == "hi" or msg == "hello" then
             npcHandler:addFocus(cid)
             if player:getStorageValue(storage) == -1 then 
                 local text, n = "",  0
                 for k, x in pairs(monsters) do
                     if player:getStorageValue(x.mstorage) < x.amount then 
                         n = n + 1
                         text = text .. ", "
                         text = text .. ""..x.amount.." {"..k.."}"
                     end
                 end
                 if n > 1 then
                     npcHandler:say("I have several tasks for you to kill monsters"..text..", which one do you choose? I can also show you a {list} with rewards and you can {stop} a task if you want.", cid)
                     npcHandler.topic[cid] = 1
                     xmsg[cid] = msg
                 elseif n == 1 then
                     npcHandler:say("I have one last task for you"..text..".", cid)
                     npcHandler.topic[cid] = 1
                 elseif n == 0 then
                    if player:getStorageValue(14481) == -1 then
                        npcHandler:say("You already did all tasks. You can try again in 24 hours.", cid)
                        player:setStorageValue(14481, tempo*3600 + os.time())
                    elseif player:getStorageValue(14481) - os.time() <= 0 then
                        for i, k in pairs(monsters) do
                            player:setStorageValue(k.mstorage, -1)
                        end
                        npcHandler:say("You can do tasks again.", cid)     
                        player:setStorageValue(14481, -1)
                    else
                        npcHandler:say("You already did all tasks. You must wait about "..math.ceil((player:getStorageValue(14481)-os.time())/3600).." hours.", cid)                
                    end
                end
             elseif player:getStorageValue(storage) == 1 then 
                 for k, x in pairs(monsters) do
                     if player:getStorageValue(x.storage) == 1 then 
                         npcHandler:say("Did you kill "..x.amount.." "..k.."?", cid)
                         npcHandler.topic[cid] = 2
                         xmsg[cid] = k
                     end
                 end
             end
         else
             return false
         end
     elseif monsters[cmsg] and npcHandler.topic[cid] == 1 then
         if player:getStorageValue(monsters[cmsg].storage) == -1 then
             npcHandler:say("Good luck, come back when you killed "..monsters[cmsg].amount.." "..cmsg..".", cid)
             player:setStorageValue(storage, 1)
             player:setStorageValue(monsters[cmsg].storage, 1) 
         else
             npcHandler:say("You already did the "..cmsg.." mission.", cid)
         end
         npcHandler.topic[cid] = 0
         
     elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
         local x = monsters[xmsg[cid]]
         if player:getStorageValue(x.mstorage) >= x.amount then
             npcHandler:say("Good job, here is your reward, "..getItemsFromTable(x.items)..".", cid)
             for g = 1, #x.items do
                 player:addItem(x.items[g].id, x.items[g].count)
             end
             player:addExperience(x.exp)
             player:setStorageValue(x.storage, 2)
             player:setStorageValue(storage, -1) 
             npcHandler.topic[cid] = 3
         else
             npcHandler:say("You didn't kill them all, you still need to kill "..x.amount -(player:getStorageValue(x.mstorage) + 1).." "..xmsg[cid]..".", cid)
         end
     elseif msgcontains(msg, "task") and npcHandler.topic[cid] == 3 then
         local text, n = "",  0
         for k, x in pairs(monsters) do
             if player:getStorageValue(x.mstorage) < x.amount then
                 n = n + 1
                 text = text .. (n == 1 and "" or ", ")
                 text = text .. "{"..k.."}"
             end
         end
         if text ~= "" then
             npcHandler:say("Want to do another task? You can choose "..text..".", cid)
             npcHandler.topic[cid] = 1
         else
             npcHandler:say("You already did all tasks.", cid)
         end
     elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 1 then
         npcHandler:say("Ok then.", cid)
         npcHandler.topic[cid] = 0
     elseif msgcontains(msg, "stop") then
         local text, n = "",  0
         for k, x in pairs(monsters) do
             if player:getStorageValue(x.mstorage) < x.amount then
                 n = n + 1
                 text = text .. (n == 1 and "" or ", ")
                 text = text .. "{"..k.."}"
                 if player:getStorageValue(x.storage) == 1 then 
                      player:setStorageValue(x.storage, -1)
                 end
             end
         end
         if player:getStorageValue(storage) == 1 then 
             npcHandler:say("Alright, let me know if you want to continue an other task, you can still choose "..text..".", cid)
         else
             npcHandler:say("You didn't start any new task yet, if you want to start one, you can choose "..text..".", cid)
         end
         player:setStorageValue(storage, -1) 
         npcHandler.topic[cid] = 1
     elseif msgcontains(msg, "list") then
         local text = "Tasks\n\n"
         for k, x in pairs(monsters) do
             if player:getStorageValue(x.mstorage) < x.amount then
                 text = text ..k .." ["..(player:getStorageValue(x.mstorage) + 1).."/"..x.amount.."]:\n  Rewards:\n  "..getItemsFromTable(x.items).."\n  "..x.exp.." experience \n\n"
             else
                 text = text .. k .." [DONE]\n"
             end
         end
         player:showTextDialog(1949, "" .. text)
         npcHandler:say("Here you are.", cid)
     elseif msgcontains(msg, "bye") then
         npcHandler:say("Bye.", cid)
         npcHandler:releaseFocus(cid)
     else
         npcHandler:say("What?", cid)
     end
     return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

 


Edited by Dwarfer (see edit history)

Contato:

  • Email: dwarfer@sapo.pt
  • Discord: Dwarfer#2715

 

Share this post


Link to post
Share on other sites

Obrigado pela ajuda, vou testar e volto pra confirmar se funcionou.

 

1 hora atrás, Dwarfer disse:
  Ocultar conteúdo


-- Monster Tasks by Limos
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local xmsg = {}
 
function onCreatureAppear(cid)  npcHandler:onCreatureAppear(cid)  end
function onCreatureDisappear(cid)  npcHandler:onCreatureDisappear(cid)  end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg)  end
function onThink()  npcHandler:onThink()  end
 
local storage = 62003

local tempo = 1 -- tempo em horas para poder fazer as tasks novamente


--   ["Demons"] = {storage = 5013, mstorage = 19003, amount = 10, exp = 400000, items = {{id = 1991, count = 1}, {id = 2160, count = 40}}}

local monsters = {
   ["Dragons"] = {storage = 5010, mstorage = 19000, amount = 100, exp = 150000, items = {{id = 2160, count = 10}}},
   ["Dragon Lords"] = {storage = 5011, mstorage = 19001, amount = 150, exp = 300000, items = {{id = 2160, count = 20}}},
   ["Frost Dragon"] = {storage = 5019, mstorage = 19009, amount = 300, exp = 800000, items = {{id = 2160, count = 25}}},
   ["Hydras"] = {storage = 5012, mstorage = 19002, amount = 200, exp = 400000, items = {{id = 2160, count = 30}}},
   ["Seacrest Serpent"] = {storage = 5017, mstorage = 19007, amount = 500, exp = 1200000, items = {{id = 2160, count = 35}}},
   ["Kollos"] = {storage = 5018, mstorage = 19008, amount = 500, exp = 1800000, items = {{id = 2160, count = 38}}},
   ["Deepling Tyrant"] = {storage = 5020, mstorage = 19010, amount = 600, exp = 25000000, items = {{id = 2160, count = 100}}},
   ["Demons"] = {storage = 5013, mstorage = 19003, amount = 350, exp = 850000, items = {{id = 2160, count = 40}}},
   ["Grim Reaper"] = {storage = 5023, mstorage = 19013, amount = 1000, exp = 12000000, items = {{id = 2160, count = 70}}},
   ["Lava Golem"] = {storage = 5014, mstorage = 19004, amount = 250, exp = 950000, items = {{id = 2160, count = 50}}},
   ["Mawhawk"] = {storage = 5015, mstorage = 19005, amount = 150, exp = 1000000, items = {{id = 2160, count = 60}}},
   ["Hellgorak"] = {storage = 5016, mstorage = 19006, amount = 100, exp = 1500000, items = {{id = 2160, count = 80}}},
   ["Midnight Asura"] = {storage = 5021, mstorage = 19011, amount = 500, exp = 10000000, items = {{id = 2160, count = 50}}},
   ["Dawnfire Asura"] = {storage = 5022, mstorage = 19012, amount = 500, exp = 10000000, items = {{id = 2160, count = 50}}},
   ["Hades"] = {storage = 5024, mstorage = 19014, amount = 1, exp = 25000000, items = {{id = 1991, count = 1}, {id = 2160, count = 50}}}
}
 
 
local function getItemsFromTable(itemtable)
     local text = ""
     for v = 1, #itemtable do
         count, info = itemtable[v].count, ItemType(itemtable[v].id)
         local ret = ", "
         if v == 1 then
             ret = ""
         elseif v == #itemtable then
             ret = " and "
         end
         text = text .. ret
         text = text .. (count > 1 and count or info:getArticle()).." "..(count > 1 and info:getPluralName() or info:getName())
     end
     return text
end
 
local function Cptl(f, r)
     return f:upper()..r:lower()
end
 
function creatureSayCallback(cid, type, msg)
 
     local player, cmsg = Player(cid), msg:gsub("(%a)([%w_']*)", Cptl)
     if not npcHandler:isFocused(cid) then
         if msg == "hi" or msg == "hello" then
             npcHandler:addFocus(cid)
             if player:getStorageValue(storage) == -1 then 
                 local text, n = "",  0
                 for k, x in pairs(monsters) do
                     if player:getStorageValue(x.mstorage) < x.amount then 
                         n = n + 1
                         text = text .. ", "
                         text = text .. ""..x.amount.." {"..k.."}"
                     end
                 end
                 if n > 1 then
                     npcHandler:say("I have several tasks for you to kill monsters"..text..", which one do you choose? I can also show you a {list} with rewards and you can {stop} a task if you want.", cid)
                     npcHandler.topic[cid] = 1
                     xmsg[cid] = msg
                 elseif n == 1 then
                     npcHandler:say("I have one last task for you"..text..".", cid)
                     npcHandler.topic[cid] = 1
                 else
                    if player:getStorageValue(14481) == -1 then
                        npcHandler:say("You already did all tasks. You can try again in 24 hours.", cid)
                        player:setStorageValue(14481, tempo*3600 + os.time())
                    elseif player:getStorageValue(14481) - os.time() <= 0 then
                        for i, k in pairs(monsters) do
                            player:setStorageValue(k.mstorage, -1)
                        end
                        npcHandler:say("You can do tasks again.", cid)        
                    else
                        npcHandler:say("You already did all tasks. You must wait about "..math.ceil((player:getStorageValue(14481)-os.time())/3600).." hours.", cid)                
                    end
             elseif player:getStorageValue(storage) == 1 then 
                 for k, x in pairs(monsters) do
                     if player:getStorageValue(x.storage) == 1 then 
                         npcHandler:say("Did you kill "..x.amount.." "..k.."?", cid)
                         npcHandler.topic[cid] = 2
                         xmsg[cid] = k
                     end
                 end
             end
         else
             return false
         end
     elseif monsters[cmsg] and npcHandler.topic[cid] == 1 then
         if player:getStorageValue(monsters[cmsg].storage) == -1 then
             npcHandler:say("Good luck, come back when you killed "..monsters[cmsg].amount.." "..cmsg..".", cid)
             player:setStorageValue(storage, 1)
             player:setStorageValue(monsters[cmsg].storage, 1) 
         else
             npcHandler:say("You already did the "..cmsg.." mission.", cid)
         end
         npcHandler.topic[cid] = 0
         
     elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
         local x = monsters[xmsg[cid]]
         if player:getStorageValue(x.mstorage) >= x.amount then
             npcHandler:say("Good job, here is your reward, "..getItemsFromTable(x.items)..".", cid)
             for g = 1, #x.items do
                 player:addItem(x.items[g].id, x.items[g].count)
             end
             player:addExperience(x.exp)
             player:setStorageValue(x.storage, 2)
             player:setStorageValue(storage, -1) 
             npcHandler.topic[cid] = 3
         else
             npcHandler:say("You didn't kill them all, you still need to kill "..x.amount -(player:getStorageValue(x.mstorage) + 1).." "..xmsg[cid]..".", cid)
         end
     elseif msgcontains(msg, "task") and npcHandler.topic[cid] == 3 then
         local text, n = "",  0
         for k, x in pairs(monsters) do
             if player:getStorageValue(x.mstorage) < x.amount then
                 n = n + 1
                 text = text .. (n == 1 and "" or ", ")
                 text = text .. "{"..k.."}"
             end
         end
         if text ~= "" then
             npcHandler:say("Want to do another task? You can choose "..text..".", cid)
             npcHandler.topic[cid] = 1
         else
             npcHandler:say("You already did all tasks.", cid)
         end
     elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 1 then
         npcHandler:say("Ok then.", cid)
         npcHandler.topic[cid] = 0
     elseif msgcontains(msg, "stop") then
         local text, n = "",  0
         for k, x in pairs(monsters) do
             if player:getStorageValue(x.mstorage) < x.amount then
                 n = n + 1
                 text = text .. (n == 1 and "" or ", ")
                 text = text .. "{"..k.."}"
                 if player:getStorageValue(x.storage) == 1 then 
                      player:setStorageValue(x.storage, -1)
                 end
             end
         end
         if player:getStorageValue(storage) == 1 then 
             npcHandler:say("Alright, let me know if you want to continue an other task, you can still choose "..text..".", cid)
         else
             npcHandler:say("You didn't start any new task yet, if you want to start one, you can choose "..text..".", cid)
         end
         player:setStorageValue(storage, -1) 
         npcHandler.topic[cid] = 1
     elseif msgcontains(msg, "list") then
         local text = "Tasks\n\n"
         for k, x in pairs(monsters) do
             if player:getStorageValue(x.mstorage) < x.amount then
                 text = text ..k .." ["..(player:getStorageValue(x.mstorage) + 1).."/"..x.amount.."]:\n  Rewards:\n  "..getItemsFromTable(x.items).."\n  "..x.exp.." experience \n\n"
             else
                 text = text .. k .." [DONE]\n"
             end
         end
         player:showTextDialog(1949, "" .. text)
         npcHandler:say("Here you are.", cid)
     elseif msgcontains(msg, "bye") then
         npcHandler:say("Bye.", cid)
         npcHandler:releaseFocus(cid)
     else
         npcHandler:say("What?", cid)
     end
     return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

 

 

Edite aqui: local tempo = 1 -- tempo em horas para poder fazer as tasks novamente

 

@Edit, tava faltando uma coisa. Vê aí  @Semideus

 

A npc não me responde amigo


Share this post


Link to post
Share on other sites

como eu coloco no npc.xml? em ot 854 tipo NPC.XML


Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


Open Tibia Server

Quer aprender a criar seu próprio servidor de Tibia? Então está no lugar certo, aqui você encontrará milhares de tutorias, scripts, códigos, mapas e utilitários para que você possa fazer o seu próprio servidor de Tibia partindo do zero.

Redes Sociais

Anuncie no Tibia King

Precisa de mais visibilidade em seus projetos? Quer publicidade para o seu servidor? Anuncie no Tibia King e faça sua divulgação, possuímos centenas de acessos simultâneos e milhares diários, com certeza será a sua solução! A publicação do seu anuncio é instantânea!

×
×
  • Create New...