• 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 Problem with NPC

brunolopes

New Member
Joined
Nov 8, 2009
Messages
49
Reaction score
1
Hello, people!

I have a problem with NPCs, in the area of TalkStates...
Actually my NPCs isn't obbeying the talkstates, when I say 'yes', a NPC say all the his sentences related to the "yes", for example:

Code:
if(msgcontains(msg, "yes")) then
		npcHandler:say("=)", cid)
		talkState[talkUser] = 2
end

if(msgcontains(msg, "yes") and talkState[talkUser] == 2) then
		npcHandler:say("=D", cid)
		talkState[talkUser] = 3
end

if(msgcontains(msg, "yes") and talkState[talkUser] == 3) then
		npcHandler:say("xD", cid)
		talkState[talkUser] = 4
end

With one "yes", the NPC will say "=)", "=D" and "xD" at once.
Can you help me?

Sorry for my english...
 
you have this after function callback
Code:
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
??
 
Use elseif, not if
Lua:
if(msgcontains(msg, "yes")) then
	npcHandler:say("=)", cid)
	talkState[talkUser] = 2
elseif(msgcontains(msg, "yes") and talkState[talkUser] == 2) then
	npcHandler:say("=D", cid)
	talkState[talkUser] = 3
elseif(msgcontains(msg, "yes") and talkState[talkUser] == 3) then
	npcHandler:say("xD", cid)
	talkState[talkUser] = 4
end
 
Back
Top