Tested with TFS 0.3.6pl1 8.54
Luffy.xml
questmissions.lua (with same greetmessage)
questmissions.lua (with different greetmessage)
How does it work:
This NPC gives missions to do quests (already existing quests in your server like questboxes).
When the player comes back after a mission the NPC counts how much quests he did.
If the player did the amount of quests the NPC asked, he will get experience and move on to the next mission.
If all the missions are done, he will receive an item as reward.
The counting of quests works with storage, so use the storage you use for your quests.
Feel free to ask questions or to report bugs.
Note: If you use totaly random storage numbers for your quests, with using alot non quest storages in between, then this isn't good to use.
Luffy.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Luffy" script="questmissions.lua" walkinterval="2000" speed="0" floorchange="0">
<health now="150" max="150"/>
<look type="134" head="59" body="76" legs="119" feet="0" addons="3"/>
<parameters>
<parameter key="message_greet" value="Hello, I love doing {quests}, some of them are quite hard though."/>
</parameters>
</npc>
questmissions.lua (with same greetmessage)
Lua:
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] = {amountquests = 3, exp = 10000, confirmmessage = "Well that wasn't so hard was it? Lets go for something a bit more challenging don't you agree?"},
[2] = {amountquests = 10, exp = 25000, confirmmessage = "Well done, want to do more quests?"},
[3] = {amountquests = 20, exp = 50000, confirmmessage = "Good job, do you think you can do more quests?"},
[4] = {amountquests = 35, exp = 100000, confirmmessage = "Great! I have one last mission for you, do you accept?"},
[5] = {amountquests = 50, exp = 200000, confirmmessage = "Amazing, well this is it, or do you want to do more quests?"}
}
local config = {
rewarditem = {id = 2128, count = 1},
startstorage = 4000, -- startstorage of your quests
endstorage = 5000 -- endstorage of your quests
}
local storage, stor = 24560, 19837
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, 'quests')) then
if xstorage == -1 then
selfSay("Did you know there are alot of quests around here?", cid)
elseif x then
selfSay("Did you do "..x.amountquests.." quests?", cid)
end
talkState[talkUser] = 1
if not x and xstorage ~= -1 then
selfSay("You did a great job, all those quests, amazing.", cid)
npcHandler:releaseFocus(cid)
end
end
if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if xstorage == -1 then
selfSay("Good, do you want to try some?", cid)
talkState[talkUser] = 2
elseif x then
local amount = 0
for i = config.startstorage, config.endstorage do
if getPlayerStorageValue(cid, i) >= 1 then
amount = amount +1
end
end
if amount >= x.amountquests then
if getPlayerStorageValue(cid, stor) ~= getPlayerStorageValue(cid, storage) then
selfSay(""..x.confirmmessage, cid)
doPlayerAddExp(cid, x.exp)
setPlayerStorageValue(cid, stor, getPlayerStorageValue(cid, storage))
else
selfSay("Oh wait, I already asked you this before, well doesn't matter, are you in for more quests?", cid)
end
talkState[talkUser] = 2
else
selfSay("What? You did "..amount.." "..(amount == 1 and "quest" or "quests")..", you need to do "..x.amountquests.." quests.", cid)
talkState[talkUser] = 0
end
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
if xstorage == -1 then
setPlayerStorageValue(cid, storage, 1)
xstorage = getPlayerStorageValue(cid, storage)
x = missions[xstorage]
selfSay("Great! You can start with doing "..x.amountquests.." quests, I think that won't be hard for you, good luck!", cid)
elseif x then
setPlayerStorageValue(cid, storage, xstorage + 1)
xstorage = getPlayerStorageValue(cid, storage)
x = missions[xstorage]
if x then
selfSay("Good, now try to do "..x.amountquests.." quests.", cid)
else
selfSay("That's the spirit! But for me this is more then enough, so I will give you your reward for all your hard work.", cid)
local info = getItemInfo(config.rewarditem.id)
if config.rewarditem.count > 1 then
text = config.rewarditem.count.." "..info.plurar
else
text = info.article.." "..info.name
end
selfSay("Here you are, "..text..", enjoy.", cid)
doPlayerAddItem(cid, config.rewarditem.id, config.rewarditem.count)
end
end
talkState[talkUser] = 0
elseif (msgcontains(msg, 'no')) 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())
questmissions.lua (with different greetmessage)
Lua:
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] = {amountquests = 3, exp = 10000, greetmessage = "Oh hello, it's you again", confirmmessage = "Well that wasn't so hard was it? Lets go for something a bit more challenging don't you agree?"},
[2] = {amountquests = 10, exp = 25000, greetmessage = "Huh what? Oh wait, you were doing these quests", confirmmessage = "Well done, want to do more quests?"},
[3] = {amountquests = 20, exp = 50000, greetmessage = "Hey, welcome back", confirmmessage = "Good job, do you think you can do more quests?"},
[4] = {amountquests = 35, exp = 100000, greetmessage = "Hi again", confirmmessage = "Great! I have one last mission for you, do you accept?"},
[5] = {amountquests = 50, exp = 200000, greetmessage = "So, and here you are again", confirmmessage = "Amazing, well this is it, or do you want to do more quests?"}
}
local config = {
rewarditem = {id = 2128, count = 1},
startstorage = 4000, -- startstorage of your quests
endstorage = 5000 -- endstorage of your quests
}
local storage, stor = 24559, 19836
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
if msgcontains(msg, 'hello') or msg == 'hi' then
if xstorage == -1 then
selfSay("Oh hi! Did you know there are alot of quests around here?", cid)
elseif x then
selfSay(x.greetmessage..", did you do "..x.amountquests.." quests?", cid)
end
npcHandler:addFocus(cid)
talkState[talkUser] = 1
if not x and xstorage ~= -1 then
selfSay("You did a great job, all those quests, amazing.", cid)
npcHandler:releaseFocus(cid)
end
else
return false
end
end
if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if xstorage == -1 then
selfSay("Ah well, I love doing them, I already did alot of them myself, want to try some?", cid)
talkState[talkUser] = 2
elseif x then
local amount = 0
for i = config.startstorage, config.endstorage do
if getPlayerStorageValue(cid, i) >= 1 then
amount = amount +1
end
end
if amount >= x.amountquests then
if getPlayerStorageValue(cid, stor) ~= getPlayerStorageValue(cid, storage) then
selfSay(""..x.confirmmessage, cid)
doPlayerAddExp(cid, x.exp)
setPlayerStorageValue(cid, stor, getPlayerStorageValue(cid, storage))
else
selfSay("Oh wait, I already asked you this before, well doesn't matter, are you in for more quests?", cid)
end
talkState[talkUser] = 2
else
selfSay("What? You did "..amount.." "..(amount == 1 and "quest" or "quests")..", you need to do "..x.amountquests.." quests.", cid)
talkState[talkUser] = 0
end
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
if xstorage == -1 then
setPlayerStorageValue(cid, storage, 1)
xstorage = getPlayerStorageValue(cid, storage)
x = missions[xstorage]
selfSay("Great! You can start with doing "..x.amountquests.." quests, I think that won't be hard for you, good luck!", cid)
elseif x then
setPlayerStorageValue(cid, storage, xstorage + 1)
xstorage = getPlayerStorageValue(cid, storage)
x = missions[xstorage]
if x then
selfSay("Good, now try to do "..x.amountquests.." quests.", cid)
else
selfSay("That's the spirit! But for me this is more then enough, so I will give you your reward for all your hard work.", cid)
local info = getItemInfo(config.rewarditem.id)
if config.rewarditem.count > 1 then
text = config.rewarditem.count.." "..info.plurar
else
text = info.article.." "..info.name
end
selfSay("Here you are, "..text..", enjoy.", cid)
doPlayerAddItem(cid, config.rewarditem.id, config.rewarditem.count)
end
end
talkState[talkUser] = 0
elseif (msgcontains(msg, 'no')) then
selfSay("Oh well, I guess not then.", cid)
elseif (msgcontains(msg, 'bye')) then
selfSay("Bye.", cid)
npcHandler:releaseFocus(cid)
end
return true
end
npcHandler:setMessage(MESSAGE_FAREWELL, "Well, what are you waiting for, I don't have all day!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Bye? I guess...")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
How does it work:
This NPC gives missions to do quests (already existing quests in your server like questboxes).
When the player comes back after a mission the NPC counts how much quests he did.
If the player did the amount of quests the NPC asked, he will get experience and move on to the next mission.
If all the missions are done, he will receive an item as reward.
The counting of quests works with storage, so use the storage you use for your quests.
Feel free to ask questions or to report bugs.
Note: If you use totaly random storage numbers for your quests, with using alot non quest storages in between, then this isn't good to use.
Last edited: