Lua:
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
if msgcontains(msg, 'mission') then
if getPlayerStorageValue(cid, 10011) == -1 then
npcHandler:say('If u want to enter my training room you shall find Magic Book and retrieve it to me.', cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, 10010) == 1 then
npcHandler:say('Have you retrieved it?', cid)
talkState[talkUser] = 2
elseif getPlayerStorageValue(cid, 10010) == 2 then
npcHandler:say('Thank you for the book. I no longer need your further assistance.', cid)
talkState[talkUser] = 3
end
elseif talkState[talkUser] == 2 then
if msgcontains(msg, 'yes') then
if getPlayerItemCount(uid,10546) == 1 then
doPlayerRemoveItem(cid,10546,1)
npcHandler:say('Thank you! now you have acess to enter in my Training Room.', cid)
setPlayerStorageValue(cid, 10010, 2)
setPlayerStorageValue(cid,10011,1)
talkState[talkUser] = 3
else
npcHandler:say('Sorry...but you dont have item. Come back have them', cid)
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
I want my npc to take book in exchange for entry to training room but it doesnt remove the book.. when I say 'yes' i doesnt do nothing. can any1 help? :/
Last edited: