• 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 Basic NPC Help

Joined
Jul 25, 2007
Messages
382
Reaction score
38
Can someone show me a simple NPC script just respond based on what the player says. Not just one keyword like I see all the scripts or: "would you like blah" player -> "yes" , something happens. I tried doing:

Lua:
	if msgcontains(msg, 'quest') then
			selfSay('Huh? Quest? Just a simple post office here. That all?', cid)
			if msgcontains(msg, 'no') then
				selfSay('Gonna have to be more specific than that lad', cid)
			else
				selfSay('Come again! -wisper- not that you have other options', cid)
			end
	end

Player says quest, npc responds with the proper message but also adds "Come again~" instead of waiting for a response. I can't find any resource on NPC scripting. Help is appreciated.
 
Pretty sure you need to use talkStates.

Like, after you say "quest", give the player a talkState value.
Then if there's a response, like yes or no, check for the talkState value and confirm.

For example:

NPC: Hello, want to do a quest?
<give talkState value 1>
You: Yes

Then, if message contains "yes" and talkState == 1, then
NPC: Okay, first you need to do this, bla bla.
<give talkState value 2>

OR:

You: No

Then, if message contains "no" and talkState == 1, then
NPC: Okay, ask me anytime when you want to begin the quest!
<give talkState value 0>


If you said "yes" and completed the quest, then you'd do something like this:

If message contains "quest" and talkState == 2, then
NPC: Have you completed the quest?
<give talkState value 3>
You: Yes

Then, if message contains "yes" and talkState == 3, then
NPC: Okay, here is your reward.


Refer to this to see an example: http://otland.net/f83/quest-missions-185514/
 
Last edited:
Back
Top