bpm91
Intermediate OT User
- Joined
- May 23, 2019
- Messages
- 931
- Solutions
- 7
- Reaction score
- 127
- Location
- Brazil
- YouTube
- caruniawikibr
hello I would like to know how I do it for an npc, in the middle of the conversation, give me a key and withdraw 500 gold for example.
Lua:
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 function greetCallback(cid)
npcHandler:setMessage(MESSAGE_GREET, "Hello, |PLAYERNAME|! What can I do for you?")
return true
end
local function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
if msgcontains(msg, "netlios") then
npcHandler:say({
"That fool! His book is nothing but a hoax! At least I believe that. Or did you find an answer to my questions?"
}, cid)
npcHandler.topic[cid] = 1
return true
end
if npcHandler.topic[cid] == 1 then
if msgcontains(msg, "yes") then
npcHandler:say({
"You can't even say 'yes' or 'no'. You are not worth talking to me!"
}, cid)
npcHandler.topic[cid] = 2
return true
end
end
if npcHandler.topic[cid] == 2 then
if msgcontains(msg, "yes") then
npcHandler:say({
"By the way, I'd like a donation for my temple. Are 500 gold pieces ok?"
}, cid)
npcHandler.topic[cid] = 3
return true
end
end
if npcHandler.topic[cid] == 3 then
if msgcontains(msg, "yes") then
npcHandler:say({
"Thank you very much. Now, name me the first person in alphabetical order, his age, his fate, and how long he was on his journeys!"
}, cid)
npcHandler.topic[cid] = 4
return true
end
end
if npcHandler.topic[cid] == 4 then
if msgcontains(msg, "anaso") then
npcHandler:say({
"Hmmm, maybe. What can you tell me about the second adventurer?"
}, cid)
npcHandler.topic[cid] = 5
return true
end
end
if npcHandler.topic[cid] == 5 then
if msgcontains(msg, "elaeus") then
npcHandler:say({
"Yes, that might be true. What did you find out about the third man?"
}, cid)
npcHandler.topic[cid] = 6
return true
end
end
if npcHandler.topic[cid] == 6 then
if msgcontains(msg, "gadinius") then
npcHandler:say({
"Correct again! Hmmmm... I doubt you know anything about the fourth person!"
}, cid)
npcHandler.topic[cid] = 7
return true
end
end
if npcHandler.topic[cid] == 7 then
if msgcontains(msg, "heso") then
npcHandler:say({
"Yes! Really, how did you figure that out? I bet you don't know anything about the last adventurer!"
}, cid)
npcHandler.topic[cid] = 8
return true
end
end
if npcHandler.topic[cid] == 8 then
if msgcontains(msg, "hestus") then
npcHandler:say({
"That's right! Why didn't I see it? It's obvious, Netlios was right, and his stories are great! Wait, I'll give you something!"
}, cid)
npcHandler.topic[cid] = 0
return true
end
end
return true
end
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'My name is Adrenius.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = ' I\'m a priest of Fafnar.'})
keywordHandler:addKeyword({'excalibug'}, StdModule.say, {npcHandler = npcHandler, text = 'What\'s that? You start annoying me.'})
keywordHandler:addKeyword({'fight'}, StdModule.say, {npcHandler = npcHandler, text = 'The king encouraged salesmen to travel here, but only I dared to take the risk, and a risk it was!'})
keywordHandler:addKeyword({'king'}, StdModule.say, {npcHandler = npcHandler, text = 'Who needs a king? I don\'t.'})
keywordHandler:addKeyword({'priestess'}, StdModule.say, {npcHandler = npcHandler, text = 'I live a solitary life here to meditate and contemplate..'})
keywordHandler:addKeyword({'secret'}, StdModule.say, {npcHandler = npcHandler, text = 'Secrets ... What do you mean?'})
keywordHandler:addKeyword({'sword'}, StdModule.say, {npcHandler = npcHandler, text = 'Swords? Don\'t you have something else to do?'})
keywordHandler:addKeyword({'treasure'}, StdModule.say, {npcHandler = npcHandler, text = 'Treasures? What is a treasure for you?'})
keywordHandler:addKeyword({'weapon'}, StdModule.say, {npcHandler = npcHandler, text = 'Who needs weapons? I never had and i never will have weapons - what for?'})
keywordHandler:addKeyword({'library'}, StdModule.say, {npcHandler = npcHandler, text = 'I heard of the library, but I never was very interested in it.'})
keywordHandler:addKeyword({'book'}, StdModule.say, {npcHandler = npcHandler, text = 'Read books, it increases your intelligence and, furthermore, it\'s a great source of inspiration!'})
keywordHandler:addKeyword({'ankrahmun'}, StdModule.say, {npcHandler = npcHandler, text = 'Fafnar may burn this city of evil. Its heretical inhabitants and their blasphemous leader are an insult to the gods. Beware! The day of reckoning is at hand!'})
keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, text = 'Carlin? Don\'t you mean Thais?'})
keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, text = 'Even after the death of this swindler Daraman, the descendants of his followers cling to his ignorant teachings.'})
keywordHandler:addKeyword({'daraman'}, StdModule.say, {npcHandler = npcHandler, text = 'The Daramian deserts are much more impressive than this one. Sadly the continent is run over by heretics of all sorts...'})
keywordHandler:addKeyword({'desert'}, StdModule.say, {npcHandler = npcHandler, text = 'Sand, sand and again sand. Sand all over. Yes, I\'d say: it\'s truly a desert!'})
keywordHandler:addKeyword({'tower'}, StdModule.say, {npcHandler = npcHandler, text = 'The tower was built and inhabited by the great sage Jakundaf himself. It\'s a shame that it can be rented nowadays. People have no respect for the past!'})
keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, text = 'Yyyyess. Yes, it\'s the capital city of Tibia I think.'})
keywordHandler:addKeyword({'god'}, StdModule.say, {npcHandler = npcHandler, text = 'Fafnar is the greatest among the gods.'})
keywordHandler:addKeyword({'farfnar'}, StdModule.say, {npcHandler = npcHandler, text = 'Fafnar is the stronger one of the two suns above our world.'})
keywordHandler:addKeyword({'suon'}, StdModule.say, {npcHandler = npcHandler, text = 'Suon is the misguided sibling of the great Fafnar. Suon\'s light turns pale compared to the brightness of Fafnar.'})
keywordHandler:addKeyword({'door'}, StdModule.say, {npcHandler = npcHandler, text = 'Who needs doors? Free your mind!'})
keywordHandler:addKeyword({'time'}, StdModule.say, {npcHandler = npcHandler, text = 'Time? What is time? A word? A thing? An object?'})
keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, text = 'I can offer you religion and mysticism.'})
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())