• 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!

NPC Collecting items missions

If a player did all the missions it's done, if you want to make it that players can do the missions every day, you can set exhaustion to the npc.
Then when the exhaustion is over, set the storage back to -1.
Under "if msgcontains(msg, 'mission') then"
Code:
if not exhaustion.check(cid, 45646) and getPlayerStorageValue(cid, storage) > 5 then
     setPlayerStorageValue(cid, storage, -1)
end
Then at "Thanks alot! I can finish my research now."
Code:
exhaustion.set(cid, 45646, 86400)
 
If a player did all the missions it's done, if you want to make it that players can do the missions every day, you can set exhaustion to the npc.
Then when the exhaustion is over, set the storage back to -1.
Under "if msgcontains(msg, 'mission') then"
Code:
if not exhaustion.check(cid, 45646) and getPlayerStorageValue(cid, storage) > 5 then
     setPlayerStorageValue(cid, storage, -1)
end
Then at "Thanks alot! I can finish my research now."
Code:
exhaustion.set(cid, 45646, 86400)
Code:
-- Collecting items 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] = {items = {
     {id = 5890, count = 12},
     {id = 5878, count = 20},
     {id = 5896, count = 15},
     {id = 5902, count = 21},
     {id = 5897, count = 35},
     {id = 5894, count = 8}
     },
     message = "Great, I need alot of items, but you can start with",
     level = 15, -- minimum level voor this mission
     rewarditem = {id = 2160, count = 1},
     rewardexp = 15000
   },
   [2] = {items = {
     {id = 5898, count = 20},
     {id = 5921, count = 28},
     {id = 5899, count = 15},
     {id = 5905, count = 25},
     {id = 6097, count = 35},
     {id = 6098, count = 26}
     },
     message = "Thank you, the next items are",
     level = 30,
     rewarditem = {id = 2160, count = 5},
     rewardexp = 40000
   },
   [3] = {items = {
     {id = 5920, count = 45},
     {id = 5879, count = 30},
     {id = 5881, count = 15},
     {id = 5876, count = 18},
     {id = 5877, count = 22}
     },
     message = "Awesome, now get",
     level = 50,
     rewarditem = {id = 2160, count = 15},
     rewardexp = 100000
   },
   [4] = {items = {
     {id = 5913, count = 20},
     {id = 5909, count = 42},
     {id = 5914, count = 38},
     {id = 5911, count = 25},
     {id = 5912, count = 10},
     {id = 5910, count = 10}
     },
     message = "Thanks, now I need",
     level = 70,
     rewarditem = {id = 2160, count = 25},
     rewardexp = 200000
   },
   [5] = {items = {
     {id = 5906, count = 35},
     {id = 5882, count = 42},
     {id = 5893, count = 28},
     {id = 5948, count = 32},
     {id = 5954, count = 22},
     {id = 4850, count = 1}
     },
     message = "Good, only a few items left,",
     level = 100,
     rewarditem = {id = 2160, count = 50},
     rewardexp = 450000
   }
}

local storage = 45550

local function getItemsFromTable(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) > 5 then
     setPlayerStorageValue(cid, storage, -1)
end
         if xstorage == -1 then
             selfSay("I am a scientist 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 {items} 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 items, 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.." "..getItemsFromTable(x.items)..".", cid)
         elseif x then
             local amount = 0
             for i = 1, #x.items do
                 if getPlayerItemCount(cid, x.items[i].id) >= x.items[i].count then
                     amount = amount + 1
                 end
             end
             if amount == #x.items then
                 for i = 1, #x.items do
                     doPlayerRemoveItem(cid, x.items[i].id, x.items[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
                 setPlayerStorageValue(cid, storage, xstorage + 1)
                 local x = missions[getPlayerStorageValue(cid, storage)]
                 if x then
                     selfSay(x.message.." "..getItemsFromTable(x.items)..".", cid)
                 else
                     selfSay("Thanks alot! I can finish my research now.", cid)
                     exhaustion.set(cid, 45646, 86400)
                 end
             else
                 local n = 0
                 for i = 1, #x.items do
                     if getPlayerItemCount(cid, x.items[i].id) < x.items[i].count then
                         n = n + 1
                     end
                 end
                 local text = ""
                 local c = 0
                 for v = 1, #x.items do
                     count, info = x.items[v].count - getPlayerItemCount(cid, x.items[v].id), getItemInfo(x.items[v].id)
                     if getPlayerItemCount(cid, x.items[v].id) < x.items[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 items, you still need to get "..text..".", cid)
             end
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, 'items') and x then
         selfSay("The items I asked you are "..getItemsFromTable(x.items)..".", 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())
sorry but npc is making mission every time i msg him mission Oo even after i done my 5 missions he still give me mission btw how can i make it give me levels not exp? :D like 2 on every mission not exp
@Limos
 
Last edited:
If a player did all the missions it's done, if you want to make it that players can do the missions every day, you can set exhaustion to the npc.
Then when the exhaustion is over, set the storage back to -1.
Under "if msgcontains(msg, 'mission') then"
Code:
if not exhaustion.check(cid, 45646) and getPlayerStorageValue(cid, storage) > 5 then
     setPlayerStorageValue(cid, storage, -1)
end
Then at "Thanks alot! I can finish my research now."
Code:
exhaustion.set(cid, 45646, 86400)
i've got problem now when i made new mission for high level for like 4k and when i done my missions till this mission the npc says
Code:
15:09 Discoverer: The mission I gave you is for level 4000, come back later.
everything is ok till now but in another day these missions must be restarted to start again from 1st mission as you posted UP you gave me a code to restart missions everyday but with this mission i mean 4k didn't remove from this guy on another day and still saying
Code:
15:09 Discoverer: The mission I gave you is for level 4000, come back later.
here is my script after i did some changes and added new one
Code:
-- Collecting items 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] = {items = {
     {id = 5890, count = 12},
     {id = 5894, count = 8}
     },
     message = "Great, I need alot of items, but you can start with",
     level = 15, -- minimum level voor this mission
     rewarditem = {id = 2160, count = 1},
     rewardexp = 15000
   },
   [2] = {items = {
     {id = 5898, count = 20},
     {id = 6098, count = 26}
     },
     message = "Thank you, the next items are",
     level = 30,
     rewarditem = {id = 2160, count = 5},
     rewardexp = 40000
   },
   [3] = {items = {
     {id = 5920, count = 45},
     {id = 5877, count = 22}
     },
     message = "Awesome, now get",
     level = 50,
     rewarditem = {id = 2160, count = 15},
     rewardexp = 100000
   },
   [4] = {items = {
     {id = 5913, count = 20},
     {id = 5910, count = 10}
     },
     message = "Thanks, now I need",
     level = 70,
     rewarditem = {id = 2160, count = 25},
     rewardexp = 200000
   },
   [5] = {items = {
     {id = 5906, count = 35},
     {id = 4850, count = 1}
     },
     message = "Good, only a few items left,",
     level = 100,
     rewarditem = {id = 2160, count = 50},
     rewardlevel = 45
},
   [6] = {items = {
     {id = 5913, count = 20},
     {id = 5910, count = 10}
     },
     message = "last thing",
     level = 4000,
     rewarditem = {id = 2160, count = 100},
     rewardexp = 2000000
   }
}

local storage = 45550

local function getItemsFromTable(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) > 6 then
     setPlayerStorageValue(cid, storage, -1)
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 {items} 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 items, 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.." "..getItemsFromTable(x.items)..".", cid)
         elseif x then
             local amount = 0
             for i = 1, #x.items do
                 if getPlayerItemCount(cid, x.items[i].id) >= x.items[i].count then
                     amount = amount + 1
                 end
             end
             if amount == #x.items then
                 for i = 1, #x.items do
                     doPlayerRemoveItem(cid, x.items[i].id, x.items[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.." "..getItemsFromTable(x.items)..".", cid)
                 else
                     selfSay("Thanks alot! I can finish my research now.", cid)
                     exhaustion.set(cid, 45646, 86400)
                 end
             else
                 local n = 0
                 for i = 1, #x.items do
                     if getPlayerItemCount(cid, x.items[i].id) < x.items[i].count then
                         n = n + 1
                     end
                 end
                 local text = ""
                 local c = 0
                 for v = 1, #x.items do
                     count, info = x.items[v].count - getPlayerItemCount(cid, x.items[v].id), getItemInfo(x.items[v].id)
                     if getPlayerItemCount(cid, x.items[v].id) < x.items[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 items, you still need to get "..text..".", cid)
             end
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, 'items') and x then
         selfSay("The items I asked you are "..getItemsFromTable(x.items)..".", 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())
i hope you help me @Limos
 
Havnt been into scripting for a while but try to change the 5 in the end of this part of the code for a 6
Code:
if not exhaustion.check(cid, 45646) and getPlayerStorageValue(cid, storage) > 5
 
i've got problem now when i made new mission for high level for like 4k and when i done my missions till this mission the npc says
Code:
15:09 Discoverer: The mission I gave you is for level 4000, come back later.
everything is ok till now but in another day these missions must be restarted to start again from 1st mission as you posted UP you gave me a code to restart missions everyday but with this mission i mean 4k didn't remove from this guy on another day and still saying
Code:
15:09 Discoverer: The mission I gave you is for level 4000, come back later.
here is my script after i did some changes and added new one
Code:
-- Collecting items 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] = {items = {
     {id = 5890, count = 12},
     {id = 5894, count = 8}
     },
     message = "Great, I need alot of items, but you can start with",
     level = 15, -- minimum level voor this mission
     rewarditem = {id = 2160, count = 1},
     rewardexp = 15000
   },
   [2] = {items = {
     {id = 5898, count = 20},
     {id = 6098, count = 26}
     },
     message = "Thank you, the next items are",
     level = 30,
     rewarditem = {id = 2160, count = 5},
     rewardexp = 40000
   },
   [3] = {items = {
     {id = 5920, count = 45},
     {id = 5877, count = 22}
     },
     message = "Awesome, now get",
     level = 50,
     rewarditem = {id = 2160, count = 15},
     rewardexp = 100000
   },
   [4] = {items = {
     {id = 5913, count = 20},
     {id = 5910, count = 10}
     },
     message = "Thanks, now I need",
     level = 70,
     rewarditem = {id = 2160, count = 25},
     rewardexp = 200000
   },
   [5] = {items = {
     {id = 5906, count = 35},
     {id = 4850, count = 1}
     },
     message = "Good, only a few items left,",
     level = 100,
     rewarditem = {id = 2160, count = 50},
     rewardlevel = 45
},
   [6] = {items = {
     {id = 5913, count = 20},
     {id = 5910, count = 10}
     },
     message = "last thing",
     level = 4000,
     rewarditem = {id = 2160, count = 100},
     rewardexp = 2000000
   }
}

local storage = 45550

local function getItemsFromTable(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) > 6 then
     setPlayerStorageValue(cid, storage, -1)
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 {items} 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 items, 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.." "..getItemsFromTable(x.items)..".", cid)
         elseif x then
             local amount = 0
             for i = 1, #x.items do
                 if getPlayerItemCount(cid, x.items[i].id) >= x.items[i].count then
                     amount = amount + 1
                 end
             end
             if amount == #x.items then
                 for i = 1, #x.items do
                     doPlayerRemoveItem(cid, x.items[i].id, x.items[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.." "..getItemsFromTable(x.items)..".", cid)
                 else
                     selfSay("Thanks alot! I can finish my research now.", cid)
                     exhaustion.set(cid, 45646, 86400)
                 end
             else
                 local n = 0
                 for i = 1, #x.items do
                     if getPlayerItemCount(cid, x.items[i].id) < x.items[i].count then
                         n = n + 1
                     end
                 end
                 local text = ""
                 local c = 0
                 for v = 1, #x.items do
                     count, info = x.items[v].count - getPlayerItemCount(cid, x.items[v].id), getItemInfo(x.items[v].id)
                     if getPlayerItemCount(cid, x.items[v].id) < x.items[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 items, you still need to get "..text..".", cid)
             end
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, 'items') and x then
         selfSay("The items I asked you are "..getItemsFromTable(x.items)..".", 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())
i hope you help me @Limos
This means the storage value of the player is 6 but the level is less than 4000, so it can't do the last mission yet.
 
This meas the storage value of the player is 6 but the level is less than 4000, so it can't do the last mission yet.
i know but i need the restart these missions on another day ! to back to first missions but this script didn't restart anything when i talk to the npc on another day i couldn't accept any missions cuz there is still last missions didn't finish yet
i need this script to restart all missions to first one on another day even if you didn't finish anyone
 
Havnt been into scripting for a while but try to change the 5 in the end of this part of the code for a 6
Code:
if not exhaustion.check(cid, 45646) and getPlayerStorageValue(cid, storage) > 5
i already changed it to 6 but i got problem that missions didn't restart on another day
 
i know but i need the restart these missions on another day ! to back to first missions but this script didn't restart anything when i talk to the npc on another day i couldn't accept any missions cuz there is still last missions didn't finish yet
i need this script to restart all missions to first one on another day even if you didn't finish anyone
Use time as a storage value, then check the current time against the saved time and whatever modifiers like if 1 days has passed then reset the storage values if it has.

You're really answering your own question.
 
Use time as a storage value, then check the current time against the saved time and whatever modifiers like if 1 days has passed then reset the storage values if it has.

You're really answering your own question.
sorry couldn't understand what you mean :S may you explain more? my english is too bad, you mean that i change the storage everyday, manually?
 
@Limos
help me please to fix this npc please!!! i didn't understand what that guy mean :s
 
I don't understand what you mean, the reason why the npc says that message, I explained it here.
This means the storage value of the player is 6 but the level is less than 4000, so it can't do the last mission yet.
It means the level is lower than 4000.
 
I don't understand what you mean, the reason why the npc says that message, I explained it here.

It means the level is lower than 4000.
i understand but the missions must restart everyday ,aren'tt it? but this didn't happen and on other day i found the npc asks for this mission (4k)
 
Under: setPlayerStorageValue(cid, storage, -1), add this.
Code:
xstorage = getPlayerStorageValue(cid, storage)
 
Under: setPlayerStorageValue(cid, storage, -1), add this.
Code:
xstorage = getPlayerStorageValue(cid, storage)
i've added it like you said and found this error
Code:
-- Collecting items 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] = {items = {
     {id = 5890, count = 12},
     {id = 5894, count = 8}
     },
     message = "Great, I need alot of items, but you can start with",
     level = 15, -- minimum level voor this mission
     rewarditem = {id = 2160, count = 1},
     rewardexp = 15000
   },
   [2] = {items = {
     {id = 5898, count = 20},
     {id = 6098, count = 26}
     },
     message = "Thank you, the next items are",
     level = 30,
     rewarditem = {id = 2160, count = 5},
     rewardexp = 40000
   },
   [3] = {items = {
     {id = 5920, count = 45},
     {id = 5877, count = 22}
     },
     message = "Awesome, now get",
     level = 50,
     rewarditem = {id = 2160, count = 15},
     rewardexp = 100000
   },
   [4] = {items = {
     {id = 5913, count = 20},
     {id = 5910, count = 10}
     },
     message = "Thanks, now I need",
     level = 70,
     rewarditem = {id = 2160, count = 25},
     rewardexp = 200000
   },
   [5] = {items = {
     {id = 5906, count = 35},
     {id = 4850, count = 1}
     },
     message = "Good, only a few items left,",
     level = 10000,
     rewarditem = {id = 2160, count = 50},
     rewardlevel = 45
   }
}

local storage = 45550

local function getItemsFromTable(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) > 5 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 {items} 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 items, 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.." "..getItemsFromTable(x.items)..".", cid)
         elseif x then
             local amount = 0
             for i = 1, #x.items do
                 if getPlayerItemCount(cid, x.items[i].id) >= x.items[i].count then
                     amount = amount + 1
                 end
             end
             if amount == #x.items then
                 for i = 1, #x.items do
                     doPlayerRemoveItem(cid, x.items[i].id, x.items[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.." "..getItemsFromTable(x.items)..".", cid)
                 else
                     selfSay("Thanks alot! I can finish my research now.", cid)
                     exhaustion.set(cid, 45646, 86400)
                 end
             else
                 local n = 0
                 for i = 1, #x.items do
                     if getPlayerItemCount(cid, x.items[i].id) < x.items[i].count then
                         n = n + 1
                     end
                 end
                 local text = ""
                 local c = 0
                 for v = 1, #x.items do
                     count, info = x.items[v].count - getPlayerItemCount(cid, x.items[v].id), getItemInfo(x.items[v].id)
                     if getPlayerItemCount(cid, x.items[v].id) < x.items[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 items, you still need to get "..text..".", cid)
             end
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, 'items') and x then
         selfSay("The items I asked you are "..getItemsFromTable(x.items)..".", 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())
Code:
[27/01/2015 18:00:12] [Error - LuaScriptInterface::loadFile] data/npc/scripts/itemsmissions.lua:92: unexpected symbol near ','
[27/01/2015 18:00:12] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/itemsmissions.lua
[27/01/2015 18:00:12] data/npc/scripts/itemsmissions.lua:92: unexpected symbol near ','
after then i've deleted , from it and the npc still same thing
Code:
     setPlayerStorageValue(cid, storage, -1)
     xstorage = getPlayerStorageValue(cid, storage)
 
Make sure you saved the npc and restarted or reload, if it still gives errors, post the new errors and the script.
 
Make sure you saved the npc and restarted or reload, if it still gives errors, post the new errors and the script.
this is the bug with script
Code:
[28/01/2015 00:38:34] [Error - LuaScriptInterface::loadFile] data/npc/scripts/itemsmissions.lua:92: unexpected symbol near ','
[28/01/2015 00:38:34] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/itemsmissions.lua
[28/01/2015 00:38:34] data/npc/scripts/itemsmissions.lua:92: unexpected symbol near ','
Code:
-- Collecting items 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] = {items = {
     {id = 5890, count = 12},
     {id = 5894, count = 8}
     },
     message = "Great, I need alot of items, but you can start with",
     level = 15, -- minimum level voor this mission
     rewarditem = {id = 2160, count = 1},
     rewardexp = 15000
   },
   [2] = {items = {
     {id = 5898, count = 20},
     {id = 6098, count = 26}
     },
     message = "Thank you, the next items are",
     level = 30,
     rewarditem = {id = 2160, count = 5},
     rewardexp = 40000
   },
   [3] = {items = {
     {id = 5920, count = 45},
     {id = 5877, count = 22}
     },
     message = "Awesome, now get",
     level = 50,
     rewarditem = {id = 2160, count = 15},
     rewardexp = 100000
   },
   [4] = {items = {
     {id = 5913, count = 20},
     {id = 5910, count = 10}
     },
     message = "Thanks, now I need",
     level = 70,
     rewarditem = {id = 2160, count = 25},
     rewardexp = 200000
   },
   [5] = {items = {
     {id = 5906, count = 35},
     {id = 4850, count = 1}
     },
     message = "Good, only a few items left,",
     level = 10000,
     rewarditem = {id = 2160, count = 50},
     rewardlevel = 45
   }
}

local storage = 45550

local function getItemsFromTable(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) > 5 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 {items} 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 items, 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.." "..getItemsFromTable(x.items)..".", cid)
         elseif x then
             local amount = 0
             for i = 1, #x.items do
                 if getPlayerItemCount(cid, x.items[i].id) >= x.items[i].count then
                     amount = amount + 1
                 end
             end
             if amount == #x.items then
                 for i = 1, #x.items do
                     doPlayerRemoveItem(cid, x.items[i].id, x.items[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.." "..getItemsFromTable(x.items)..".", cid)
                 else
                     selfSay("Thanks alot! I can finish my research now.", cid)
                     exhaustion.set(cid, 45646, 86400)
                 end
             else
                 local n = 0
                 for i = 1, #x.items do
                     if getPlayerItemCount(cid, x.items[i].id) < x.items[i].count then
                         n = n + 1
                     end
                 end
                 local text = ""
                 local c = 0
                 for v = 1, #x.items do
                     count, info = x.items[v].count - getPlayerItemCount(cid, x.items[v].id), getItemInfo(x.items[v].id)
                     if getPlayerItemCount(cid, x.items[v].id) < x.items[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 items, you still need to get "..text..".", cid)
             end
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, 'items') and x then
         selfSay("The items I asked you are "..getItemsFromTable(x.items)..".", 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())
 
Remove the comma at line 92.
~~
setPlayerStorageValue(cid, storage, -1),
 
Remove the comma at line 92.
~~
setPlayerStorageValue(cid, storage, -1),
man i already said to you that i changed it and still no working :S i can send you meeting id to check it -.- if you can't understand me
Code:
-- Collecting items 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] = {items = {
     {id = 5890, count = 12},
     {id = 5894, count = 8}
     },
     message = "Great, I need alot of items, but you can start with",
     level = 15, -- minimum level voor this mission
     rewarditem = {id = 2160, count = 1},
     rewardexp = 15000
   },
   [2] = {items = {
     {id = 5898, count = 20},
     {id = 6098, count = 26}
     },
     message = "Thank you, the next items are",
     level = 30,
     rewarditem = {id = 2160, count = 5},
     rewardexp = 40000
   },
   [3] = {items = {
     {id = 5920, count = 45},
     {id = 5877, count = 22}
     },
     message = "Awesome, now get",
     level = 50,
     rewarditem = {id = 2160, count = 15},
     rewardexp = 100000
   },
   [4] = {items = {
     {id = 5913, count = 20},
     {id = 5910, count = 10}
     },
     message = "Thanks, now I need",
     level = 70,
     rewarditem = {id = 2160, count = 25},
     rewardexp = 200000
   },
   [5] = {items = {
     {id = 5906, count = 35},
     {id = 4850, count = 1}
     },
     message = "Good, only a few items left,",
     level = 10000,
     rewarditem = {id = 2160, count = 50},
     rewardlevel = 45
   }
}

local storage = 45550

local function getItemsFromTable(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) > 5 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 {items} 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 items, 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.." "..getItemsFromTable(x.items)..".", cid)
         elseif x then
             local amount = 0
             for i = 1, #x.items do
                 if getPlayerItemCount(cid, x.items[i].id) >= x.items[i].count then
                     amount = amount + 1
                 end
             end
             if amount == #x.items then
                 for i = 1, #x.items do
                     doPlayerRemoveItem(cid, x.items[i].id, x.items[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.." "..getItemsFromTable(x.items)..".", cid)
                 else
                     selfSay("Thanks alot! I can finish my research now.", cid)
                     exhaustion.set(cid, 45646, 86400)
                 end
             else
                 local n = 0
                 for i = 1, #x.items do
                     if getPlayerItemCount(cid, x.items[i].id) < x.items[i].count then
                         n = n + 1
                     end
                 end
                 local text = ""
                 local c = 0
                 for v = 1, #x.items do
                     count, info = x.items[v].count - getPlayerItemCount(cid, x.items[v].id), getItemInfo(x.items[v].id)
                     if getPlayerItemCount(cid, x.items[v].id) < x.items[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 items, you still need to get "..text..".", cid)
             end
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, 'items') and x then
         selfSay("The items I asked you are "..getItemsFromTable(x.items)..".", 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())
 
The script you posted above this still had the comma, I've tested this script and it works fine for me, I can create the npc and start with the missions, if you get new errors, post them.
 
Back
Top