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

{Request NPC} Rupercht

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
I have this script:
Quick fix:
Code:
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 creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	elseif msgcontains(msg, "item") or msgcontains(msg, "offer") then
		npcHandler:say("I accept presents that were stolen from Santa by those little pest Grynch Goblins in exchange for christmas tokens.", cid)
	elseif msgcontains(msg, "token") then
		npcHandler:say("I will trade a gingerbread man for 1 token, the gingerbread recipe for 10, a jewel case for 25, a santa hat for 50 and a santa doll for 100 tokens.", cid)
	elseif msgcontains(msg, "present") or msgcontains(msg, "bag") then
		npcHandler:say("Do you want trade some present bags for christmas tokens?", cid)
		Topic[cid] = 1
	elseif (msgcontains(msg, "gingerbread") and msgcontains(msg, "man")) or msgcontains(msg, "gingerbreadman") then
		npcHandler:say("Do you want trade a christmas token for a gingerbread man?", cid)
		Topic[cid] = 2
	elseif msgcontains(msg, "recipe") then
		npcHandler:say("Do you want trade 10 christmas tokens for a gingerbread man recipe?", cid)
		Topic[cid] = 3
	elseif msgcontains(msg, "jewel") or msgcontains(msg, "case") then
		npcHandler:say("Do you want trade 25 christmas tokens for a jewel case?", cid)
		Topic[cid] = 4
	elseif msgcontains(msg, "hat") then
		npcHandler:say("Do you want trade 50 christmas tokens for a santa hat?", cid)
		Topic[cid] = 5
	elseif msgcontains(msg, "doll") then
		npcHandler:say("Do you want trade 100 christmas tokens for a santa doll?", cid)
		Topic[cid] = 6
	elseif msgcontains(msg, "yes") and Topic[cid] == 1 then
		local tmp = getPlayerItemCount(cid, 6497)
		if 0 < tmp and doPlayerRemoveItem(cid,6497,tmp) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6527,tmp)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 2 then
		if doPlayerRemoveItem(cid,6527,1) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6501,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 3 then
		if doPlayerRemoveItem(cid,6527,10) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6523,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 4 then
		if doPlayerRemoveItem(cid,6527,25) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6104,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 5 then
		if doPlayerRemoveItem(cid,6527,50) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6531,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif msgcontains(msg, "yes") and Topic[cid] == 6 then
		if doPlayerRemoveItem(cid,6527,100) == TRUE then
			npcHandler:say("Here you are.", cid)
			doPlayerAddItem(cid,6512,1)
		else
			npcHandler:say("I only want present bags.", cid)
		end
		Topic[cid] = 0
	elseif Topic[cid] > 0 then
		npcHandler:say("I'll be here when you're ready.", cid)
		Topic[cid] = 0
	end
	return TRUE
end

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


I've found a problem, NPC is not givin' gingerbread.
Is possible to make it 100% real?

Gingerbreadman for 1 Christmas Token
Gingerbread Recipe for 10 Christmas Tokens
Jewel Case for 25 Christmas Tokens
Santa Hat for 50 Christmas Tokens
Santa Backpack for 75 Christmas Tokens
Santa Doll for 100 Christmas Tokens
Snowman Doll for 150 Christmas Tokens
Santa Teddy for 500 Christmas Tokens
 
Wth O.o that script sucks.
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)
	Topic[cid] = 0
	return true
end

function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	elseif Topic[cid] == 1 and msgcontains(msg, "yes") then
		local tmp = getPlayerItemCount(cid, 6497)
		if tmp > 0 then
			doPlayerRemoveItem(cid, 6497, tmp)
			doPlayerAddItem(cid, 6527, tmp)
			npcHandler:say("Thank you. Here are your tokens.", cid)
		end
		Topic[cid] = 0
	elseif Topic[cid] == 2 and msgcontains(msg, "yes") and doPlayerRemoveItem(cid, 6527, 1) then
		doPlayerAddItem(cid, 6501)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] == 2 and msgcontains(msg, "no") then
		npcHandler:say("Then not.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 2 and msgcontains(msg, "gingerbread") and msgcontains(msg, "man") and doPlayerRemoveItem(cid, 6527, 1) then
		doPlayerAddItem(cid, 6501)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 3 and msgcontains(msg, "recipe") and doPlayerRemoveItem(cid, 6527, 10) then
		doPlayerAddItem(cid, 6523)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 4 and msgcontains(msg, "jewel") and msgcontains(msg, "box") and doPlayerRemoveItem(cid, 6527, 25) then
		doPlayerAddItem(cid, 6104)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 5 and msgcontains(msg, "santa") and msgcontains(msg, "hat") and doPlayerRemoveItem(cid, 6527, 50) then
		doPlayerAddItem(cid, 6531)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 6 and msgcontains(msg, "santa") and msgcontains(msg, "backpack") and doPlayerRemoveItem(cid, 6527, 75) then
		doPlayerAddItem(cid, 11263)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 7 and msgcontains(msg, "santa") and msgcontains(msg, "doll") and doPlayerRemoveItem(cid, 6527, 100) then
		doPlayerAddItem(cid, 6512)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 8 and msgcontains(msg, "snowman") and msgcontains(msg, "doll") and doPlayerRemoveItem(cid, 6527, 150) then
		doPlayerAddItem(cid, 11256)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 9 and msgcontains(msg, "santa") and msgcontains(msg, "teddy") and doPlayerRemoveItem(cid, 6527, 500) then
		doPlayerAddItem(cid, 11255)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 3 then
		npcHandler:say("Uhm, sorry, that won't work.", cid)
		Topic[cid] = 0
	elseif (msgcontains(msg, "present") or msgcontains(msg, "stolen")) and getPlayerItemCount(cid, 6497) > 0 then
		npcHandler:say("Will you bring me some stolen presents?", cid)
		Topic[cid] = 1
	elseif msgcontains(msg, "christmas") and msgcontains(msg, "bakery") then
		npcHandler:say("The entrance to the bakery is right behind my hut.", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "turn") and msgcontains(msg, "in") then
		local c = getPlayerItemCount(cid, 6527)
		if c >= 500 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man, a recipe, a jewel box, a santa hat, a santa backpack, a santa doll, a snowman doll or a santa teddy?", cid)
			Topic[cid] = 9
		elseif c >= 150 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man, a recipe, a jewel box, a santa hat, a santa backpack, a santa doll or a snowman doll?", cid)
			Topic[cid] = 8
		elseif c >= 100 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man, a recipe, a jewel box, a santa hat, a santa backpack or a santa doll?", cid)
			Topic[cid] = 7
		elseif c >= 75 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man, a recipe, a jewel box, a santa hat, a santa backpack or a santa doll?", cid)
			Topic[cid] = 6
		elseif c >= 50 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man, a recipe, a jewel box or a santa hat?", cid)
			Topic[cid] = 5
		elseif c >= 25 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man, a recipe or a jewel box?", cid)
			Topic[cid] = 4
		elseif c >= 10 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man or a recipe?", cid)
			Topic[cid] = 3
		elseif c >= 1 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man?", cid)
			Topic[cid] = 2
		else
			npcHandler:say("Sorry, but you do not have a token.", cid)
			Topic[cid] = 0
		end
	elseif msgcontains(msg, "job") then
		npcHandler:say("I am one of {Santa's} helpers. Not one of the little ones, of course!! I tend the reindeer, look after his sleigh and collect the {presents} that are {stolen} by the {goblins}. ...", cid)
		npcHandler:say("If you give me {presents}, I trade you a {token} for each one. {Turn in} your collected tokens for nice prizes.", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "deer") then
		npcHandler:say("They are no ordinary deer, but a rare magical breed. They are fun and nice, you know. The ugly thing about them is that they prefer a stew made of old, worn boots of haste. Guess that keeps them fast and flying. But what a foul stench!!", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "sleigh") then
		npcHandler:say("Oh, the sleigh is magical, of course. It was made by some djinn that owed good old Santa a favour.", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "token") then
		npcHandler:say("If you have any tokens you'd like to turn in, just tell me to {turn in} the tokens. ...", cid)
		npcHandler:say("For 1 token you will get a gingerbread man. For 10 tokens I will give you a recipe so you can make your own gingerbread men in the {christmas bakery}. ...", cid)
		npcHandler:say("For 25 tokens I will give you a jewel box, while you can trade 50 tokens for a hat, just like the one Santa has. ...", cid)
		npcHandler:say("75 tokens are enough for a fluffy santa backpack, and for 100 tokens you will get a santa doll. I trade 150 tokens for a snowman doll, and finally 500 tokens for a santa teddy.", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "santa") then
		npcHandler:say("Well, he does not really like it if someone tells his story ... but I do! A long, long time ago Santa was nothing but a greedy little dwarf. A real miser, I tell ya ...", cid)
		npcHandler:say("He was greedy even by dwarven standards. He would never share anything or give away the cheapest thing in his possession ...", cid)
		npcHandler:say("One day a woman came to his house and asked him for a cup of water ...", cid)
		npcHandler:say("Of course he refused. He even mocked her for being so naive. But what he did not know was that this woman was some kind of mighty fairy or perhaps a goddess in disguise ...", cid)
		npcHandler:say("Be it as it may, the woman cursed old Santa, forcing him to share his fortune with everyone he met ...", cid)
		npcHandler:say("Santa was horrified. Of course, he could not bear the thought of sharing anything at all. So he went into hiding ...", cid)
		npcHandler:say("He hid in the most remote places in the world, but time and again someone found him out, and the curse made him share his wealth ...", cid)
		npcHandler:say("And know something? Old santa actually came to like it! He saw the joy his presents brought, and this opened his old stony heart ...", cid)
		npcHandler:say("And he learnt that this way his fortune gave him more joy and pleasure than it ever did when he locked it away. ...", cid)
		npcHandler:say("Over the years he turned it into a game. He hid somewhere to reward those who found him ...", cid)
		npcHandler:say("But once every year, on a very special day which happens to be his curse's anniversary, he goes out and brings presents to the people, and especially to the children ...", cid)
		npcHandler:say("Well, that is his story ... Nah, that's not a tear in my eye. It's just the wind, you know.", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "goblin") or msgcontains(msg, "grynch") then
		npcHandler:say("The goblins of clan Grynch are a constant nuisance. They steal everything that is not nailed to the ground, and if possible even that. ...", cid)
		npcHandler:say("They do not shrink away from stealing presents from little children. If you should manage to get your hands on the {stolen presents} Santa will gladly return them to their rightful owners.", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "present") or msgcontains(msg, "stolen") then
		npcHandler:say("The goblins of clan Grynch have made it a habit to steal presents in the cities and even from Santa's sleigh. If you should find any, please return them to me and I will reward you with a {token}. You can collect tokens and trade them for a nice gift.", cid)
		Topic[cid] = 0
	end
	return true
end

npcHandler:setMessage(MESSAGE_GREET, "A merry christmas and a 'Ho!Ho!Ho!' to you, |PLAYERNAME|! Anything I can help you with?")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye! And happy holidays, my friend!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Good bye! And happy holidays, my friend!")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
If you're using the old items.otb:
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)
	Topic[cid] = 0
	return true
end
 
function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	elseif Topic[cid] == 1 and msgcontains(msg, "yes") then
		local tmp = getPlayerItemCount(cid, 6497)
		if tmp > 0 then
			doPlayerRemoveItem(cid, 6497, tmp)
			doPlayerAddItem(cid, 6527, tmp)
			npcHandler:say("Thank you. Here are your tokens.", cid)
		end
		Topic[cid] = 0
	elseif Topic[cid] == 2 and msgcontains(msg, "yes") and doPlayerRemoveItem(cid, 6527, 1) then
		doPlayerAddItem(cid, 6501)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] == 2 and msgcontains(msg, "no") then
		npcHandler:say("Then not.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 2 and msgcontains(msg, "gingerbread") and msgcontains(msg, "man") and doPlayerRemoveItem(cid, 6527, 1) then
		doPlayerAddItem(cid, 6501)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 3 and msgcontains(msg, "recipe") and doPlayerRemoveItem(cid, 6527, 10) then
		doPlayerAddItem(cid, 6523)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 4 and msgcontains(msg, "jewel") and msgcontains(msg, "box") and doPlayerRemoveItem(cid, 6527, 25) then
		doPlayerAddItem(cid, 6104)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 5 and msgcontains(msg, "santa") and msgcontains(msg, "hat") and doPlayerRemoveItem(cid, 6527, 50) then
		doPlayerAddItem(cid, 6531)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 6 and msgcontains(msg, "santa") and msgcontains(msg, "backpack") and doPlayerRemoveItem(cid, 6527, 75) then
		doPlayerAddItem(cid, 11257)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 7 and msgcontains(msg, "santa") and msgcontains(msg, "doll") and doPlayerRemoveItem(cid, 6527, 100) then
		doPlayerAddItem(cid, 6512)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 8 and msgcontains(msg, "snowman") and msgcontains(msg, "doll") and doPlayerRemoveItem(cid, 6527, 150) then
		doPlayerAddItem(cid, 11250)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 9 and msgcontains(msg, "santa") and msgcontains(msg, "teddy") and doPlayerRemoveItem(cid, 6527, 500) then
		doPlayerAddItem(cid, 11249)
		npcHandler:say("Thank you. Here it is.", cid)
		Topic[cid] = 0
	elseif Topic[cid] >= 3 then
		npcHandler:say("Uhm, sorry, that won't work.", cid)
		Topic[cid] = 0
	elseif (msgcontains(msg, "present") or msgcontains(msg, "stolen")) and getPlayerItemCount(cid, 6497) > 0 then
		npcHandler:say("Will you bring me some stolen presents?", cid)
		Topic[cid] = 1
	elseif msgcontains(msg, "christmas") and msgcontains(msg, "bakery") then
		npcHandler:say("The entrance to the bakery is right behind my hut.", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "turn") and msgcontains(msg, "in") then
		local c = getPlayerItemCount(cid, 6527)
		if c >= 500 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man, a recipe, a jewel box, a santa hat, a santa backpack, a santa doll, a snowman doll or a santa teddy?", cid)
			Topic[cid] = 9
		elseif c >= 150 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man, a recipe, a jewel box, a santa hat, a santa backpack, a santa doll or a snowman doll?", cid)
			Topic[cid] = 8
		elseif c >= 100 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man, a recipe, a jewel box, a santa hat, a santa backpack or a santa doll?", cid)
			Topic[cid] = 7
		elseif c >= 75 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man, a recipe, a jewel box, a santa hat, a santa backpack or a santa doll?", cid)
			Topic[cid] = 6
		elseif c >= 50 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man, a recipe, a jewel box or a santa hat?", cid)
			Topic[cid] = 5
		elseif c >= 25 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man, a recipe or a jewel box?", cid)
			Topic[cid] = 4
		elseif c >= 10 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man or a recipe?", cid)
			Topic[cid] = 3
		elseif c >= 1 then
			npcHandler:say("Would you like to turn in your tokens for a gingerbread man?", cid)
			Topic[cid] = 2
		else
			npcHandler:say("Sorry, but you do not have a token.", cid)
			Topic[cid] = 0
		end
	elseif msgcontains(msg, "job") then
		npcHandler:say("I am one of {Santa's} helpers. Not one of the little ones, of course!! I tend the reindeer, look after his sleigh and collect the {presents} that are {stolen} by the {goblins}. ...", cid)
		npcHandler:say("If you give me {presents}, I trade you a {token} for each one. {Turn in} your collected tokens for nice prizes.", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "deer") then
		npcHandler:say("They are no ordinary deer, but a rare magical breed. They are fun and nice, you know. The ugly thing about them is that they prefer a stew made of old, worn boots of haste. Guess that keeps them fast and flying. But what a foul stench!!", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "sleigh") then
		npcHandler:say("Oh, the sleigh is magical, of course. It was made by some djinn that owed good old Santa a favour.", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "token") then
		npcHandler:say("If you have any tokens you'd like to turn in, just tell me to {turn in} the tokens. ...", cid)
		npcHandler:say("For 1 token you will get a gingerbread man. For 10 tokens I will give you a recipe so you can make your own gingerbread men in the {christmas bakery}. ...", cid)
		npcHandler:say("For 25 tokens I will give you a jewel box, while you can trade 50 tokens for a hat, just like the one Santa has. ...", cid)
		npcHandler:say("75 tokens are enough for a fluffy santa backpack, and for 100 tokens you will get a santa doll. I trade 150 tokens for a snowman doll, and finally 500 tokens for a santa teddy.", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "santa") then
		npcHandler:say("Well, he does not really like it if someone tells his story ... but I do! A long, long time ago Santa was nothing but a greedy little dwarf. A real miser, I tell ya ...", cid)
		npcHandler:say("He was greedy even by dwarven standards. He would never share anything or give away the cheapest thing in his possession ...", cid)
		npcHandler:say("One day a woman came to his house and asked him for a cup of water ...", cid)
		npcHandler:say("Of course he refused. He even mocked her for being so naive. But what he did not know was that this woman was some kind of mighty fairy or perhaps a goddess in disguise ...", cid)
		npcHandler:say("Be it as it may, the woman cursed old Santa, forcing him to share his fortune with everyone he met ...", cid)
		npcHandler:say("Santa was horrified. Of course, he could not bear the thought of sharing anything at all. So he went into hiding ...", cid)
		npcHandler:say("He hid in the most remote places in the world, but time and again someone found him out, and the curse made him share his wealth ...", cid)
		npcHandler:say("And know something? Old santa actually came to like it! He saw the joy his presents brought, and this opened his old stony heart ...", cid)
		npcHandler:say("And he learnt that this way his fortune gave him more joy and pleasure than it ever did when he locked it away. ...", cid)
		npcHandler:say("Over the years he turned it into a game. He hid somewhere to reward those who found him ...", cid)
		npcHandler:say("But once every year, on a very special day which happens to be his curse's anniversary, he goes out and brings presents to the people, and especially to the children ...", cid)
		npcHandler:say("Well, that is his story ... Nah, that's not a tear in my eye. It's just the wind, you know.", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "goblin") or msgcontains(msg, "grynch") then
		npcHandler:say("The goblins of clan Grynch are a constant nuisance. They steal everything that is not nailed to the ground, and if possible even that. ...", cid)
		npcHandler:say("They do not shrink away from stealing presents from little children. If you should manage to get your hands on the {stolen presents} Santa will gladly return them to their rightful owners.", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "present") or msgcontains(msg, "stolen") then
		npcHandler:say("The goblins of clan Grynch have made it a habit to steal presents in the cities and even from Santa's sleigh. If you should find any, please return them to me and I will reward you with a {token}. You can collect tokens and trade them for a nice gift.", cid)
		Topic[cid] = 0
	end
	return true
end
 
npcHandler:setMessage(MESSAGE_GREET, "A merry christmas and a 'Ho!Ho!Ho!' to you, |PLAYERNAME|! Anything I can help you with?")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye! And happy holidays, my friend!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Good bye! And happy holidays, my friend!")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
gingerbread, recipe, jewel, hat, backpack ..

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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
elseif msgcontains(msg, "item") or msgcontains(msg, "offer") then
npcHandler:say("I accept presents that were stolen from Santa by those little pest Grynch Goblins in exchange for christmas tokens.", cid)
elseif msgcontains(msg, "token") then
npcHandler:say("I will trade a gingerbread man for 1 token, the gingerbread recipe for 10, a jewel case for 25, a santa hat for 50 and a santa doll for 100 tokens.", cid)
elseif msgcontains(msg, "present") or msgcontains(msg, "bag") then
npcHandler:say("Do you want trade some present bags for christmas tokens?", cid)
Topic[cid] = 1
elseif msgcontains(msg, "gingerbread") or msgcontains(msg, "man") then
npcHandler:say("Do you want trade a christmas token for a gingerbread man?", cid)
Topic[cid] = 2
elseif msgcontains(msg, "recipe") then
npcHandler:say("Do you want trade 10 christmas tokens for a gingerbread man recipe?", cid)
Topic[cid] = 3
elseif msgcontains(msg, "jewel") or msgcontains(msg, "case") then
npcHandler:say("Do you want trade 25 christmas tokens for a jewel case?", cid)
Topic[cid] = 4
elseif msgcontains(msg, "hat") then
npcHandler:say("Do you want trade 50 christmas tokens for a santa hat?", cid)
Topic[cid] = 5
elseif msgcontains(msg, "santa doll") then
npcHandler:say("Do you want trade 100 christmas tokens for a santa doll?", cid)
Topic[cid] = 6
elseif msgcontains(msg, "santa backpack") then
npcHandler:say("Do you want trade 75 christmas tokens for a santa backpack?", cid)
Topic[cid] = 7
elseif msgcontains(msg, "yes") and Topic[cid] == 1 then
local tmp = getPlayerItemCount(cid, 6497)
if 0 < tmp and doPlayerRemoveItem(cid,6497,tmp) == TRUE then
npcHandler:say("Here you are.", cid)
doPlayerAddItem(cid,6527,tmp)
else
npcHandler:say("I only want present bags.", cid)
end
Topic[cid] = 0
elseif msgcontains(msg, "yes") and Topic[cid] == 2 then
if doPlayerRemoveItem(cid,6527,1) == TRUE then
npcHandler:say("Here you are.", cid)
doPlayerAddItem(cid,6501,1)
else
npcHandler:say("I only want present bags.", cid)
end
Topic[cid] = 0
elseif msgcontains(msg, "yes") and Topic[cid] == 3 then
if doPlayerRemoveItem(cid,6527,10) == TRUE then
npcHandler:say("Here you are.", cid)
doPlayerAddItem(cid,6523,1)
else
npcHandler:say("I only want present bags.", cid)
end
Topic[cid] = 0
elseif msgcontains(msg, "yes") and Topic[cid] == 4 then
if doPlayerRemoveItem(cid,6527,25) == TRUE then
npcHandler:say("Here you are.", cid)
doPlayerAddItem(cid,6104,1)
else
npcHandler:say("I only want present bags.", cid)
end
Topic[cid] = 0
elseif msgcontains(msg, "yes") and Topic[cid] == 5 then
if doPlayerRemoveItem(cid,6527,50) == TRUE then
npcHandler:say("Here you are.", cid)
doPlayerAddItem(cid,6531,1)
else
npcHandler:say("I only want present bags.", cid)
end
Topic[cid] = 0
elseif msgcontains(msg, "yes") and Topic[cid] == 6 then
if doPlayerRemoveItem(cid,6527,100) == TRUE then
npcHandler:say("Here you are.", cid)
doPlayerAddItem(cid,6512,1)
else
npcHandler:say("I only want present bags.", cid)
end
Topic[cid] = 0
elseif msgcontains(msg, "yes") and Topic[cid] == 7 then
if doPlayerRemoveItem(cid,6527,75) == TRUE then
npcHandler:say("Here you are.", cid)
doPlayerAddItem(cid,11257,1)
else
npcHandler:say("I only want present bags.", cid)
end
Topic[cid] = 0
elseif Topic[cid] > 0 then
npcHandler:say("I'll be here when you're ready.", cid)
Topic[cid] = 0
end
return TRUE
end

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

This scripts is working, BUT when I try to add itens he give me only gingerbread.
 
You must first say "turn in" :p It works exactly the same as the NPC in real Tibia. Well atleast exactly how it worked last year.
 
You must first say "turn in" :p It works exactly the same as the NPC in real Tibia. Well atleast exactly how it worked last year.

OMG, realy sorry, you script works fine, sorry.

Thank you Cyko.
PS: I know that you are a busy man but if you can help here I will be happy :D
 
Last edited:
Back
Top