- Joined
- Nov 17, 2010
- Messages
- 6,830
- Solutions
- 586
- Reaction score
- 5,413
Hi everyone.
The npc works perfectly except if you say all the keywords in one sentence.
If you say 'health' it works fine.
If you say 'health mana potions buff' it will activate all keywords at once.
How do I stop this?
Thanks in advance.
The npc works perfectly except if you say all the keywords in one sentence.
If you say 'health' it works fine.
If you say 'health mana potions buff' it will activate all keywords at once.
How do I stop this?
Thanks in advance.
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, "potions") then
selfSay("There are {health} {mana} and {buff} potions. Which would you like?", cid)
end
if msgcontains(msg, "health") then
if (getPlayerStorageValue(cid,45012) < 1) then
selfSay("Health potions can restore your players life pool. Please take one.", cid)
doPlayerAddItem(cid, 7618, 1)
setPlayerStorageValue(cid,45012,1)
else
selfSay("Health potions can restore your players life pool.", cid)
end
end
if msgcontains(msg, "mana") then
if (getPlayerStorageValue(cid,45013) < 1) then
selfSay("Mana potions can restore your player mana pool. Please take one.", cid)
doPlayerAddItem(cid, 7620, 1)
setPlayerStorageValue(cid,45013,1)
else
selfSay("Mana potions can restore your player mana pool.", cid)
end
end
if msgcontains(msg, "buff") then
if (getPlayerStorageValue(cid,45014) < 1) then
selfSay("Buff potions can temporarily increase your players statistics. Please take a few.", cid)
local bag = doPlayerAddItem(cid, 1987, 1)
doAddContainerItem(bag, 7443, 1)
doAddContainerItem(bag, 7440, 1)
doAddContainerItem(bag, 7439, 1)
setPlayerStorageValue(cid,45014,1)
else
selfSay("Buff potions can temporarily increase your players statistics.", cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())