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

NPC Examples for TFS for tibia 8.31 or 8.4

Yeah man! All npcs work fine now!
I delet all "1," and move the tag:
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
for later of shop module...

Only the Blessia npc no work =/! I say Blessings and he no say!!!
 
Hello, can u make npc who sell pacc for 7 days (config able) and promotion? in one script please?

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local premium = { days = 7, cost = 20000, effect = CONST_ME_MAGIC_GREEN }
local promotion = { cost = 20000, effect = CONST_ME_MAGIC_GREEN }

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
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	
	if msgcontains(msg, "premium") or msgcontains(msg, "pacc") then
		selfSay("Do you want to buy "..premium.days.." days of premium account for "..premium.cost.." gold?", cid)
		talkState[talkUser] = 1
	elseif msgcontains(msg, "promotion") or msgcontains(msg, "advance") then
		if getPlayerStorageValue(cid, 30018) ~= TRUE then
			selfSay("I can promote you for "..promotion.cost.." gold. Should I do it?", cid)
			talkState[talkUser] = 2
		else
			selfSay("You are already promoted!", cid)
		end
	elseif msgcontains(msg, "yes") then
		if talkState[talkUser] == 1 then
			if doPlayerRemoveMoney(cid, premium.cost) == TRUE then
				selfSay(premium.days.." days has been added to your account.", cid)
				doSendMagicEffect(getCreaturePosition(cid), premium.effect)
				doPlayerAddPremiumDays(cid, 7)
				talkState[talkUser] = 0
			else
				selfSay("You do not have enough money.", cid)
				talkState[talkUser] = 0
			end
		elseif talkState[talkUser] == 2 then
			if doPlayerRemoveMoney(cid, promotion.cost) == TRUE then
				setPlayerStorageValue(cid, 30018, TRUE)
				selfSay("Enjoy your promotion!", cid)
				doPlayerSetVocation(cid, getPlayerVocation(cid) + 4)
				doSendMagicEffect(getCreaturePosition(cid), promotion.effect)
				talkState[talkUser] = 0
			else
				selfSay("You do not have enough money.", cid)
				talkState[talkUser] = 0
			end
		end
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Can anyone add please any npc with quest?
using quest.xml , storage , etc
With the new system in TFS 0,3B3
Ty guys
 
@ up
Well, when u talk to them, u talk to them in MSG mode.
So many people can talk with the npc.

@ Topic

Very nice, a lot of them are working by me, but not all....
First: u forgot by a few scripts a "'".
And by my which not working there comes in console:


[05/06/2009 23:53:47] Lua Script Error: [Npc interface]
[05/06/2009 23:53:48] data/npc/scripts/jewelry.lua

[05/06/2009 23:53:48] data/npc/scripts/jewelry.lua:11: attempt to index global 'shopModule' (a nil value)
[05/06/2009 23:53:48] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/jewelry.lua


[05/06/2009 23:53:48] Lua Script Error: [Npc interface]
[05/06/2009 23:53:48] data/npc/scripts/rune.lua

[05/06/2009 23:53:48] data/npc/scripts/rune.lua:13: attempt to index global 'shopModule' (a nil value)
[05/06/2009 23:53:48] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/rune.lua


[05/06/2009 23:53:49] Lua Script Error: [Npc interface]
[05/06/2009 23:53:49] data/npc/scripts/necklaces.lua

[05/06/2009 23:53:49] data/npc/scripts/necklaces.lua:11: attempt to index global 'shopModule' (a nil value)
[05/06/2009 23:53:49] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/necklaces.lua

What is that? How i can make the errors away?? Please help!
 
@ To all.
Haven't been active for a while, thanks for the reputations and other replies!
I will work on it soon, and then I will also fix the 8.5(2) items.
But first, I am busy with the monster package project.

@ Yakushi (if you still need help).
adding "shopModule:addSellableItem" on .lua is a bit out of time, so I will make it xml next time.
~Sentielo
 
Back
Top