ond
Veteran OT User
Can someone help me fix my script? The NPC responds wrong. I don't really get any errors but perhaps someone can see the error in the script.
This doesn't work.
LUA:
dofile(getDataDir() .. 'global/greeting.lua')
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = 0
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
function greetCallback(cid)
Topic = 0
return true
end
npcHandler:setMessage(MESSAGE_GREET, "Greetings, young mortal.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "You can never outrun death.")
npcHandler:setMessage(MESSAGE_FAREWELL, "May the dark powers be with you.")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
function creatureSayCallback(cid, type, msg)
if npcHandler.focus ~= cid then
return false
end
msg = msg:lower()
local v = getPlayerStorageValue(cid, 4788) -- Standard Value
if (msgcontains(msg, "quest")) then
if v < 1 then
selfSay("I can reward you greatly if you do a few tasks for me. Are you interested?")
Topic = 1
else
selfSay(v == 4 and "You have already done this quest.")
Topic = 0
end
elseif Topic == 1 then
if msgcontains(msg, "yes") then
selfSay("Fine, I need you to go to the dwarfs nest and bring back my book. They keep it in their nest. Are you still listening?")
Topic = 2
else
selfSay("Then leave. I have no time for people like you.")
npcHandler:releaseFocus()
Topic = 0
end
elseif Topic == 2 then
if msgcontains(msg, "yes") then
selfSay("Very well then report back here when you have got my book.")
setPlayerStorageValue(cid, 4788, 1) -- First mission's value
Topic = 0
else
selfSay("Then leave. I have no time for people like you.")
Topic = 0
end
-- First mission --
elseif (msgcontains(msg, "book") or msgcontains(msg, "mission") or msgcontains("task")) then
if getPlayerStorageValue(cid, 5062) == 1 then
if getPlayerItemCount(cid, 1961) >= 1 then
selfSay("You did it, you find my old book! This will be remembered. Are you ready for another assignment?")
setPlayerStorageValue(cid, 4788, 2)
Topic = 3
else
selfSay(v < 3 and "You haven't finished the current mission." or "You forgot the book..." or "You didn't bring that book yourself...") -- THIS DOESN'T WORK
Topic = 0
end
end
-- Second mission --
elseif Topic == 3 then
if msgcontains(msg, "yes") then -- DON'T RESPOND WHEN SAYING YES.
selfSay("Very well then, the second thing I want you to do is finding a guy named Sony. He lives on the top of the volcano on Goroma Island. Are you still listening?")
Topic = 4
else
selfSay("Fine. Come back when you're ready.")
Topic = 0
end
elseif Topic == 4 then
if msgcontains(msg, "yes") then
selfSay("Good. Find him, talk to him about dark forces. When you've done that, report back to me.")
setPlayerStorageValue(cid, 4788, 3)
Topic = 0
else
selfSay("Fine. Come back when you're ready.")
Topic = 0
end
elseif v == 4 then
if (msgcontains(msg, "mission") or msgcontains(msg, "dark") or msgcontains(msg, "forces")) then
selfSay("Wait... Let's see... Ah yes, I can sense the dark forces within you! Here you go. A little gift for making you run so far.")
doPlayerAddItem(cid, 2195, 1)
Topic = 0
else
selfSay(v < 4 and "You haven't got the dark forces in you.")
Topic = 0
end
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
This doesn't work.
LUA:
selfSay(v < 3 and "You haven't finished the current mission." or "You forgot the book..." or "You didn't bring that book yourself...")
LUA:
elseif Topic == 3 then
if msgcontains(msg, "yes") then
Last edited: