• 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!

talkState[talkUser]

Tprocheira

New Member
Joined
Apr 2, 2008
Messages
103
Reaction score
0
How can I use talkState[talkUser] at TFS?
I've trying to make an NPC, and when I say hi, it answers NOTHING.
Code:
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 talker = getCreaturePosition(cid)
local status = getPlayerStorageValue(cid, 10000)	

if((msg == "hi" or msg == "hello") and (status == 0)) then
		selfSay("Who... Who are you, ".. getCreatureName(cid) .."?", cid, TRUE)
		selfSay("Are you hunting me or what!?", cid)
		addFocus(cid)
		talkState[talkUser] = 1
		--Quest - Part 1
		elseif((msg == "no") and (talkState[talkUser] == 1) and (status == 0)) then
			selfSay("Ok then... But, what brings such a person here?", cid)
			talkState[talkUser] = 2
end
end
Should I use onCreatureSay or creatureSayCallBack?
And, am I using it correctly?
Please, answer :D

Tprocheira
 
Use msgcontains(msg, 'hi') instead of msg == "hi"...
 
Then the script will by something like this;

Lua:
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 talker = getCreaturePosition(cid)
local status = getPlayerStorageValue(cid, 10000)	

if((msg == "hi") and (getNpcDistanceToCreature(cid)) <= 3 and not (isFocused(cid))) then
		selfSay("Who... Who are you, ".. getCreatureName(cid) .."?", cid, TRUE)
		selfSay("Are you hunting me or what!?", cid)
		addFocus(cid)
		talkState[talkUser] = 1
		--Quest - Part 1
		elseif((msg == "no") and (talkState[talkUser] == 1) and (status == 0)) then
			selfSay("Ok then... But, what brings such a person here?", cid)
			talkState[talkUser] = 2
end
end
 
Lua:
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 talker = getCreaturePosition(cid)
	local status = getPlayerStorageValue(cid, 10000)	

	if((msgcontains(msg, "hi") or msgcontains(msg, "hello")) and (status == 0)) then
			selfSay("Who... Who are you, ".. getCreatureName(cid) .."?", cid, TRUE)
			selfSay("Are you hunting me or what!?", cid)
			npcHandler:addFocus(cid)
			talkState[talkUser] = 1
			--Quest - Part 1
	elseif((msgcontains(msg, "no")) and (talkState[talkUser] == 1) and (status == 0)) then
		selfSay("Ok then... But, what brings such a person here?", cid)
		talkState[talkUser] = 2
	end
	return true
end

Don't forget this, too:
Lua:
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
And, of course; remove focusModule:
Lua:
npcHandler:addModule(FocusModule:new())
 

Similar threads

Back
Top