My NPC that I have for an arena isn't responding to certain keywords the way I want him to. Basically, When you say "boss arena" to him, he will ask if you want to join. If you say "yes", he sets your storage value at 3501, 1. I'm trying to make it so that when you already have storage value 3501 and say "boss arena", he responds differently than he did the first time. When I go to him and say "boss arena" with storage value 3501, he still asks if I want to join.
Code:
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, 'boss arena') then if getPlayerStorageValue(cid) >= 3501 then
npc:say('Welcome back to the boss arena. Would you like to see what {challenges} are avalible, or are you here to {report} about your success in the arena?s', cid)
elseif(msgcontains(msg, 'boss arena')) then if getPlayerStorageValue(cid) ~= 3501 then
npcHandler:say('The boss arena is a place where strong and mighty warriors gather to test their skills in a fight against some of the toughest creatures in this world. Many have tried, many have failed. Do you think you have what it takes?', cid)
talkState = 1
elseif(msgcontains(msg, 'yes') and talkState == 1) then
npcHandler:say('I am pleased to hear this. You are very brave. There are different types of {challenges}, each challenge has its own difficulty. Please tell me which challenge you would like to take on.', cid)
setPlayerStorageValue(cid, 3501, 1)
talkState = 2
elseif(msgcontains(msg, 'challenges') and talkState == 2) then
npcHandler:say('Currently, the only challenge avalible is the {White Pale}.', cid)
talkState = 3
elseif(msgcontains(msg, 'white pale') or msgcontains(msg, 'White Pale') and talkState == 3) then
npcHandler:say('The White Pale is the easiest monster in the arena. It costs 5 boss tokens to spawn. Would you like to enter the arena?', cid)
talkState = 4
elseif(msgcontains(msg, 'yes') and talkState == 4) then
if(getPlayerItemCount(cid, 24115) >= 5) then
doPlayerRemoveItem(cid, 24115, 5)
setPlayerStorageValue(cid, 3501, 2)
npcHandler:say('Good luck. Flip the lever when you are ready.', cid)
else npcHandler:say('You must have 5 {boss tokens} to enter the arena.', cid)
talkState = 0
end
end
end
end
if(msgcontains(msg, 'report')) then
if(getPlayerStorageValue(cid, 3501) == 3) then
npcHandler:say('Wow, you did it! Congratulations. Here is a small reward for your hard work.', cid)
doPlayerAddItem(cid, 2160, 5)
setPlayerStorageValue(cid, 3501, 4)
talkState = 6
end
end
if(msgcontains(msg, 'boss tokens') or msgcontains(msg, 'boss token')) then
npcHandler:say('Boss tokens are used to gain access to the {boss arena}, in which you can fight unique bosses and get very rare loot. Boss tokens are dropped by every single creature in the game with varying loot chances. You can also get boss tokens by doing missions for NPC\'s and from many different quests..', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())