• Sign up for September Mapping Competition! The prize includes Otland Premium time.
  • There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ Monster task by Limos customization

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,197
Best answers
1
Reaction score
871
Location
Chile
Hello guys!! i was making a task npc with the limos system, and add it the slow speaking way to the npc, looks really cool, but i have a problem, i don't know why the system isn't counting my kills, and i already registered it in login.lua and creaturescripts.xml :S

I was wondering if someone could help me figure out why, and hopefully someone can help me make this whole monsters become 1 single task. You take the task and have to kill all of them for a single reward, this is beyong my "coding skills" =(

NPC lua

Lua:
-- 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 = 62109
 
local monsters = {
   ["Deepling Worker"] = {storage = 25243, mstorage = 25251, amount = 20, exp = 30000, items = {{id = 28800, count = 1}, {id = 29529, count = 2}, {id = 22397, count = 3}}},
   ["Deepling Scout"] = {storage = 25244, mstorage = 25252, amount = 20, exp = 30000, items = {{id = 28800, count = 1}, {id = 29529, count = 2}, {id = 22397, count = 3}}},
   ["Deepling Brawler"] = {storage = 25245, mstorage = 25253, amount = 20, exp = 30000, items = {{id = 28800, count = 1}, {id = 29529, count = 2}, {id = 22397, count = 3}}},
   ["Deepling Spellsinger"] = {storage = 25246, mstorage = 25254, amount = 20, exp = 30000, items = {{id = 28800, count = 1}, {id = 29529, count = 2}, {id = 22397, count = 3}}},
   ["Deepling Warrior"] = {storage = 25247, mstorage = 25255, amount = 20, exp = 30000, items = {{id = 28800, count = 1}, {id = 29529, count = 2}, {id = 22397, count = 3}}},
   ["Deepling Guard"] = {storage = 25248, mstorage = 25256, amount = 20, exp = 30000, items = {{id = 28800, count = 1}, {id = 29529, count = 2}, {id = 22397, count = 3}}},
   ["Deepling Elite"] = {storage = 25249, mstorage = 25257, amount = 20, exp = 30000, items = {{id = 28800, count = 1}, {id = 29529, count = 2}, {id = 22397, count = 3}}},
   ["Deepling Tyrant"] = {storage = 25250, mstorage = 25258, amount = 20, exp = 30000, items = {{id = 28800, count = 1}, {id = 29529, count = 2}, {id = 22397, count = 3}}}
}
 
 local message = {
                delay = 4000,
                start = {
                    "Gaahhjj! kja kja kja...A human! Perfect! ...",
                    "My name is Braquiuros, and i am the leader of this quara community ...",
                    "For many months, we have been in peace, but deeplings have started attaacking us for no reason!! ...",
                    "I would be really helpful if you could help me slain a bunch of those bastards ...",
                    "I would go myself but you see...My knee is broken...coff coff ...",
                    "So, will you help our peaceful community? Say {yes} to accept and help us.",
                    "So, will you help our peaceful community? I just need you to kill 20 of each deeplings: worker, scout, brawler, spellsinger, warrior, guard, elite and tyrant.",
                    "I will give you a reward for each type completed, just say the full name of the deepling and we will start.",
                    
                }
            }
 
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(message.start, cid, false, true, message.delay)
                     npcHandler.topic[cid] = 1
                     xmsg[cid] = msg
                 elseif n == 1 then
                     npcHandler:say(message.start, cid, false, true, message.delay)
                     npcHandler.topic[cid] = 1
                 else
                     npcHandler:say("You have already helped me, thank you for that!", 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 defeated Those ugly "..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("Best of luck! Come back to me when you have kill "..monsters[cmsg].amount.." "..cmsg..".", cid)
             player:setStorageValue(storage, 1)
             player:setStorageValue(monsters[cmsg].storage, 1)
         else
             npcHandler:say("You have already helped me, thank you for that!", 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("Ahhhh this is very nice, thank you human, you have helped me, 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("Don't lie to me, you haven't kill him yet...You are missing "..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("You want to kill more of these deeplings? "..text..".", cid)
             npcHandler.topic[cid] = 1
         else
             npcHandler:say("You have helped us enough human.", cid)
         end
     elseif msgcontains(msg, "no") and npcHandler.topic[cid] == 1 then
         npcHandler:say("Ok then.", cid)
         npcHandler.topic[cid] = 0
     elseif msgcontains(msg, "abandon") 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("Ok, dime si quieres continuar otra task, todavia puedes elegir "..text..".", cid)
         else
             npcHandler:say("No empezaste ninguna nueva task, si quieres empezar una, puedes elegir "..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("Gaahhjj!", cid)
     end
     return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

Creaturescript.lua

Lua:
local config = {
     ['Deepling Worker'] = {amount = 20, startstorage = 25243, storage = 25251, startvalue = 1},
     ['Deepling Scout'] = {amount = 20, startstorage = 25244, storage = 25252, startvalue = 1},
     ['Deepling Brawler'] = {amount = 20, startstorage = 25245, storage = 25253, startvalue = 1},
     ['Deepling Spellsinger'] = {amount = 20, startstorage = 25246, storage = 25254, startvalue = 1},
     ['Deepling Warrior'] = {amount = 20, startstorage = 25247, storage = 25255, startvalue = 1},
     ['Deepling Guard'] = {amount = 20, startstorage = 25248, storage = 25256, startvalue = 1},
     ['Deepling Elite'] = {amount = 20, startstorage = 25249, storage = 25257, startvalue = 1},
     ['Deepling Tyrant'] = {amount = 20, startstorage = 25250, storage = 25258, startvalue = 1}
}
function onKill(player, target)
     local monster = config[target:getName():lower()]
     if target:isPlayer() or not monster or target:getMaster() then
         return true
     end
     local stor = player:getStorageValue(monster.storage)+1
     if stor < monster.amount and player:getStorageValue(monster.startstorage) >= monster.startvalue then
         player:setStorageValue(monster.storage, stor)
         player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(stor +1)..' of '..monster.amount..' '..target:getName()..'s killed.')
     end
     if (stor +1) == monster.amount then
         player:sendTextMessage(MESSAGE_INFO_DESCR, 'Nicee, you have killed '..(stor +1)..' '..target:getName()..'s and completed the '..target:getName()..'s mission.')
         player:setStorageValue(monster.storage, stor +1)
     end
     return true
end
 

Nokturno

Not a human
Premium User
Joined
Aug 7, 2009
Messages
401
Best answers
0
Reaction score
247
try using lower case letters for the Monster names in creaturescripts.lua
also if u want them to be all the same task just change the storage value and startstorage value for all of them to a same number
 
OP
Thorn

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,197
Best answers
1
Reaction score
871
Location
Chile
try using lower case letters for the Monster names in creaturescripts.lua
also if u want them to be all the same task just change the storage value and startstorage value for all of them to a same number
hey!! the lower case worked!! thank you so much! But i dont understand very well what u are saying about the same storage...because if i do that, any of the keywords would trigger the quest to start? and what about rewards? there are many rewards, and i just need 1 for all
 

Nokturno

Not a human
Premium User
Joined
Aug 7, 2009
Messages
401
Best answers
0
Reaction score
247
NPC.lua it is just a reference file for the names, so just leave it like "Deeplings" and erase all the other ones and just leave one.
Lua:
 ["Deeplings"] = {storage = 25243, mstorage = 25251, amount = 20, exp = 30000, items = {{id = 28800, count = 1}, {id = 29529, count = 2}, {id = 22397, count = 3}}}
just one task for all of them, just change the storage numbers
 
OP
Thorn

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,197
Best answers
1
Reaction score
871
Location
Chile
NPC.lua it is just a reference file for the names, so just leave it like "Deeplings" and erase all the other ones and just leave one.
Lua:
 ["Deeplings"] = {storage = 25243, mstorage = 25251, amount = 20, exp = 30000, items = {{id = 28800, count = 1}, {id = 29529, count = 2}, {id = 22397, count = 3}}}
just one task for all of them, just change the storage numbers
Okey i did what u said, but im having this problem

19:08 Task message: 1 of 20 Deepling Workers killed.
19:08 Task message: 2 of 20 Deepling Tyrants killed.

So it's counting them all as one


Lua:
     ['deepling worker'] = {amount = 20, startstorage = 25243, storage = 25244, startvalue = 1},
     ['deepling scout'] = {amount = 20, startstorage = 25243, storage = 25244, startvalue = 1},
     ['deepling brawler'] = {amount = 20, startstorage = 25243, storage = 25244, startvalue = 1},
     ['deepling spellsinger'] = {amount = 20, startstorage = 25243, storage = 25244, startvalue = 1},
     ['deepling warrior'] = {amount = 20, startstorage = 25243, storage = 25244, startvalue = 1},
     ['deepling guard'] = {amount = 20, startstorage = 25243, storage = 25244, startvalue = 1},
     ['deepling elite'] = {amount = 20, startstorage = 25243, storage = 25244, startvalue = 1},
     ['deepling tyrant'] = {amount = 20, startstorage = 25243, storage = 25244, startvalue = 1}
 

Nokturno

Not a human
Premium User
Joined
Aug 7, 2009
Messages
401
Best answers
0
Reaction score
247
So it's counting them all as one
try changing the storage in creaturescripts but leaving the same startstorage then
nvm im getting confused xD
 
Top