lol
tenta assim então:
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local storage1,storage2 = 123456,654321
if(msgcontains(msg, 'quest') or msgcontains(msg, 'QUEST')) then
selfSay('Entao voce que entrar no castelo das almas perdidas? {yes}', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE then
return selfSay('você não pode estar com battle!', cid)
elseif getPlayerStorageValue(cid,storage1) <= 0 then
return selfSay('Sinto muito mas voce nao podera entrar sem permissao da arvore ancian!.', cid)
elseif getPlayerStorageValue(cid,storage2) >= 1 then
return selfSay('Voce ja teve sua chance seu porco ganancioso!.', cid)
end
setPlayerStorageValue(cid,storage2,1)
selfSay('Pode seguir sua jornada guerreiro!', cid)
doSendMagicEffect(getPlayerPosition(cid), 2)
elseif msg == "no" and talkState[talkUser] >= 1 then
selfSay("Then not", cid)
talkState[talkUser] = 0
npcHandler:releaseFocus(cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())