• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Daily quest or task

Jean Herbert

New Member
Joined
Apr 14, 2014
Messages
10
Reaction score
1
Hi for everyone, I'm looking for one system of daily quest or task that the player will kill one determinated number of the same monster (ex: demon) every day and when he finish, can take one item (editable) in the Daily quest NPC.

Thanks!!
 
Server version is 8.60, TFS 0.4. Only one monster that I will create, I put the Demon like one example and the item is one coin that when the player finish the daily task will receive from npc.

Thanks for progress ;)
 
creaturescripts
Code:
local config = {
     ['demon'] = {amount = 5, storage = 19000, startstorage = 5002, startvalue = 1}
}
function onKill(cid, target)
     local monster = config[getCreatureName(target):lower()]
     if isPlayer(target) or not monster then
         return true
     end

     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) == monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
     end
     if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end
npc
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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 = 5002

function creatureSayCallback(cid, type, msg)
     if not npcHandler:isFocused(cid) then
         return false
     end
     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

     if msgcontains(msg, "mission") then
         if exhaustion.check(cid, storage) then
             local time = exhaustion.get(cid, storage)
             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
             selfSay("You already did the mission today, wait "..text.." before you can get do the mission again.", cid)    
         elseif getPlayerStorageValue(cid, storage) ~= 1 then
             selfSay("I have a daily mission for you to kill 5 Demons, do you accept?", cid)
             talkState[talkUser] = 1
         elseif getPlayerStorageValue(cid, storage) == 1 then
             selfSay("Did you kill 5 Demons?", cid)
             talkState[talkUser] = 1
         end
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         if getPlayerStorageValue(cid, storage) == -1 then
             selfSay("Good, come back when you killed them.", cid)
             setPlayerStorageValue(cid, storage, 1)
         else
             if getPlayerStorageValue(cid, 19000) == 5 then
                 selfSay("Good job, here is your reward.", cid)
                 doPlayerAddItem(cid, 2160, 5)
                 doPlayerAddExp(cid, 50000)
                 setPlayerStorageValue(cid, 19000, -1)
                 exhaustion.set(cid, storage, 86400)
             else
                 selfSay("You didn't kill them all.", cid)
             end
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
         selfSay("Ok then.", cid)
         talkState[talkUser] = 0
     end
     return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Thanks bro. I tryed to use and it appears that have worked. I think that line is wrong in creaturescript -
<event type="kill" name="DailyQuest" script="daily.lua"/>

Because of it the Demons that I've killed don't count.
You know what is the correct line in creaturescript??

Thank you very much
 
Code:
<event type="kill" name="DailyQuest" event="script" value="daily.lua"/>
In login.lua
Code:
registerCreatureEvent(cid, "DailyQuest")
Restart the server before you test.
 
creaturescripts
Code:
local config = {
     ['demon'] = {amount = 5, storage = 19000, startstorage = 5002, startvalue = 1}
}
function onKill(cid, target)
     local monster = config[getCreatureName(target):lower()]
     if isPlayer(target) or not monster then
         return true
     end

     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) == monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
     end
     if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end
npc
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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 = 5002

function creatureSayCallback(cid, type, msg)
     if not npcHandler:isFocused(cid) then
         return false
     end
     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

     if msgcontains(msg, "mission") then
         if exhaustion.check(cid, storage) then
             local time = exhaustion.get(cid, storage)
             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
             selfSay("You already did the mission today, wait "..text.." before you can get do the mission again.", cid)  
         elseif getPlayerStorageValue(cid, storage) ~= 1 then
             selfSay("I have a daily mission for you to kill 5 Demons, do you accept?", cid)
             talkState[talkUser] = 1
         elseif getPlayerStorageValue(cid, storage) == 1 then
             selfSay("Did you kill 5 Demons?", cid)
             talkState[talkUser] = 1
         end
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         if getPlayerStorageValue(cid, storage) == -1 then
             selfSay("Good, come back when you killed them.", cid)
             setPlayerStorageValue(cid, storage, 1)
         else
             if getPlayerStorageValue(cid, 19000) == 5 then
                 selfSay("Good job, here is your reward.", cid)
                 doPlayerAddItem(cid, 2160, 5)
                 doPlayerAddExp(cid, 50000)
                 setPlayerStorageValue(cid, 19000, -1)
                 exhaustion.set(cid, storage, 86400)
             else
                 selfSay("You didn't kill them all.", cid)
             end
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
         selfSay("Ok then.", cid)
         talkState[talkUser] = 0
     end
     return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Code:
<event type="kill" name="DailyQuest" event="script" value="daily.lua"/>
In login.lua
Code:
registerCreatureEvent(cid, "DailyQuest")
Restart the server before you test.
Thanks for this npc but i have one problem with it and some requests
First one I took mission from npc and done it and took my reward but when i tried to take mission again i found this message
Code:
00:34 Task Mons: I have a daily mission for you to kill 5 Demons, do you accept?
And when i answered with Yes i found this message
Code:
00:34 Task Mons: You didn't kill them all.
Secondly I need to make missions like you made on your Mission npc but with monsters not items
http://otland.net/threads/collecting-items-missions.164797/
Like
Player : Mission
NPC : I've got mission for you , You need to kill 10 demons to take your reward
After i done it i will take my reward
Player :Mission
NPC : Well this is second mission for you, You need to kill 20 hydra to take your reward
That's all i need with easy config like you made with Collecting items missions
 
Change == -1 to ~= 1.
For monsters just replace items with monsters in the tables, so instead of checking for items and removing then, check for storage,.
 
Change == -1 to ~= 1.
For monsters just replace items with monsters in the tables, so instead of checking for items and removing then, check for storage,.
I've changed Items with monsters like this
Code:
-- Collecting monsters missions by Limos
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talkState = {}

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 missions = {
   [1] = {monsters = {
     {id = hydra, count = 12},
     {id = demon, count = 8}
     },
     message = "Great, I need alot of monsters, but you can start with",
     level = 15, -- minimum level voor this mission
     rewarditem = {id = 2160, count = 1},
     rewardexp = 15000
   },
   [2] = {monsters = {
     {id = 5898, count = 20},
     {id = 6098, count = 26}
     },
     message = "Thank you, the next monsters are",
     level = 30,
     rewarditem = {id = 2160, count = 5},
     rewardexp = 40000
   },
   [3] = {monsters = {
     {id = 5920, count = 45},
     {id = 5877, count = 22}
     },
     message = "Awesome, now get",
     level = 50,
     rewarditem = {id = 2160, count = 15},
     rewardexp = 100000
   },
   [4] = {monsters = {
     {id = 5913, count = 20},
     {id = 5910, count = 10}
     },
     message = "Thanks, now I need",
     level = 70,
     rewarditem = {id = 2160, count = 25},
     rewardexp = 200000
   },
   [5] = {monsters = {
     {id = 5906, count = 35},
     {id = 4850, count = 1}
     },
     message = "Good, only a few monsters left,",
     level = 10000,
     rewarditem = {id = 2160, count = 50},
     rewardlevel = 45
   }
}

local storage = 45550

local function getmonstersFromTable(itemtable)
     local text = ""
     for v = 1, #itemtable do
         count, info = itemtable[v].count, getItemInfo(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.article).." "..(count > 1 and info.plural or info.name)
     end
     return text
end

function creatureSayCallback(cid, type, msg)

     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

     local xstorage = getPlayerStorageValue(cid, storage)
     local x = missions[xstorage]

     if not npcHandler:isFocused(cid) then
         return false
     end

     if msgcontains(msg, 'mission') then
     if not exhaustion.check(cid, 45646) and getPlayerStorageValue(cid, storage) > 0 then
     setPlayerStorageValue(cid, storage, -1)
     xstorage = getPlayerStorageValue(cid, storage)
end
         if xstorage == -1 then
             selfSay("I am a discoverer and I am currently doing some research, do you think you can help me out?", cid)
             talkState[talkUser] = 1
         elseif x then
             if getPlayerLevel(cid) >= x.level then
                 selfSay("Did you get the {monsters} I asked you?", cid)
                 talkState[talkUser] = 1
             else
                 selfSay("The mission I gave you is for level "..x.level..", come back later.", cid)
             end
         else
             selfSay("Thanks again for all your monsters, it helped me alot.", cid)
             npcHandler:releaseFocus(cid)
         end
     elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
         if xstorage == -1 then
             setPlayerStorageValue(cid, storage, 1)
             local x = missions[getPlayerStorageValue(cid, storage)]
             selfSay(x.message.." "..getmonstersFromTable(x.monsters)..".", cid)
             exhaustion.set(cid, 45646, 86400)
         elseif x then
             local amount = 0
             for i = 1, #x.monsters do
                 if getPlayerItemCount(cid, x.monsters[i].id) >= x.monsters[i].count then
                     amount = amount + 1
                 end
             end
             if amount == #x.monsters then
                 for i = 1, #x.monsters do
                     doPlayerRemoveItem(cid, x.monsters[i].id, x.monsters[i].count)
                 end
                 if x.rewarditem then
                     local count, info = x.rewarditem.count, getItemInfo(x.rewarditem.id)
                     doPlayerAddItem(cid, x.rewarditem.id, count)
                     doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You received "..(count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)..".")
                 end
                 if x.rewardexp then
                     doPlayerAddExp(cid, x.rewardexp)
                     doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You received "..x.rewardexp.." experience.")
                 end
                 if x.rewardlevel then
                     doPlayerAddLevel(cid, x.rewardlevel)
                     doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "You received "..x.rewardlevel.." level.")
                 end
                 setPlayerStorageValue(cid, storage, xstorage + 1)
                 local x = missions[getPlayerStorageValue(cid, storage)]
                 if x then
                     selfSay(x.message.." "..getmonstersFromTable(x.monsters)..".", cid)
                 else
                     selfSay("Thanks alot! I can finish my research now.", cid)
                 end
                 exhaustion.set(cid, 45646, 86400)
             else
                 local n = 0
                 for i = 1, #x.monsters do
                     if getPlayerItemCount(cid, x.monsters[i].id) < x.monsters[i].count then
                         n = n + 1
                     end
                 end
                 local text = ""
                 local c = 0
                 for v = 1, #x.monsters do
                     count, info = x.monsters[v].count - getPlayerItemCount(cid, x.monsters[v].id), getItemInfo(x.monsters[v].id)
                     if getPlayerItemCount(cid, x.monsters[v].id) < x.monsters[v].count then
                         c = c + 1
                         local ret = ", "
                         if c == 1 then
                             ret = ""
                         elseif c == n then
                             ret = " and "
                         end
                         text = text .. ret
                         text = text .. (count > 1 and count or info.article).." "..(count > 1 and info.plural or info.name)
                     end
                 end
                 selfSay("You don't have all monsters, you still need to get "..text..".", cid)
             end
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, 'monsters') and x then
         selfSay("The monsters I asked you are "..getmonstersFromTable(x.monsters)..".", cid)
     elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
         selfSay("Oh well, I guess not then.", cid)
     end
     return true
end

npcHandler:setMessage(MESSAGE_FAREWELL, "Bye!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Bye? I guess...")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
and i tried to message this npc but found this error
Code:
[03/03/2015 12:32:05] [Error - Npc interface]
[03/03/2015 12:32:05] data/npc/scripts/itemsmissions.lua:onCreatureSay
[03/03/2015 12:32:05] Description:
[03/03/2015 12:32:05] data/npc/scripts/itemsmissions.lua:74: attempt to index global 'info' (a boolean value)
[03/03/2015 12:32:05] stack traceback:
[03/03/2015 12:32:05]     data/npc/scripts/itemsmissions.lua:74: in function 'getmonstersFromTable'
[03/03/2015 12:32:05]     data/npc/scripts/itemsmissions.lua:113: in function 'callback'
[03/03/2015 12:32:05]     data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[03/03/2015 12:32:05]     data/npc/scripts/itemsmissions.lua:10: in function <data/npc/scripts/itemsmissions.lua:10>
[03/03/2015 12:32:43] > Broadcasted message: "Information: Follow the rules to avoid a banishment.".
npchandler
http://pastebin.com/TwR776vM
 
Back
Top