• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Npc problem

tiddpd

PHP Scripter
Joined
Apr 16, 2008
Messages
331
Reaction score
0
I am trying to make a simple convo with an npc that I've done several times before exactly like this, but however after the npc asks the quesion, and I say yes, he does nothing. I've spent an hour trying different combos and stuff and I just can't get him to say anything after the yes. Whats the problem?

Here's the code:

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
	local storage = getPlayerStorageValue(cid, 13)

	if(msgcontains(msg, 'base elements') or msgcontains(msg, 'elements')) then
		if storage == 31063 then 
			selfSay('Welcome back ' ..getPlayerName(cid)..'. Do you have all the required items?', cid)
			talkState[talkUser] = 1

		elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
			if(doPlayerRemoveItem(cid, 2746, 1) and doPlayerRemoveItem(cid, 4851, 1) and doPlayerRemoveItem(cid, 8262, 1)) then
				selfSay('Ah, yes that did it! Please take this note to Neklis so that he might begin selling this wonderful necklace!', cid)
			end
		end
	end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top