wafuboe
Active Member
- Joined
- Dec 24, 2010
- Messages
- 884
- Solutions
- 2
- Reaction score
- 26
Well im using Limos task system NPC - Collecting items and monster missions for tfs 1.2 which im currently using, im trying to make several npcs for several tasks in my server.
This is my second npc task. But when im about to accept the task the npc says : 12:20 Dharalis: You already did all the missions, great job though human.
Also this error on console
Any help?
Heres the script
Heres also kill missions in creature scripts
Heres my first task npc dunno if it making some interference
This is my second npc task. But when im about to accept the task the npc says : 12:20 Dharalis: You already did all the missions, great job though human.
Also this error on console
Any help?
Heres the script
Code:
-- Collecting items and monster missions by Limos
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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 = {
[9] = {
monsters = {
{name = "Dwarf", count = 100, storage = 51902},
{name = "Dwarf Soldier", count = 70, storage = 51903},
{name = "Dwarf Guard", count = 30, storage = 51904}
},
message = "Impressive Human remember stay quiet. I need to retrieve dwarven ore, bring me",
level = 8,
rewardexp = 200000
},
[10] = {
items = {
{id = 8891, count = 1}
},
message = "Take my armor, now get lost",
level = 8,
rewarditems = {
{id = 2641, count = 1}
},
rewardexp = 100000
}
}
local storage = 45560
local function getItemsMonstersFromTable(imtable)
local text = ""
for v = 1, #imtable do
local ret = ", "
if v == 1 then
ret = ""
elseif v == #imtable then
ret = " and "
end
text = text .. ret
count = imtable[v].count
if imtable[v].id then
info = ItemType(imtable[v].id)
text = text .. (count > 1 and count or info:getArticle()).." "..(count > 1 and info:getPluralName() or info:getName())
else
text = text .. count .." "..imtable[v].name
end
end
return text
end
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
local x = missions[player:getStorageValue(storage)]
if msgcontains(msg, 'mission') or msgcontains(msg, 'quest') then
if player:getStorageValue(storage) == -1 then
selfSay("You need to be silent for this mission", cid)
npcHandler.topic[cid] = 1
elseif x then
if player:getLevel() >= x.level then
selfSay("Did you "..(x.items and "get "..getItemsMonstersFromTable(x.items) or "kill "..getItemsMonstersFromTable(x.monsters)).."?", cid)
npcHandler.topic[cid] = 1
else
selfSay("The mission I gave you is for level "..x.level..", come back later.", cid)
end
else
selfSay("You already did all the missions, great job though human.", cid)
npcHandler:releaseFocus(cid)
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
if player:getStorageValue(storage) == -1 then
player:setStorageValue(storage, 1)
local x = missions[player:getStorageValue(storage)]
selfSay(x.message.." "..getItemsMonstersFromTable(x.items or x.monsters)..".", cid)
elseif x then
local imtable = x.items or x.monsters
local amount = 0
for it = 1, #imtable do
local check = x.items and player:getItemCount(imtable[it].id) or player:getStorageValue(imtable[it].storage)
if check >= imtable[it].count then
amount = amount + 1
end
end
if amount == #imtable then
if x.items then
for it = 1, #x.items do
player:removeItem(x.items[it].id, x.items[it].count)
end
end
if x.rewarditems then
for r = 1, #x.rewarditems do
player:addItem(x.rewarditems[r].id, x.rewarditems[r].count)
end
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "You received "..getItemsMonstersFromTable(x.rewarditems)..".")
end
if x.rewardexp then
player:addExperience(x.rewardexp)
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "You received "..x.rewardexp.." experience.")
end
player:setStorageValue(storage, player:getStorageValue(storage) + 1)
local x = missions[player:getStorageValue(storage)]
if x then
selfSay(x.message.." "..getItemsMonstersFromTable(x.items or x.monsters)..".", cid)
else
selfSay("Well done! You did a great job on all your missions.", cid)
end
else
local n = 0
for i = 1, #imtable do
local check = x.items and player:getItemCount(imtable[i].id) or player:getStorageValue(imtable[i].storage)
if check < imtable[i].count then
n = n + 1
end
end
local text = ""
local c = 0
for v = 1, #imtable do
local check = x.items and player:getItemCount(imtable[v].id) or player:getStorageValue(imtable[v].storage)
if check < imtable[v].count then
c = c + 1
local ret = ", "
if c == 1 then
ret = ""
elseif c == n then
ret = " and "
end
text = text .. ret
if x.items then
local count, info = imtable[v].count - player:getItemCount(imtable[v].id), ItemType(imtable[v].id)
text = text .. (count > 1 and count or info:getArticle()).." "..(count > 1 and info:getPluralName() or info:getName())
else
local count = imtable[v].count - (player:getStorageValue(imtable[v].storage) + 1)
text = text .. count.." "..imtable[v].name
end
end
end
selfSay(x.items and "You don't have all items, you still need to get "..text.."." or "You didn't kill all monsters, you still need to kill "..text..".", cid)
end
end
npcHandler.topic[cid] = 0
elseif msgcontains(msg, 'no') and npcHandler.topic[cid] == 1 then
selfSay("Oh well, I guess not then.", cid)
npcHandler.topic[cid] = 0
end
return true
end
npcHandler:setMessage(MESSAGE_FAREWELL, "Bye!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye, have a nice day!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Heres also kill missions in creature scripts
Code:
local config = {
['rat'] = {amount = 10, storage = 21900, startstorage = 45551, startvalue = 2},
['cave rat'] = {amount = 3, storage = 21901, startstorage = 45551, startvalue = 2},
['orc'] = {amount = 25, storage = 21902, startstorage = 45551, startvalue = 4},
['orc spearman'] = {amount = 25, storage = 21903, startstorage = 45551, startvalue = 4},
['Pirate Marauder'] = {amount = 10, storage = 31900, startstorage = 45552, startvalue = 6},
['Pirate Corsair'] = {amount = 3, storage = 31901, startstorage = 45552, startvalue = 6},
['Pirate Cutthroat'] = {amount = 25, storage = 31902, startstorage = 45552, startvalue = 6},
['Pirate Buccaneer'] = {amount = 25, storage = 31903, startstorage = 45552, startvalue = 6},
['Dwarf'] = {amount = 100, storage = 51902, startstorage = 45560, startvalue = 9},
['Dwarf Soldier'] = {amount = 70, storage = 51903, startstorage = 45560, startvalue = 9},
['Dwarf Guard'] = {amount = 30, storage = 52904, startstorage = 45560, startvalue = 9}
}
function onKill(player, target)
local player, target = Player(player), Creature(target) -- for TFS 1.0, delete this line if you use 1.1
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, 'Congratulations, 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
Heres my first task npc dunno if it making some interference
Code:
-- Collecting items and monster missions by Limos
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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 = 2677, count = 6},
},
message = "Alright rookie, for your first mission you need to collect some items, I need",
level = 1, -- minimum level voor this mission
rewarditems = {
{id = 2512, count = 1},
},
rewardexp = 100
},
[2] = {
monsters = {
{name = "Rats", count = 10, storage = 21900},
{name = "Cave rats", count = 3, storage = 21901}
},
message = "My belly thanks you, we have a pest problem in town i need you to deal with",
level = 1,
rewarditems = {
{id = 2450, count = 1}
},
rewardexp = 200
},
[3] = {
items = {
{id = 10606, count = 1}
},
message = "Ready rookie for your first troll? Bring me.",
level = 3,
rewarditems = {
{id = 2480, count = 1}
},
rewardexp = 350
},
[4] = {
monsters = {
{name = "Orcs", count = 20, storage = 21902},
{name = "Orc Spearmans", count = 10, storage = 21903}
},
message = "That aint nothing! I want to see your face when you met an orc",
level = 5,
rewarditems = {
{id = 2455, count = 1},
{id = 2543, count = 50}
},
rewardexp = 800
},
[5] = {
items = {
{id = 12435, count = 3},
{id = 10606, count = 5},
{id = 10609, count = 15},
{id = 5878, count = 8},
{id = 11192, count = 1},
{id = 12407, count = 2}
},
message = "Good, now your final mission, a little bit of everything,",
level = 8,
rewarditems = {
{id = 2641, count = 1}
},
rewardexp = 5000
}
}
local storage = 45551
local function getItemsMonstersFromTable(imtable)
local text = ""
for v = 1, #imtable do
local ret = ", "
if v == 1 then
ret = ""
elseif v == #imtable then
ret = " and "
end
text = text .. ret
count = imtable[v].count
if imtable[v].id then
info = ItemType(imtable[v].id)
text = text .. (count > 1 and count or info:getArticle()).." "..(count > 1 and info:getPluralName() or info:getName())
else
text = text .. count .." "..imtable[v].name
end
end
return text
end
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
local x = missions[player:getStorageValue(storage)]
if msgcontains(msg, 'mission') or msgcontains(msg, 'quest') then
if player:getStorageValue(storage) == -1 then
selfSay("I have several missions for you, do you accept the challenge?", cid)
npcHandler.topic[cid] = 1
elseif x then
if player:getLevel() >= x.level then
selfSay("Did you "..(x.items and "get "..getItemsMonstersFromTable(x.items) or "kill "..getItemsMonstersFromTable(x.monsters)).."?", cid)
npcHandler.topic[cid] = 1
else
selfSay("The mission I gave you is for level "..x.level..", come back later.", cid)
end
else
selfSay("You already did all the missions, great job though.", cid)
npcHandler:releaseFocus(cid)
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
if player:getStorageValue(storage) == -1 then
player:setStorageValue(storage, 1)
local x = missions[player:getStorageValue(storage)]
selfSay(x.message.." "..getItemsMonstersFromTable(x.items or x.monsters)..".", cid)
elseif x then
local imtable = x.items or x.monsters
local amount = 0
for it = 1, #imtable do
local check = x.items and player:getItemCount(imtable[it].id) or player:getStorageValue(imtable[it].storage)
if check >= imtable[it].count then
amount = amount + 1
end
end
if amount == #imtable then
if x.items then
for it = 1, #x.items do
player:removeItem(x.items[it].id, x.items[it].count)
end
end
if x.rewarditems then
for r = 1, #x.rewarditems do
player:addItem(x.rewarditems[r].id, x.rewarditems[r].count)
end
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "You received "..getItemsMonstersFromTable(x.rewarditems)..".")
end
if x.rewardexp then
player:addExperience(x.rewardexp)
player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "You received "..x.rewardexp.." experience.")
end
player:setStorageValue(storage, player:getStorageValue(storage) + 1)
local x = missions[player:getStorageValue(storage)]
if x then
selfSay(x.message.." "..getItemsMonstersFromTable(x.items or x.monsters)..".", cid)
else
selfSay("Well done! You did a great job on all your missions.", cid)
end
else
local n = 0
for i = 1, #imtable do
local check = x.items and player:getItemCount(imtable[i].id) or player:getStorageValue(imtable[i].storage)
if check < imtable[i].count then
n = n + 1
end
end
local text = ""
local c = 0
for v = 1, #imtable do
local check = x.items and player:getItemCount(imtable[v].id) or player:getStorageValue(imtable[v].storage)
if check < imtable[v].count then
c = c + 1
local ret = ", "
if c == 1 then
ret = ""
elseif c == n then
ret = " and "
end
text = text .. ret
if x.items then
local count, info = imtable[v].count - player:getItemCount(imtable[v].id), ItemType(imtable[v].id)
text = text .. (count > 1 and count or info:getArticle()).." "..(count > 1 and info:getPluralName() or info:getName())
else
local count = imtable[v].count - (player:getStorageValue(imtable[v].storage) + 1)
text = text .. count.." "..imtable[v].name
end
end
end
selfSay(x.items and "You don't have all items, you still need to get "..text.."." or "You didn't kill all monsters, you still need to kill "..text..".", cid)
end
end
npcHandler.topic[cid] = 0
elseif msgcontains(msg, 'no') and npcHandler.topic[cid] == 1 then
selfSay("Oh well, I guess not then.", cid)
npcHandler.topic[cid] = 0
end
return true
end
npcHandler:setMessage(MESSAGE_FAREWELL, "Bye!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye, have a nice day!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Last edited: