Kayan
Active Member
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())