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

What's wrong in this npc?

Kayan

Active Member
Joined
Sep 19, 2007
Messages
1,561
Reaction score
38
Location
Santa Catarina
What is the problem of this NPC, well I think everything is right, but the times I'll buy an item he delivered another, someone who knows the Jiddo System can I say that there is something wrong?

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return false
	end
-- Mystican Blade --
if msgcontains(msg, 'mystican') then
	npcHandler:say('Você quer trocar 15 dias de premium account por uma Mystican Blade?')
	talkState = 1
	elseif msgcontains(msg, 'yes') and talkState == 1 then
	talkState = 0
if getPlayerPremiumDays(cid) >= 15 then
	if getPlayerLevel(cid) >= 100 then
		if getPlayerVocation(cid) == 8 then
	        if getPlayerStorageValue(cid, 333) == -1 then
			    if doPlayerRemovePremiumDays(cid, 15) then
		        doSetItemSpecialDescription(doPlayerAddItem(cid,7385, 1),'It is a mystican blade forjed for '..getCreatureName(cid)..'. The blade of the sword can defeat his opponent in one blow.')
				setPlayerStorageValue(cid,333, 1)
				npcHandler:say('Aqui esta sua Mystican Blade.')
		        talkState = 0
				end
		    else
			npcHandler:say('Desculpe, mas somente é possivel comprar uma Mystican Blade por jogador.')
			talkState = 0
		    end
		else
		npcHandler:say('Desculpe, você precisa ser Elite Knight para comprar uma Mystican Blade')
		talkState = 0
	    end
    else
	npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar sua Mystican Blade.')
	talkState = 0
	end
else
npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar sua Mystican Blade. Por favor volte quando tiver.')
talkState = 0
end

-- Guardian Axe --
elseif msgcontains(msg, 'guardian') then
			npcHandler:say('Você quer trocar 15 dias de premium account por um Guardian Axe?')
			talkState = 2
		elseif msgcontains(msg, 'yes') and talkState == 2 then
			talkState = 0
if getPlayerPremiumDays(cid) >= 15 then
	if getPlayerLevel(cid) >= 100 then
		if getPlayerVocation(cid) == 8 then
	        if getPlayerStorageValue(cid, 334) == -1 then
			    if doPlayerRemovePremiumDays(cid, 15) then
		        doSetItemSpecialDescription(doPlayerAddItem(cid,7436, 1),'It is a guardian axe forjed for '..getCreatureName(cid)..'. You feel the power of this axe.')
	            setPlayerStorageValue(cid,334, 1)
				npcHandler:say('Aqui esta seu Guardian Axe.')
				talkState = 0
		        end
		    else
			npcHandler:say('Desculpe, mas somente é possivel comprar um Guardian Axe por jogador.')
		    talkState = 0
			end
		else
		npcHandler:say('Desculpe mas você precisa ser um Elite Knight para comprar um Guardian Axe')
	    talkState = 0
		end
	else
	npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar seu Guardian Axe.')
	talkState = 0
	end
else
npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar seu Guardian Axe. Por favor volte quando tiver.')
talkState = 0
end

-- Clerical Hammer --
elseif msgcontains(msg, 'clerical') then
			npcHandler:say('Você quer trocar 15 dias de premium account por uma Clerical Hammer?')
			talkState = 3
		elseif msgcontains(msg, 'yes') and talkState == 3 then
			talkState = 0
if getPlayerPremiumDays(cid) >= 15 then
	if getPlayerLevel(cid) >= 100 then
		if getPlayerVocation(cid) == 8 then
 	        if getPlayerStorageValue(cid, 336) == -1 then
			    if doPlayerRemovePremiumDays(cid, 15) then
		        doSetItemSpecialDescription(doPlayerAddItem(cid,7410,1),'It is a clerical hammer forjed for '..getCreatureName(cid)..'. The staff longs for death')
			    setPlayerStorageValue(cid,336, 1)
				npcHandler:say('Aqui esta sua Clerical Hammer.')
				talkState = 0
			    end
			else
			npcHandler:say('Desculpe, mas somente é possivel comprar uma Clerical Hammer por jogador.')
			talkState = 0
			end
	    else
		npcHandler:say('Desculpe mas você precisa ser Elite Knight para comprar uma Clerical Hammer')
	    talkState = 0
	   end
    else
	npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar sua Clerical Hammer.')
	talkState = 0
	end
else
npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar Sua Clerical Hammer. Por favor volte quando tiver.')
talkState = 0
end
---Weapons Fim---

-- Wizard Sceptre --
elseif msgcontains(msg, 'wizard') then
			npcHandler:say('Você quer trocar 15 dias de premium account por uma Wizard Sceptre?')
			talkState = 4
		elseif msgcontains(msg, 'yes') and talkState == 4 then
			talkState = 0
if getPlayerPremiumDays(cid) >= 15 then
	if getPlayerLevel(cid) >= 100 then
		if getPlayerVocation(cid) == 5 then
	         if getPlayerStorageValue(cid, 335) == -1 then
		         if doPlayerRemovePremiumDays(cid, 15) then
		         doSetItemSpecialDescription(doPlayerAddItem(cid,7451,1),'It is a wizard sceptre forjed for '..getCreatureName(cid)..'. This wand gives divine power to powerful mages')
				 setPlayerStorageValue(cid,335,1)
		         npcHandler:say('Aqui está sua Wizard Sceptre.')
				 talkState = 0
				 end
			else
			npcHandler:say('Desculpe, mas somente é possivel comprar uma Wizard Sceptre por jogador.')
			talkState = 0
			end
	    else
		npcHandler:say('Desculpe mas você precisa ser um Master Sorcerer para comprar uma Wizard Sceptre')
	    talkState = 0
		end
	else
	npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar sua Wizard Sceptre.')
	talkState = 0
	end
else
npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar sua Wizard Sceptre. Por favor volte quando tiver.')
talkState = 0
end

-- Shaman Sceptre --
elseif msgcontains(msg, 'shaman') then
			npcHandler:say('Você quer trocar 15 dias de premium account por uma Shaman Sceptre?')
			talkState = 5
        elseif msgcontains(msg, 'yes') and talkState == 5 then
			talkState = 0
if getPlayerPremiumDays(cid) >= 15 then
	if getPlayerLevel(cid) >= 100 then
		if getPlayerVocation(cid) == 6 then
	        if getPlayerStorageValue(cid, 338) == -1 then
		        if doPlayerRemovePremiumDays(cid, 15) then
                doSetItemSpecialDescription(doPlayerAddItem(cid,7429,1),'It is a shaman sceptre forjed for '..getCreatureName(cid)..'. This wand gives divine power to powerful druids')
			    setPlayerStorageValue(cid,338,1)
				npcHandler:say('Aqui esta sua Shaman Sceptre.')
				talkState = 0
				end
			else
		    npcHandler:say('Desculpe, mas somente é possivel comprar uma Shaman Sceptre por jogador.')
			talkState = 0
			end
		else
		npcHandler:say('Desculpe mas você precisa ser um Elder Druid para comprar uma Shaman Sceptre')
	    talkState = 0
		end
	else
	npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar sua Shaman Sceptre.')
	talkState = 0
	end
else
npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar sua Shaman Sceptre. Por favor volte quando tiver.')
talkState = 0
end
---Wands Fim---


---Rings Inicio---
--------------------------------------------------------------------------------------------------- Berserk Ring------------------------------------------------------------------------------------------------
elseif msgcontains(msg, 'berserk') then
		    npcHandler:say('Você quer trocar 15 dias de premium account por um Berserk Ring?')
		    talkState = 6
		elseif msgcontains(msg, 'yes') and talkState == 6 then
			talkState = 0
if getPlayerPremiumDays(cid) >= 15 then
	if getPlayerLevel(cid) >= 100 then
	    if getPlayerStorageValue(cid, 337) == -1 then
		    if doPlayerRemovePremiumDays(cid, 15) then
			doSetItemSpecialDescription(doPlayerAddItem(cid,2166,1),'It is a berserk ring forjed for '..getCreatureName(cid)..'. This object increnses your all skills in ten points')
			setPlayerStorageValue(cid,337,1)
			npcHandler:say('Aqui esta seu Berserk Ring.')
			talkState = 0
		    end
		else
		npcHandler:say('Desculpe, mas somente é possivel comprar um Berserk Ring por jogador.')
		talkState = 0
		end
	else
	npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar seu Berserk Ring.')
	talkState = 0
	end
else
npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar seu Berserk Ring. Por favor volte quando tiver.')
talkState = 0
end
-------------------------------------------------------------------------------------------------- Stone Ring------------------------------------------------------------------------------------------------
elseif msgcontains(msg, 'stone') then
			npcHandler:say('Você quer trocar 15 dias de premium account por um Stone Ring?')
			talkState = 7
	elseif msgcontains(msg, 'yes') and talkState == 7 then
			talkState = 0
if getPlayerPremiumDays(cid) >= 15 then
	if getPlayerLevel(cid) >= 80 then
		if doPlayerRemovePremiumDays(cid, 15) then
		doSetItemSpecialDescription(doPlayerAddItem(cid,2213,1),'It is a stone ring forjed for '..getCreatureName(cid)..'. It absorb twenty seven percent of all attacks received')
		npcHandler:say('Aqui esta seu Stone Ring.')
		talkState = 0
		end
	else
	npcHandler:say('Desculpe, você precisa pegar level 80 para poder comprar um Stone Ring.')
	talkState = 0
	end
else
npcHandler:say('Desculpe, você não tem dias de premium account suficiente para compra um Stone Ring. Por favor volte quando tiver.')
talkState = 0
end
--Rings Fim---

--Shields Inicio---

--Fenix Shield--
elseif msgcontains(msg, 'fenix') then
		npcHandler:say('Você quer trocar 15 dias de premium account por um Fenix Shield?')
			talkState = 8
		elseif msgcontains(msg, 'yes') and talkState == 8 then
			talkState = 0
if getPlayerPremiumDays(cid) >= 15 then
	if getPlayerLevel(cid) >= 100 then
	    if getPlayerStorageValue(cid, 339) == -1 then
		    if doPlayerRemovePremiumDays(cid, 15) then
		    doSetItemSpecialDescription(doPlayerAddItem(cid,2538,1),'It is a fenix shield forjed for '..getCreatureName(cid)..'. The power of fenix absorb five percent of all attacks received.')
		    setPlayerStorageValue(cid,339,1)
			npcHandler:say('Aqui esta seu Fenix Shield')
		    talkState = 0
			end
		else
		npcHandler:say('Desculpe, mas somente é possivel comprar um Fenix Shield por jogador.')
		talkState = 0
		end
	else
	npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar um Fenix Shield.')
	talkState = 0
	end
else
npcHandler:say('Desculpe, você não tem dias de premium account suficiente para compra seu Fenix Shield. Por favor volte quando tiver.')
talkState = 0
end
--Shields Fim--


-- Ancients Boots --
elseif msgcontains(msg, 'ancient') then
			npcHandler:say('Você quer trocar 40 dias de premium account por uma Ancients Boots?')
			talkState = 9
		elseif msgcontains(msg, 'yes') and talkState == 9 then
			talkState = 0
if getPlayerPremiumDays(cid) >= 40 then
	if getPlayerLevel(cid) >= 120 then
		if getPlayerStorageValue(cid, 340) == -1 then
	         if doPlayerRemovePremiumDays(cid, 40) then
		     doSetItemSpecialDescription(doPlayerAddItem(cid,7891,1),'It is a ancients boots forjed for '..getCreatureName(cid)..'. This object increases their healing and add sixty points of speed')
		     setPlayerStorageValue(cid,340,1)
			 npcHandler:say('Aqui está sua Ancients Boots')
			 talkState = 0
			 end
		else
		npcHandler:say('Desculpe, mas somente é possivel comprar uma Ancients Boots por jogador.')
		talkState = 0
		end
	else
    npcHandler:say('Desculpe, você precisa pegar level 120 para poder comprar sua Ancients Boots.')
	talkState = 0
	end
else
npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar sua Ancients Boots. Por favor volte quando tiver.')
talkState = 0
end
--Botas Fim---
----------------------------------------------------------------------------------------------------Adeus-------------------------------------------------------------------------------------------------------------------------
elseif msgcontains(msg, 'no') and talkState >= 1 and talkState <= 9 then
			talkState = 0
			npcHandler:say('Ok! Quem sabe na próxima vez.')
		end
	return TRUE
end
keywordHandler:addKeyword({'weapons'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho mystican blade, guardian axe and clerical hammer por 15 dias de premium account. O que você precisa?'})
keywordHandler:addKeyword({'rings'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho stone ring e berserk ring por 15 dias de premmium account cada. O que você precisa'})
keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu vendo botas, wands, rings, weapons e shields. Do que você precisa?'})
keywordHandler:addKeyword({'shields'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho fenix shield por 15 dias de premium account. O que você precisa?'})
keywordHandler:addKeyword({'wands'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho shaman sceptre para elder druids e wizard sceptre para master sorcerers por 15 dias de premium account cada. O que você precisa?'})
keywordHandler:addKeyword({'botas'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho ancients boots por 40 dias de premium account. O que você precisa?'})
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
well here i tabbed it in the way i find it to be correct so now its a lot easier to read

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return false
	end
-- Mystican Blade --
	if msgcontains(msg, 'mystican') then
		npcHandler:say('Você quer trocar 15 dias de premium account por uma Mystican Blade?')
		talkState = 1
	elseif msgcontains(msg, 'yes') and talkState == 1 then
		talkState = 0
		if getPlayerPremiumDays(cid) >= 15 then
			if getPlayerLevel(cid) >= 100 then
				if getPlayerVocation(cid) == 8 then
					if getPlayerStorageValue(cid, 333) == -1 then
						if doPlayerRemovePremiumDays(cid, 15) then
							doSetItemSpecialDescription(doPlayerAddItem(cid,7385, 1),'It is a mystican blade forjed for '..getCreatureName(cid)..'. The blade of the sword can defeat his opponent in one blow.')
							setPlayerStorageValue(cid,333, 1)
							npcHandler:say('Aqui esta sua Mystican Blade.')
							talkState = 0
						end
					else
						npcHandler:say('Desculpe, mas somente é possivel comprar uma Mystican Blade por jogador.')
						[COLOR="Red"]talkState = 0[/COLOR]
					end
				else
					npcHandler:say('Desculpe, você precisa ser Elite Knight para comprar uma Mystican Blade')
					[COLOR="Red"]talkState = 0[/COLOR]
				end
			else
				npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar sua Mystican Blade.')
				[COLOR="Red"]talkState = 0[/COLOR]
			end
		else
			npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar sua Mystican Blade. Por favor volte quando tiver.')
			[COLOR="Red"]talkState = 0[/COLOR]
		end

-- Guardian Axe --
elseif msgcontains(msg, 'guardian') then
			npcHandler:say('Você quer trocar 15 dias de premium account por um Guardian Axe?')
			talkState = 2
		elseif msgcontains(msg, 'yes') and talkState == 2 then
			talkState = 0
if getPlayerPremiumDays(cid) >= 15 then
	if getPlayerLevel(cid) >= 100 then
		if getPlayerVocation(cid) == 8 then
	        if getPlayerStorageValue(cid, 334) == -1 then
			    if doPlayerRemovePremiumDays(cid, 15) then
		        doSetItemSpecialDescription(doPlayerAddItem(cid,7436, 1),'It is a guardian axe forjed for '..getCreatureName(cid)..'. You feel the power of this axe.')
	            setPlayerStorageValue(cid,334, 1)
				npcHandler:say('Aqui esta seu Guardian Axe.')
				talkState = 0
		        end
		    else
			npcHandler:say('Desculpe, mas somente é possivel comprar um Guardian Axe por jogador.')
		    talkState = 0
			end
		else
		npcHandler:say('Desculpe mas você precisa ser um Elite Knight para comprar um Guardian Axe')
	    talkState = 0
		end
	else
	npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar seu Guardian Axe.')
	talkState = 0
	end
else
npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar seu Guardian Axe. Por favor volte quando tiver.')
talkState = 0
end

-- Clerical Hammer --
	elseif msgcontains(msg, 'clerical') then
		npcHandler:say('Você quer trocar 15 dias de premium account por uma Clerical Hammer?')
		talkState = 3
	elseif msgcontains(msg, 'yes') and talkState == 3 then
		talkState = 0
		if getPlayerPremiumDays(cid) >= 15 then
			if getPlayerLevel(cid) >= 100 then
				if getPlayerVocation(cid) == 8 then
					if getPlayerStorageValue(cid, 336) == -1 then
						if doPlayerRemovePremiumDays(cid, 15) then
							doSetItemSpecialDescription(doPlayerAddItem(cid,7410,1),'It is a clerical hammer forjed for '..getCreatureName(cid)..'. The staff longs for death')
							setPlayerStorageValue(cid,336, 1)
							npcHandler:say('Aqui esta sua Clerical Hammer.')
							talkState = 0
						end
					else
						npcHandler:say('Desculpe, mas somente é possivel comprar uma Clerical Hammer por jogador.')
						talkState = 0
					end
				else
					npcHandler:say('Desculpe mas você precisa ser Elite Knight para comprar uma Clerical Hammer')
					talkState = 0
				end
			else
				npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar sua Clerical Hammer.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar Sua Clerical Hammer. Por favor volte quando tiver.')
			talkState = 0
		end
---Weapons Fim---

-- Wizard Sceptre --
	elseif msgcontains(msg, 'wizard') then
		npcHandler:say('Você quer trocar 15 dias de premium account por uma Wizard Sceptre?')
		talkState = 4
	elseif msgcontains(msg, 'yes') and talkState == 4 then
		talkState = 0
		if getPlayerPremiumDays(cid) >= 15 then
			if getPlayerLevel(cid) >= 100 then
				if getPlayerVocation(cid) == 5 then
					if getPlayerStorageValue(cid, 335) == -1 then
						if doPlayerRemovePremiumDays(cid, 15) then
							doSetItemSpecialDescription(doPlayerAddItem(cid,7451,1),'It is a wizard sceptre forjed for '..getCreatureName(cid)..'. This wand gives divine power to powerful mages')
							setPlayerStorageValue(cid,335,1)
							npcHandler:say('Aqui está sua Wizard Sceptre.')
							talkState = 0
						end
					else
						npcHandler:say('Desculpe, mas somente é possivel comprar uma Wizard Sceptre por jogador.')
						talkState = 0
					end
				else
					npcHandler:say('Desculpe mas você precisa ser um Master Sorcerer para comprar uma Wizard Sceptre')
					talkState = 0
				end
			else
				npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar sua Wizard Sceptre.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar sua Wizard Sceptre. Por favor volte quando tiver.')
			talkState = 0
		end

-- Shaman Sceptre --
	elseif msgcontains(msg, 'shaman') then
		npcHandler:say('Você quer trocar 15 dias de premium account por uma Shaman Sceptre?')
		talkState = 5
    elseif msgcontains(msg, 'yes') and talkState == 5 then
		talkState = 0
		if getPlayerPremiumDays(cid) >= 15 then
			if getPlayerLevel(cid) >= 100 then
				if getPlayerVocation(cid) == 6 then
					if getPlayerStorageValue(cid, 338) == -1 then
						if doPlayerRemovePremiumDays(cid, 15) then
							doSetItemSpecialDescription(doPlayerAddItem(cid,7429,1),'It is a shaman sceptre forjed for '..getCreatureName(cid)..'. This wand gives divine power to powerful druids')
							setPlayerStorageValue(cid,338,1)
							npcHandler:say('Aqui esta sua Shaman Sceptre.')
							talkState = 0
						end
					else
						npcHandler:say('Desculpe, mas somente é possivel comprar uma Shaman Sceptre por jogador.')
						talkState = 0
					end
				else
					npcHandler:say('Desculpe mas você precisa ser um Elder Druid para comprar uma Shaman Sceptre')
					talkState = 0
				end
			else
				npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar sua Shaman Sceptre.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar sua Shaman Sceptre. Por favor volte quando tiver.')
			talkState = 0
		end
---Wands Fim---


---Rings Inicio---


--- Berserk Ring --
	elseif msgcontains(msg, 'berserk') then
		npcHandler:say('Você quer trocar 15 dias de premium account por um Berserk Ring?')
		talkState = 6
	elseif msgcontains(msg, 'yes') and talkState == 6 then
		talkState = 0
		if getPlayerPremiumDays(cid) >= 15 then
			if getPlayerLevel(cid) >= 100 then
				if getPlayerStorageValue(cid, 337) == -1 then
					if doPlayerRemovePremiumDays(cid, 15) then
						doSetItemSpecialDescription(doPlayerAddItem(cid,2166,1),'It is a berserk ring forjed for '..getCreatureName(cid)..'. This object increnses your all skills in ten points')
						setPlayerStorageValue(cid,337,1)
						npcHandler:say('Aqui esta seu Berserk Ring.')
						talkState = 0
					end
				else
					npcHandler:say('Desculpe, mas somente é possivel comprar um Berserk Ring por jogador.')
					talkState = 0
				end
			else
				npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar seu Berserk Ring.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar seu Berserk Ring. Por favor volte quando tiver.')
			talkState = 0
		end
-- Stone Ring--
elseif msgcontains(msg, 'stone') then
			npcHandler:say('Você quer trocar 15 dias de premium account por um Stone Ring?')
			talkState = 7
	elseif msgcontains(msg, 'yes') and talkState == 7 then
			talkState = 0
if getPlayerPremiumDays(cid) >= 15 then
	if getPlayerLevel(cid) >= 80 then
		if doPlayerRemovePremiumDays(cid, 15) then
		doSetItemSpecialDescription(doPlayerAddItem(cid,2213,1),'It is a stone ring forjed for '..getCreatureName(cid)..'. It absorb twenty seven percent of all attacks received')
		npcHandler:say('Aqui esta seu Stone Ring.')
		talkState = 0
		end
	else
	npcHandler:say('Desculpe, você precisa pegar level 80 para poder comprar um Stone Ring.')
	talkState = 0
	end
else
npcHandler:say('Desculpe, você não tem dias de premium account suficiente para compra um Stone Ring. Por favor volte quando tiver.')
talkState = 0
end
--Rings Fim ---

--Shields Inicio ---

--Fenix Shield --
	elseif msgcontains(msg, 'fenix') then
		npcHandler:say('Você quer trocar 15 dias de premium account por um Fenix Shield?')
		talkState = 8
	elseif msgcontains(msg, 'yes') and talkState == 8 then
			talkState = 0
			if getPlayerPremiumDays(cid) >= 15 then
				if getPlayerLevel(cid) >= 100 then
					if getPlayerStorageValue(cid, 339) == -1 then
						if doPlayerRemovePremiumDays(cid, 15) then
							doSetItemSpecialDescription(doPlayerAddItem(cid,2538,1),'It is a fenix shield forjed for '..getCreatureName(cid)..'. The power of fenix absorb five percent of all attacks received.')
							setPlayerStorageValue(cid,339,1)
							npcHandler:say('Aqui esta seu Fenix Shield')
							talkState = 0
						end
					else
						npcHandler:say('Desculpe, mas somente é possivel comprar um Fenix Shield por jogador.')
						talkState = 0
					end
				else
					npcHandler:say('Desculpe, você precisa pegar level 100 para poder comprar um Fenix Shield.')
					talkState = 0
				end
			else
				npcHandler:say('Desculpe, você não tem dias de premium account suficiente para compra seu Fenix Shield. Por favor volte quando tiver.')
				talkState = 0
			end
--Shields Fim--


-- Ancients Boots --
	elseif msgcontains(msg, 'ancient') then
		npcHandler:say('Você quer trocar 40 dias de premium account por uma Ancients Boots?')
		talkState = 9
	elseif msgcontains(msg, 'yes') and talkState == 9 then
		talkState = 0
		if getPlayerPremiumDays(cid) >= 40 then
			if getPlayerLevel(cid) >= 120 then
				if getPlayerStorageValue(cid, 340) == -1 then
					if doPlayerRemovePremiumDays(cid, 40) then
						doSetItemSpecialDescription(doPlayerAddItem(cid,7891,1),'It is a ancients boots forjed for '..getCreatureName(cid)..'. This object increases their healing and add sixty points of speed')
						setPlayerStorageValue(cid,340,1)
						npcHandler:say('Aqui está sua Ancients Boots')
						talkState = 0
					end
				else
					npcHandler:say('Desculpe, mas somente é possivel comprar uma Ancients Boots por jogador.')
					talkState = 0
				end
			else
				npcHandler:say('Desculpe, você precisa pegar level 120 para poder comprar sua Ancients Boots.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, você não tem dias de premium account suficiente para comprar sua Ancients Boots. Por favor volte quando tiver.')
			talkState = 0
		end
--Botas Fim---

----------------------------------------------------------------------------------------------------Adeus-------------------------------------------------------------------------------------------------------------------------
elseif msgcontains(msg, 'no') and talkState >= 1 and talkState <= 9 then
			talkState = 0
			npcHandler:say('Ok! Quem sabe na próxima vez.')
		end
	return TRUE
end
keywordHandler:addKeyword({'weapons'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho mystican blade, guardian axe and clerical hammer por 15 dias de premium account. O que você precisa?'})
keywordHandler:addKeyword({'rings'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho stone ring e berserk ring por 15 dias de premmium account cada. O que você precisa'})
keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu vendo botas, wands, rings, weapons e shields. Do que você precisa?'})
keywordHandler:addKeyword({'shields'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho fenix shield por 15 dias de premium account. O que você precisa?'})
keywordHandler:addKeyword({'wands'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho shaman sceptre para elder druids e wizard sceptre para master sorcerers por 15 dias de premium account cada. O que você precisa?'})
keywordHandler:addKeyword({'botas'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho ancients boots por 40 dias de premium account. O que você precisa?'})
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

that is better tabbing and the red talk states i think u can remove repeat removing them all the way down the script b/c its already taken care of here

Code:
	elseif msgcontains(msg, 'yes') and talkState == 3 then
		talkState = 0

hope u understand what i mean. and i'm not rlly sure what your asking so i cant help to much besides this
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return false
	end
-- Mystican Blade --
	if msgcontains(msg, 'mystican') then
		npcHandler:say('Voce quer trocar 15 dias de premium account por uma Mystican Blade?')
		talkState = 1
	elseif msgcontains(msg, 'yes') and talkState == 1 then
		if getPlayerPremiumDays(cid) >= 15 then
			if getPlayerLevel(cid) >= 100 then
				if getPlayerVocation(cid) == 8 then
			        if getPlayerStorageValue(cid, 333) == -1 then
					    doPlayerRemovePremiumDays(cid, 15)
					    doSetItemSpecialDescription(doPlayerAddItem(cid,7385, 1),'It is a mystican blade forged for '..getCreatureName(cid)..'. The blade of the sword can defeat his opponent in one blow.')
						setPlayerStorageValue(cid,333, 1)
						npcHandler:say('Aqui esta sua Mystican Blade.')
					    talkState = 0
				    else
						npcHandler:say('Desculpe, mas somente é possivel comprar uma Mystican Blade por jogador.')
						talkState = 0
				    end
				else
					npcHandler:say('Desculpe, voce precisa ser Elite Knight para comprar uma Mystican Blade')
					talkState = 0
			    end
		    else
				npcHandler:say('Desculpe, voce precisa pegar level 100 para poder comprar sua Mystican Blade.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, voce nao tem dias de premium account suficiente para comprar sua Mystican Blade. Por favor volte quando tiver.')
			talkState = 0
		end

	-- Guardian Axe --
	elseif msgcontains(msg, 'guardian') then
		npcHandler:say('Voce quer trocar 15 dias de premium account por um Guardian Axe?')
		talkState = 2
	elseif msgcontains(msg, 'yes') and talkState == 2 then
		if getPlayerPremiumDays(cid) >= 15 then
			if getPlayerLevel(cid) >= 100 then
				if getPlayerVocation(cid) == 8 then
			        if getPlayerStorageValue(cid, 334) == -1 then
					    doPlayerRemovePremiumDays(cid, 15)
					    doSetItemSpecialDescription(doPlayerAddItem(cid,7436, 1),'It is a guardian axe forjed for '..getCreatureName(cid)..'. You feel the power of this axe.')
				        setPlayerStorageValue(cid,334, 1)
						npcHandler:say('Aqui esta seu Guardian Axe.')
						talkState = 0
				    else
						npcHandler:say('Desculpe, mas somente é possivel comprar um Guardian Axe por jogador.')
					    talkState = 0
					end
				else
					npcHandler:say('Desculpe mas voce precisa ser um Elite Knight para comprar um Guardian Axe')
				    talkState = 0
				end
			else
				npcHandler:say('Desculpe, voce precisa pegar level 100 para poder comprar seu Guardian Axe.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, voce nao tem dias de premium account suficiente para comprar seu Guardian Axe. Por favor volte quando tiver.')
			talkState = 0
		end

	-- Clerical Hammer --
	elseif msgcontains(msg, 'clerical') then
		npcHandler:say('Voce quer trocar 15 dias de premium account por uma Clerical Hammer?')
		talkState = 3
	elseif msgcontains(msg, 'yes') and talkState == 3 then
		if getPlayerPremiumDays(cid) >= 15 then
			if getPlayerLevel(cid) >= 100 then
				if getPlayerVocation(cid) == 8 then
		 	        if getPlayerStorageValue(cid, 336) == -1 then
					    doPlayerRemovePremiumDays(cid, 15)
				        doSetItemSpecialDescription(doPlayerAddItem(cid,7410,1),'It is a clerical hammer forjed for '..getCreatureName(cid)..'. The staff longs for death')
					    setPlayerStorageValue(cid,336, 1)
						npcHandler:say('Aqui esta sua Clerical Hammer.')
						talkState = 0
					else
						npcHandler:say('Desculpe, mas somente é possivel comprar uma Clerical Hammer por jogador.')
						talkState = 0
					end
			    else
					npcHandler:say('Desculpe mas voce precisa ser Elite Knight para comprar uma Clerical Hammer')
				    talkState = 0
			   end
		    else
				npcHandler:say('Desculpe, voce precisa pegar level 100 para poder comprar sua Clerical Hammer.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, voce nao tem dias de premium account suficiente para comprar Sua Clerical Hammer. Por favor volte quando tiver.')
			talkState = 0
		end

	-- Wizard Sceptre --
	elseif msgcontains(msg, 'wizard') then
		npcHandler:say('Voce quer trocar 15 dias de premium account por uma Wizard Sceptre?')
		talkState = 4
	elseif msgcontains(msg, 'yes') and talkState == 4 then
		if getPlayerPremiumDays(cid) >= 15 then
			if getPlayerLevel(cid) >= 100 then
				if getPlayerVocation(cid) == 5 then
			         if getPlayerStorageValue(cid, 335) == -1 then
				        doPlayerRemovePremiumDays(cid, 15)
				        doSetItemSpecialDescription(doPlayerAddItem(cid,7451,1),'It is a wizard sceptre forjed for '..getCreatureName(cid)..'. This wand gives divine power to powerful mages')
						setPlayerStorageValue(cid,335,1)
				        npcHandler:say('Aqui está sua Wizard Sceptre.')
						talkState = 0
					else
						npcHandler:say('Desculpe, mas somente é possivel comprar uma Wizard Sceptre por jogador.')
						talkState = 0
					end
			    else
					npcHandler:say('Desculpe mas voce precisa ser um Master Sorcerer para comprar uma Wizard Sceptre')
				    talkState = 0
				end
			else
				npcHandler:say('Desculpe, voce precisa pegar level 100 para poder comprar sua Wizard Sceptre.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, voce nao tem dias de premium account suficiente para comprar sua Wizard Sceptre. Por favor volte quando tiver.')
			talkState = 0
		end
	-- Shaman Sceptre --
	elseif msgcontains(msg, 'shaman') then
		npcHandler:say('Voce quer trocar 15 dias de premium account por uma Shaman Sceptre?')
		talkState = 5
	elseif msgcontains(msg, 'yes') and talkState == 5 then
		if getPlayerPremiumDays(cid) >= 15 then
			if getPlayerLevel(cid) >= 100 then
				if getPlayerVocation(cid) == 6 then
			        if getPlayerStorageValue(cid, 338) == -1 then
						doPlayerRemovePremiumDays(cid, 15)
		                doSetItemSpecialDescription(doPlayerAddItem(cid,7429,1),'It is a shaman sceptre forjed for '..getCreatureName(cid)..'. This wand gives divine power to powerful druids')
					    setPlayerStorageValue(cid,338,1)
						npcHandler:say('Aqui esta sua Shaman Sceptre.')
						talkState = 0
					else
					    npcHandler:say('Desculpe, mas somente é possivel comprar uma Shaman Sceptre por jogador.')
						talkState = 0
					end
				else
					npcHandler:say('Desculpe mas voce precisa ser um Elder Druid para comprar uma Shaman Sceptre')
				    talkState = 0
				end
			else
				npcHandler:say('Desculpe, voce precisa pegar level 100 para poder comprar sua Shaman Sceptre.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, voce nao tem dias de premium account suficiente para comprar sua Shaman Sceptre. Por favor volte quando tiver.')
			talkState = 0
		end

	---Rings Inicio---
	--------------------------------------------------------------------------------------------------- Berserk Ring------------------------------------------------------------------------------------------------
	elseif msgcontains(msg, 'berserk') then
		npcHandler:say('Voce quer trocar 15 dias de premium account por um Berserk Ring?')
		talkState = 6
	elseif msgcontains(msg, 'yes') and talkState == 6 then
		if getPlayerPremiumDays(cid) >= 15 then
			if getPlayerLevel(cid) >= 100 then
			    if getPlayerStorageValue(cid, 337) == -1 then
				    doPlayerRemovePremiumDays(cid, 15)
					doSetItemSpecialDescription(doPlayerAddItem(cid,2166,1),'It is a berserk ring forjed for '..getCreatureName(cid)..'. This object increnses your all skills in ten points')
					setPlayerStorageValue(cid,337,1)
					npcHandler:say('Aqui esta seu Berserk Ring.')
					talkState = 0
				else
					npcHandler:say('Desculpe, mas somente é possivel comprar um Berserk Ring por jogador.')
					talkState = 0
				end
			else
				npcHandler:say('Desculpe, voce precisa pegar level 100 para poder comprar seu Berserk Ring.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, voce nao tem dias de premium account suficiente para comprar seu Berserk Ring. Por favor volte quando tiver.')
			talkState = 0
		end
	-------------------------------------------------------------------------------------------------- Stone Ring------------------------------------------------------------------------------------------------
	elseif msgcontains(msg, 'stone') then
		npcHandler:say('Voce quer trocar 15 dias de premium account por um Stone Ring?')
		talkState = 7
	elseif msgcontains(msg, 'yes') and talkState == 7 then
		if getPlayerPremiumDays(cid) >= 15 then
			if getPlayerLevel(cid) >= 80 then
				doPlayerRemovePremiumDays(cid, 15)
				doSetItemSpecialDescription(doPlayerAddItem(cid,2213,1),'It is a stone ring forjed for '..getCreatureName(cid)..'. It absorb twenty seven percent of all attacks received')
				npcHandler:say('Aqui esta seu Stone Ring.')
				talkState = 0
			else
				npcHandler:say('Desculpe, voce precisa pegar level 80 para poder comprar um Stone Ring.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, voce nao tem dias de premium account suficiente para compra um Stone Ring. Por favor volte quando tiver.')
			talkState = 0
		end
	--Rings Fim---

	--Shields Inicio---

	--Fenix Shield--
	elseif msgcontains(msg, 'fenix') then
		npcHandler:say('Voce quer trocar 15 dias de premium account por um Fenix Shield?')
		talkState = 8
	elseif msgcontains(msg, 'yes') and talkState == 8 then
		if getPlayerPremiumDays(cid) >= 15 then
			if getPlayerLevel(cid) >= 100 then
			    if getPlayerStorageValue(cid, 339) == -1 then
				    doPlayerRemovePremiumDays(cid, 15)
				    doSetItemSpecialDescription(doPlayerAddItem(cid,2538,1),'It is a fenix shield forjed for '..getCreatureName(cid)..'. The power of fenix absorb five percent of all attacks received.')
				    setPlayerStorageValue(cid,339,1)
					npcHandler:say('Aqui esta seu Fenix Shield')
				    talkState = 0
				else
					npcHandler:say('Desculpe, mas somente é possivel comprar um Fenix Shield por jogador.')
					talkState = 0
				end
			else
				npcHandler:say('Desculpe, voce precisa pegar level 100 para poder comprar um Fenix Shield.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, voce nao tem dias de premium account suficiente para compra seu Fenix Shield. Por favor volte quando tiver.')
			talkState = 0
		end
	--Shields Fim--

	-- Ancients Boots --
	elseif msgcontains(msg, 'ancient') then
		npcHandler:say('Voce quer trocar 40 dias de premium account por uma Ancients Boots?')
		talkState = 9
	elseif msgcontains(msg, 'yes') and talkState == 9 then
		if getPlayerPremiumDays(cid) >= 40 then
			if getPlayerLevel(cid) >= 120 then
				if getPlayerStorageValue(cid, 340) == -1 then
			         doPlayerRemovePremiumDays(cid, 40)
				     doSetItemSpecialDescription(doPlayerAddItem(cid,7891,1),'It is a ancients boots forjed for '..getCreatureName(cid)..'. This object increases their healing and add sixty points of speed')
				     setPlayerStorageValue(cid,340,1)
					 npcHandler:say('Aqui está sua Ancients Boots')
					 talkState = 0
				else
					npcHandler:say('Desculpe, mas somente é possivel comprar uma Ancients Boots por jogador.')
					talkState = 0
				end
			else
			    npcHandler:say('Desculpe, voce precisa pegar level 120 para poder comprar sua Ancients Boots.')
				talkState = 0
			end
		else
			npcHandler:say('Desculpe, voce nao tem dias de premium account suficiente para comprar sua Ancients Boots. Por favor volte quando tiver.')
			talkState = 0
		end
	--Botas Fim---
	----------------------------------------------------------------------------------------------------Adeus-------------------------------------------------------------------------------------------------------------------------
	elseif msgcontains(msg, 'no') and talkState >= 1 and talkState <= 9 then
		talkState = 0
		npcHandler:say('Ok! Quem sabe na próxima vez.')
	end
	return TRUE
end
keywordHandler:addKeyword({'weapons'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho mystican blade, guardian axe and clerical hammer por 15 dias de premium account. O que voce precisa?'})
keywordHandler:addKeyword({'rings'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho stone ring e berserk ring por 15 dias de premmium account cada. O que voce precisa'})
keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu vendo botas, wands, rings, weapons e shields. Do que voce precisa?'})
keywordHandler:addKeyword({'shields'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho fenix shield por 15 dias de premium account. O que voce precisa?'})
keywordHandler:addKeyword({'wands'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho shaman sceptre para elder druids e wizard sceptre para master sorcerers por 15 dias de premium account cada. O que voce precisa?'})
keywordHandler:addKeyword({'botas'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu tenho ancients boots por 40 dias de premium account. O que voce precisa?'})
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I guess I didnt understand correctly, but at least I tabbed this shit properly and fixed thing with removing premium days.

If it is giving wrong items check the IDs in the script, you can try mine, maybe Ive fixed it :p
 
Back
Top