Eazzy
New Member
- Joined
- Mar 25, 2019
- Messages
- 8
- Solutions
- 1
- Reaction score
- 1
Evening,
Seems i'm having trouble using the Advanced Npc Quest system from @Itutorial
Using the latest TFS 1.3.
My current code:
Seems i'm having trouble using the Advanced Npc Quest system from @Itutorial
Advanced NPC quest system
This is designed to help with creating quest npcs, task npcs, ect. If you have any ideas that you want to see added or find any bugs please post them here. local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local...
otland.net
Using the latest TFS 1.3.
My current code:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local vocation = {}
local town = {}
local destination = {}
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
--[[
words = What the player says to the NPC
reply = What the NPC says back.
setStorage = If you want the NPC to set a storage to the player once he replies.
setStorageNum = What to want to set the storage value to. eg: 1
reqStorage = The NPC wont respond to the message unless that player has this storage set to a specific number
reqStorageNum = The specific number of the required storage. eg: 4.
items = You can add this to give a player items if they have the correct storage.
exp = amount of exp given to the player.
]]--
local messages = {
[1] = {
words = {"yes"}, --If the player says any of these to the NPC
reqStorage = nil, --The NPC checks this storage
reqStorageNum = nil, -- If the reqStorage is == nil (or doesn't exist)
reply = "Finally, I've been having trouble finding capable adventurers", --The NPC will reply with this
setStorage = 44001, --Set his storage for the quest
setStorageNum = 44001 -- To this value (starting the quest)
},
--At this point the player should of finished the quest and their storage value should of been changed to show he has completed it.
[2] = {
words = {"quest", "mission", "adventure", "task"},
reqStorage = 44001,
reqStorageNum = 44001,
reply = "Thank you! Those bony creatures have been destorying all of our tombs.",
setStorage = 44002,
setStorageNum = 44002,
items = {
[1] = {itemid = 2152, amount = 3},
},
exp = 10000
}
}
local function greetCallback(cid)
return true
end
local function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
if msg then
for i = 1, #messages do
if string.lower(msg) == messages[i].words then
if player:getStorageValue(messages[i].reqStorage) == messages[i].reqStorageNum then
self:say(messages[i].reply, cid)
if messages[i].setStorage then
player:setStorageValue(messages[i].setStorage, messages[i].setStorageNum)
end
if messages[i].items then
for x = 1, #messages[i].items do
player:addItem(messages[i].items[x].itemid, messages[i].items[x].amount)
end
end
if messages[i].exp then
player:addExperience(messages[i].exp)
end
end
end
end
end
return true
end
local function onAddFocus(cid)
end
local function onReleaseFocus(cid)
end
npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus)
npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())