Ir para conteúdo

Npc Blue Legs Quest.


MUTAN0

Posts Recomendados

:great: Aew gente.

Eu montei um NPC, com ajuda dum outro que peguei dum forum gringo.

O NPC faz como o Sweaty Cyclops, monta as peças do colar e entrega o colar pronto depois de 24 horas (horario real).

O NPC no entanto, também está com a função de vender AOL. E esse NPC só ta vendendo AOL, e quando eu digo alguma palavra do script, ele não responde nada, então queria que alguém visse o que tem de errado no script :neutral:

 

NPC:

<?xml version="1.0" encoding="UTF-8"?>

<npc name="Dufi" script="data/npc/scripts/blue_legs.lua" walkinterval="2000" floorchange="0">

<health now="100" max="100"/>

<look type="130" head="0" body="93" legs="0" feet="93" addons="1"/>

<parameters>

<parameter key="module_shop" value="1" />

<parameter key="message_greet" value="Hello |PLAYERNAME|. Say {trade} to buy an amulet of loss, or {fix} is behind the koshei's ancient amulet." />

<parameter key="shop_buyable" value="amulet of loss,2173,50000" />

</parameters>

</npc>

 

Script (blue_legs.LUA):

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)

-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.

if(npcHandler.focus ~= cid) then

return false

end

 

-- use the real conversation? (true/false)

real = false

 

if real == true then

tradeMsg = 'I can fix all the four pieces of the broken {amulet} into one!'

fourpobaMsg = 'Do you want me to fix all the four pieces of that broken amulet?'

hasNoMsg = 'You need all four piece of the broken amulet to get all, or I can\'t fix it!'

noMsg = 'I have no time, I\'m a busy man, LEAVE!'

else

tradeMsg = 'I can fix all the four pieces of the broken {amulet} into one!'

fourpobaMsg = 'Do you want me to fix all the four pieces of that broken amulet?'

hasNoMsg = 'You need all four piece of the broken amulet to get all, or I can\'t fix it!'

noMsg = 'I have no time, I\'m a busy man, LEAVE!'

end

if msgcontains(msg, 'fix') then

selfSay(tradeMsg, cid)

elseif msgcontains(msg, 'change') or msgcontains(msg, 'piece') or msgcontains(msg, 'four') or msgcontains(msg, 'amulet') then

selfSay(fourpobaMsg ,cid)

talk_state = 1

------------------------------------------------ confirm yes ------------------------------------------------

elseif msgcontains(msg, 'yes') and talk_state == 1 then

if getPlayerStorageValue(cid,3218) == -1 then

if getPlayerItemCount(cid,8262) == 1 and getPlayerItemCount(cid,8263) == 1 and getPlayerItemCount(cid,8264) == 1 and getPlayerItemCount(cid,8265) == 1 and getPlayerMoney(cid) == 5000 then

if doPlayerTakeItem(cid,8262,1) == 0 and doPlayerTakeItem(cid,8263,1) == 0 and doPlayerTakeItem(cid,8264,1) == 0 and doPlayerTakeItem(cid,8265,1) == 0 and doPlayerRemoveMoney(cid, 5000) == 0 then

params = {[1]=cid}

setPlayerStorageValue(cid,3218, 0)

addEvent(recompensa, 86400000, params)

selfSay('Here Go back 24 hours to get her necklace.', cid)

end

else

selfSay(hasNoMsg, cid)

end

elseif getPlayerStorageValue(cid,3218) == 0 then

selfSay('Wait until your paste is ready, is a delicate work.', cid)

elseif getPlayerStorageValue(cid,3218) == 1 then

doPlayerAddItem(cid,8266,1)

selfSay('Take your necklace, it was hard but it was perfect.', cid)

end

talk_state = 0

 

------------------------------------------------ confirm no ------------------------------------------------

elseif msgcontains(msg, 'no') and (talk_state == 1) then

selfSay(noMsg, cid)

talk_state = 0

end

-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

function recompensa(params)

cid = params[1]

setPlayerStorageValue(cid,3218, 1)

end

 

Abraços, ajude-me please :tongue2:

Link para o comentário
Compartilhar em outros sites

vc deve ter percebido que eu não gosto muito de npc's em modo CreatureSayCallback né =)

então vai aí minha sugestão

 

local keywords {'change','piece','four','amulet'}

local phrases = {
tradeMsg = 'I can fix all the four pieces of the broken {amulet} into one!',
fourpobaMsg = 'Do you want me to fix all the four pieces of that broken amulet?',
hasNoMsg = 'You need all four pieces of the broken amulet to get all, or I can\'t fix it!',
noMsg = 'I have no time, I\'m a busy man, LEAVE!',
startWorking = 'Here we go! Come back in 24 hours to get your necklace.',
working = 'Wait until your paste is ready, is a delicate work.',
done = 'Take your necklace, it was hard but it was perfect.',
}

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

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

npcHandler:addKeyword({'fix'}, StdModule.say, {npcHandler=npcHandler,onlyFocus=true,text=phrases.tradeMsg})
local node = ''
for i=1,#keywords do node = npcHandler.addKeyword({keywords[i]},StdModule.say,
  {npcHandler=npcHandler,onlyFocus=true,text=phrases.fourpobaMsg})
  node:addChildKeyword({'yes'},npcActions,{})
  node:addChildKeyword({'no'},StdModule.say,
  {npcHandler=npcHandler,onlyFocus=true,text=phrases.noMsg,reset=true})
end

function npcActions()
  if getPlayerStorageValue(cid,3218) == nil then
  local parts = 0
  for i=8262,8265 do if getPlayerItemCount(cid,i,1) then parts = parts + 1 end end
  if parts == 4 then
	 for i=8262,8265 do getPlayerTakeItem(cid,i,1) end
	 setPlayerStorageValue(cid,3218,os.time()+24*60*60)
	 selfSay(phrases.startWorking,cid)
  else selfSay(phrases.hasNoMsg,cid) end
  elseif getPlayerStorageValue(cid,3218) < os.time() then selfSay(phrases.working,cid)
  else
  selfSay(phrases.done,cid)
  doPlayerAddItem(cid,8266,1)
  end
  npcHandler:resetNpc()
end

npcHandler:addModule(FocusModule:new())

 

se não der certo, ou preferir manter o seu, o que eu ACHO que esteja causando os erros são os seguintes pontos:

 

<?xml version="1.0" encoding="UTF-8"?>

<npc name="Dufi" script="data/npc/scripts/blue_legs.lua" walkinterval="2000" floorchange="0">

<health now="100" max="100"/>

<look type="130" head="0" body="93" legs="0" feet="93" addons="1"/>

<parameters>

<parameter key="module_shop" value="1" />

<parameter key="message_greet" value="Hello |PLAYERNAME|. Say {trade} to buy an amulet of loss, or {fix} is behind the koshei's ancient amulet." />

<parameter key="shop_buyable" value="amulet of loss,2173,50000" />

</parameters>

</npc>

 

apague TODO o trecho em negrito

 

 

...if(npcHandler.focus ~= cid) then

return false

end

 

-- use the real conversation? (true/false)

real = false

 

if real == true then

tradeMsg = 'I can fix all the four pieces of the broken {amulet} into one!'...

 

mude para true

 

boa sorte.

 

 

Outro ponto que é interessante ressaltar, é a contagem da criação do amuleto, armazenada em um evento

addEvent(recompensa, 86400000, params)

 

 

caso seu server caia, todos que estiverem com amuleto em espera, perderão os itens entregues ao npc, e não terão dirieto a receber seu amuleto de volta

 

recomendo que faça o storage do tempo em banco de dados substituindo addEvent(recompensa, 86400000, params) por setPlayerStorageValue(cid,storageId,os.time()+24*60*60)

 

e a checagem da seguinte maneira

 

não falou com o npc

if (getPlayerStorageValue(cid,storage) == -1) then ...

 

amuleto em espera

if (getPlayerStorageValue(cid,storage) > os.time()) then ...

 

amuleto pronto

if (getPlayerStorageValue(cid,storage) <= os.time()) then ...
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...