bpm91
Intermediate OT User
- Joined
- May 23, 2019
- Messages
- 931
- Solutions
- 7
- Reaction score
- 128
- Location
- Brazil
- YouTube
- caruniawikibr
I managed to put together a script to talk and exchange a bread for a key, but I'm not able to force the player to say morrin first. I can jump straight to the key, how do I force the player to say morrin first?
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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 creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
if (msgcontains(msg, 'morrin') and Topic[cid] >= 1) then
npcHandler:say(" Ah, I remember that man. We made a deal, guess about what.",cid)
Topic[cid] = 1
end
if msgcontains(msg, 'key') then
npcHandler:say('Right! We can make the same deal if you give a fresh delicious roll. Do you have any?', cid)
npcHandler.topic[cid] = 2
elseif msgcontains(msg, 'yes') then
if npcHandler.topic[cid] == 2 then
local player = Player(cid)
if doPlayerRemoveItem(cid,2690,1) then
npcHandler:say('Here it is.', cid)
local key = player:addItem(2089, 1)
if key then
key:setActionId(4022)
end
else
npcHandler:say('Come back when you have delicious roll.', cid)
end
npcHandler.topic[cid] = 0
end
elseif msgcontains(msg, 'no') then
if npcHandler.topic[cid] == 1 then
npcHandler:say('Believe me, it\'s better for you that way.', cid)
npcHandler.topic[cid] = 0
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setMessage(MESSAGE_FAREWELL, "Good bye.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye.")
npcHandler:addModule(FocusModule:new())