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

A simple NPC

breadmaker

New Member
Joined
Jul 16, 2010
Messages
160
Reaction score
3
Hello i need an NPC.


I need to bring him 1 honey flower (ID: 2103).

Dialogue:
- hi
- Welcome in my house, |PLAYERNAME|. My {cat} is really sick...
- cat
- Oh yeah... my Cat is sick, he need special {medicines}.. i can only make them from {honey flowers}.
- medicine/honey flowers
- I need one special flower, called honey. I got an recipe how to make them, but i still need one reagent - the flower.. Can you try to search it for me ?
- yes
- honey flower
- (if player dont have) ; I think you still dont have honey flower, your hands are pretty clean.
- (if player got): Thanks alot my friend! Im going to make this, now!
[Player got 100 exp, storage = 34560, items: 3456, 3457, effect: 32 appear on NPC and on player]


If player done the quest and trying to talk with npc:
- hi
- You already helped me.. thanks! My Cat feel great!
(than focus == 0)
 
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}

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 greetCallback(cid)
	if getPlayerStorageValue(cid, 34560) == 1 then
		npcHandler:say('You\'ve already helped me, thanks! My cat is feeling great!', cid)
	else
		Topic[cid] = 0
		return true
	end
end

function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	elseif msgcontains(msg, 'cat') then
		npcHandler:say('Oh, yes... my cat is sick. He needs special {medicine}, but I can only make it from {honey flowers}.', cid)
		Topic[cid] = nil
	elseif msgcontains(msg, 'medicine') or msgcontains(msg, 'honey flower') then
		npcHandler:say('I need a special flower, called honey. I have a recipe how to make them, but I still need one reagent - the flower... Can you try to find one for me?', cid)
		Topic[cid] = 1
	elseif Topic[cid] == 1 and msgcontains(msg, 'yes') then
		if doPlayerRemoveItem(cid, 2103, 1) then
			npcHandler:say('Thanks a lot my friend! I\'m going to make this, now!', cid)
			doPlayerAddExp(cid, 100)
			setPlayerStorageValue(cid, 34560, 1)
			doPlayerAddItem(cid, 3456, 1)
			doPlayerAddItem(cid, 3457, 1)
			local p = getThingPos(cid)
			doSendAnimatedText(p, 100, 215)
			doSendMagicEffect(getThingPos(getNpcCid()), 32)
			doSendMagicEffect(p, 32)
			npcHandler:releaseFocus(cid)
		else
			npcHandler:say('I think you still don\'t have the honey flower, your hands look pretty clean.', cid)
		end
		Topic[cid] = nil
	end
	return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Welcome to my house, |PLAYERNAME|. My {cat} is really sick...')

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