Ir para conteúdo
  • 0

Error Com Script De Npc


Pergunta

Ae galera estou com um erro nesse scripts, quando eu falo

 

"chicken feathers"

"yes"

 

ou quando eu falo yes depois dos addons tambem da o mesmo error

 

Da esse erro no executor.

 

data/npc/script/citizenaddons.lu:8 in function data/npc/script/citizenaddons.lu:8>

data/npc/script/citizenaddons.lu:21 in function callback

data/npc/script/citizenaddons.lu:390 function on creaturesay

 

 

Aqui vai o script:

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

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, 'chicken feather')) then 
selfSay('Voc\ê me trouxe 100 chickens feathers?', cid) 
talkState[talkUser] = 1 
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if getPlayerItemCount(cid,5890) >= 100 then
if(doPlayerRemoveItem(cid, 5890,100) == true) then  
selfSay('Obrigado! Tome aqui sua big feather.', cid) 
setPlayerStorageValue(cid, 2366,1) 
talkState[talkUser] = 0 
end
else
selfSay('Voc\ê n\ão tem 100 chickens feathers.', cid) 
end
end
end

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


npcHandler:setMessage(MESSAGE_GREET, "Ola |PLAYERNAME|. Esta aqui pela {big} {feather}, ou pelos {addons}?")

function playerBuyAddonNPC(cid, message, keywords, parameters, node)
   if(not npcHandler:isFocused(cid)) then
       return false
   end
   if (parameters.confirm ~= true) and (parameters.decline ~= true) then
       if(getPlayerPremiumDays(cid) == 0) and (parameters.premium == true) then
           npcHandler:say('Desculpe, mas este addon e apenas para jogadores premium!', cid)
           npcHandler:resetNpc()
           return true
       end
       if (getPlayerStorageValue(cid, parameters.storageID) ~= -1) then
           npcHandler:say('Voce ja tem esse addon!', cid)
           npcHandler:resetNpc()
           return true
       end
       local itemsTable = parameters.items
       local items_list = ''
       if table.maxn(itemsTable) > 0 then
           for i = 1, table.maxn(itemsTable) do
               local item = itemsTable[i]
               items_list = items_list .. item[2] .. ' ' .. getItemNameById(item[1])
               if i ~= table.maxn(itemsTable) then
                   items_list = items_list .. ', '
               end
           end
       end
       local text = ''
       if (parameters.cost > 0) and table.maxn(parameters.items) then
           text = items_list .. ' and ' .. parameters.cost .. ' gp'
       elseif (parameters.cost > 0) then
           text = parameters.cost .. ' gp'
       elseif table.maxn(parameters.items) then
           text = items_list
       end
       npcHandler:say('Trouxe os itens para este addon?', cid)
       return true
   elseif (parameters.confirm == true) then
       local addonNode = node:getParent()
       local addoninfo = addonNode:getParameters()
       local items_number = 0
       if table.maxn(addoninfo.items) > 0 then
           for i = 1, table.maxn(addoninfo.items) do
               local item = addoninfo.items[i]
               if (getPlayerItemCount(cid,item[1]) >= item[2]) then
                   items_number = items_number + 1
               end
           end
       end
       if(getPlayerMoney(cid) >= addoninfo.cost) and (items_number == table.maxn(addoninfo.items)) then
           doPlayerRemoveMoney(cid, addoninfo.cost)
           if table.maxn(addoninfo.items) > 0 then
               for i = 1, table.maxn(addoninfo.items) do
                   local item = addoninfo.items[i]
                   doPlayerRemoveItem(cid,item[1],item[2])
               end
           end
           doPlayerAddOutfit(cid, addoninfo.outfit_male, addoninfo.addon)
           doPlayerAddOutfit(cid, addoninfo.outfit_female, addoninfo.addon)
           setPlayerStorageValue(cid,addoninfo.storageID,1)
           npcHandler:say('Ficou lindo em voce!', cid)
       else
           npcHandler:say('O que disse? Nao ouvi!!', cid)
       end
       npcHandler:resetNpc()
       return true
   elseif (parameters.decline == true) then
       npcHandler:say('Se nao lhe agrada, va embora!', cid)
       npcHandler:resetNpc()
       return true
   end
   return false
end

local noNode = KeywordNode:new({'no'}, playerBuyAddonNPC, {decline = true})
local yesNode = KeywordNode:new({'yes'}, playerBuyAddonNPC, {confirm = true})


local outfit_node = keywordHandler:addKeyword({'primeiro'}, playerBuyAddonNPC, {premium = false, cost = 0, items = {{5878,50},{5902,20}}, outfit_female = 136, outfit_male = 128, addon = 1, storageID = 10038})
local outfit_node = keywordHandler:addKeyword({'segundo'}, playerBuyAddonNPC, {premium = false, cost = 0, items = {{2366,1}}, outfit_female = 136, outfit_male = 128, addon = 2, storageID = 10039})
   outfit_node:addChildKeywordNode(yesNode)
   outfit_node:addChildKeywordNode(noNode)



keywordHandler:addKeyword({'big feather'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Me traga 100 {chicken} {feathers} que lhe dou 1 big feather.'})
keywordHandler:addKeyword({'addons'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Para o {primeiro} citizen addon voc\ê precisa de 50 minotaur leathers e 20 honey combs. Para o {segundo} citizen addon voc\ê precisa de uma big feather.'})

npcHandler:addModule(FocusModule:new())

Link para o comentário
https://xtibia.com/forum/topic/186011-error-com-script-de-npc/
Compartilhar em outros sites

6 respostass a esta questão

Posts Recomendados

  • 0

teste agr ai

 

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 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, 'chicken feather')) then

selfSay('Voc\ê me trouxe 100 chickens feathers?', cid)

talkState[talkUser] = 1

if getPlayerItemCount(cid,5890) >= 100 then

if(doPlayerRemoveItem(cid, 5890,100) == true) then

selfSay('Obrigado! Tome aqui sua big feather.', cid)

setPlayerStorageValue(cid, 2366,1)

talkState[talkUser] = 0

end

else

selfSay('Voc\ê n\ão tem 100 chickens feathers.', cid)

end

end

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

 

npcHandler:setMessage(MESSAGE_GREET, "Ola |PLAYERNAME|. Esta aqui pela {big} {feather}, ou pelos {addons}?")

 

function playerBuyAddonNPC(cid, message, keywords, parameters, node)

if(not npcHandler:isFocused(cid)) then

return false

end

if (parameters.confirm ~= true) and (parameters.decline ~= true) then

if(getPlayerPremiumDays(cid) == 0) and (parameters.premium == true) then

npcHandler:say('Desculpe, mas este addon e apenas para jogadores premium!', cid)

npcHandler:resetNpc()

return true

end

if (getPlayerStorageValue(cid, parameters.storageID) ~= -1) then

npcHandler:say('Voce ja tem esse addon!', cid)

npcHandler:resetNpc()

return true

end

local itemsTable = parameters.items

local items_list = ''

if table.maxn(itemsTable) > 0 then

for i = 1, table.maxn(itemsTable) do

local item = itemsTable

items_list = items_list .. item[2] .. ' ' .. getItemNameById(item[1])

if i ~= table.maxn(itemsTable) then

items_list = items_list .. ', '

end

end

end

local text = ''

if (parameters.cost > 0) and table.maxn(parameters.items) then

text = items_list .. ' and ' .. parameters.cost .. ' gp'

elseif (parameters.cost > 0) then

text = parameters.cost .. ' gp'

elseif table.maxn(parameters.items) then

text = items_list

end

npcHandler:say('Trouxe os itens para este addon?', cid)

return true

elseif (parameters.confirm == true) then

local addonNode = node:getParent()

local addoninfo = addonNode:getParameters()

local items_number = 0

if table.maxn(addoninfo.items) > 0 then

for i = 1, table.maxn(addoninfo.items) do

local item = addoninfo.items

if (getPlayerItemCount(cid,item[1]) >= item[2]) then

items_number = items_number + 1

end

end

end

if(getPlayerMoney(cid) >= addoninfo.cost) and (items_number == table.maxn(addoninfo.items)) then

doPlayerRemoveMoney(cid, addoninfo.cost)

if table.maxn(addoninfo.items) > 0 then

for i = 1, table.maxn(addoninfo.items) do

local item = addoninfo.items

doPlayerRemoveItem(cid,item[1],item[2])

end

end

doPlayerAddOutfit(cid, addoninfo.outfit_male, addoninfo.addon)

doPlayerAddOutfit(cid, addoninfo.outfit_female, addoninfo.addon)

setPlayerStorageValue(cid,addoninfo.storageID,1)

npcHandler:say('Ficou lindo em voce!', cid)

else

npcHandler:say('O que disse? Nao ouvi!!', cid)

end

npcHandler:resetNpc()

return true

elseif (parameters.decline == true) then

npcHandler:say('Se nao lhe agrada, va embora!', cid)

npcHandler:resetNpc()

return true

end

return false

end

 

local noNode = KeywordNode:new({'no'}, playerBuyAddonNPC, {decline = true})

local yesNode = KeywordNode:new({'yes'}, playerBuyAddonNPC, {confirm = true})

 

 

local outfit_node = keywordHandler:addKeyword({'primeiro'}, playerBuyAddonNPC, {premium = false, cost = 0, items = {{5878,50},{5902,20}}, outfit_female = 136, outfit_male = 128, addon = 1, storageID = 10038})

local outfit_node = keywordHandler:addKeyword({'segundo'}, playerBuyAddonNPC, {premium = false, cost = 0, items = {{2366,1}}, outfit_female = 136, outfit_male = 128, addon = 2, storageID = 10039})

outfit_node:addChildKeywordNode(yesNode)

outfit_node:addChildKeywordNode(noNode)

 

 

 

keywordHandler:addKeyword({'big feather'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Me traga 100 {chicken} {feathers} que lhe dou 1 big feather.'})

keywordHandler:addKeyword({'addons'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Para o {primeiro} citizen addon voc\ê precisa de 50 minotaur leathers e 20 honey combs. Para o {segundo} citizen addon voc\ê precisa de uma big feather.'})

 

npcHandler:addModule(FocusModule:new())

 

espero ter ajudado

ate

Link para o comentário
https://xtibia.com/forum/topic/186011-error-com-script-de-npc/#findComment-1258674
Compartilhar em outros sites

  • 0

Nao deu certo

Deu error na linha 7 "eof" eu arrumei, troquei pra

 

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

 

Mas mesmo assim continua o mesmo bug do meu topico

Link para o comentário
https://xtibia.com/forum/topic/186011-error-com-script-de-npc/#findComment-1258682
Compartilhar em outros sites

  • 0

entao tente agr

 

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

 

 

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end npcHandler:onCreatureDisappear(cid) end 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, 'chicken feather')) then

selfSay('Voc\ê me trouxe 100 chickens feathers?', cid)

talkState[talkUser] = 1

if getPlayerItemCount(cid,5890) >= 100 then

if(doPlayerRemoveItem(cid, 5890,100) == true) then

selfSay('Obrigado! Tome aqui sua big feather.', cid)

setPlayerStorageValue(cid, 2366,1)

talkState[talkUser] = 0

end

else

selfSay('Voc\ê n\ão tem 100 chickens feathers.', cid)

end

end

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

 

npcHandler:setMessage(MESSAGE_GREET, "Ola |PLAYERNAME|. Esta aqui pela {big} {feather}, ou pelos {addons}?")

 

function playerBuyAddonNPC(cid, message, keywords, parameters, node)

if(not npcHandler:isFocused(cid)) then

return false

end

if (parameters.confirm ~= true) and (parameters.decline ~= true) then

if(getPlayerPremiumDays(cid) == 0) and (parameters.premium == true) then

npcHandler:say('Desculpe, mas este addon e apenas para jogadores premium!', cid)

npcHandler:resetNpc()

return true

end

if (getPlayerStorageValue(cid, parameters.storageID) ~= -1) then

npcHandler:say('Voce ja tem esse addon!', cid)

npcHandler:resetNpc()

return true

end

local itemsTable = parameters.items

local items_list = ''

if table.maxn(itemsTable) > 0 then

for i = 1, table.maxn(itemsTable) do

local item = itemsTable

items_list = items_list .. item[2] .. ' ' .. getItemNameById(item[1])

if i ~= table.maxn(itemsTable) then

items_list = items_list .. ', '

end

end

end

local text = ''

if (parameters.cost > 0) and table.maxn(parameters.items) then

text = items_list .. ' and ' .. parameters.cost .. ' gp'

elseif (parameters.cost > 0) then

text = parameters.cost .. ' gp'

elseif table.maxn(parameters.items) then

text = items_list

end

npcHandler:say('Trouxe os itens para este addon?', cid)

return true

elseif (parameters.confirm == true) then

local addonNode = node:getParent()

local addoninfo = addonNode:getParameters()

local items_number = 0

if table.maxn(addoninfo.items) > 0 then

for i = 1, table.maxn(addoninfo.items) do

local item = addoninfo.items

if (getPlayerItemCount(cid,item[1]) >= item[2]) then

items_number = items_number + 1

end

end

end

if(getPlayerMoney(cid) >= addoninfo.cost) and (items_number == table.maxn(addoninfo.items)) then

doPlayerRemoveMoney(cid, addoninfo.cost)

if table.maxn(addoninfo.items) > 0 then

for i = 1, table.maxn(addoninfo.items) do

local item = addoninfo.items

doPlayerRemoveItem(cid,item[1],item[2])

end

end

doPlayerAddOutfit(cid, addoninfo.outfit_male, addoninfo.addon)

doPlayerAddOutfit(cid, addoninfo.outfit_female, addoninfo.addon)

setPlayerStorageValue(cid,addoninfo.storageID,1)

npcHandler:say('Ficou lindo em voce!', cid)

else

npcHandler:say('O que disse? Nao ouvi!!', cid)

end

npcHandler:resetNpc()

return true

elseif (parameters.decline == true) then

npcHandler:say('Se nao lhe agrada, va embora!', cid)

npcHandler:resetNpc()

return true

end

return false

end

 

local noNode = KeywordNode:new({'no'}, playerBuyAddonNPC, {decline = true})

local yesNode = KeywordNode:new({'yes'}, playerBuyAddonNPC, {confirm = true})

 

 

local outfit_node = keywordHandler:addKeyword({'primeiro'}, playerBuyAddonNPC, {premium = false, cost = 0, items = {{5878,50},{5902,20}}, outfit_female = 136, outfit_male = 128, addon = 1, storageID = 10038})

local outfit_node = keywordHandler:addKeyword({'segundo'}, playerBuyAddonNPC, {premium = false, cost = 0, items = {{2366,1}}, outfit_female = 136, outfit_male = 128, addon = 2, storageID = 10039})

outfit_node:addChildKeywordNode(yesNode)

outfit_node:addChildKeywordNode(noNode)

 

 

 

keywordHandler:addKeyword({'big feather'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Me traga 100 {chicken} {feathers} que lhe dou 1 big feather.'})

keywordHandler:addKeyword({'addons'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Para o {primeiro} citizen addon voc\ê precisa de 50 minotaur leathers e 20 honey combs. Para o {segundo} citizen addon voc\ê precisa de uma big feather.'})

 

npcHandler:addModule(FocusModule:new())

Link para o comentário
https://xtibia.com/forum/topic/186011-error-com-script-de-npc/#findComment-1258694
Compartilhar em outros sites

  • 0

Com o primeiro addon e com a big feather continua o mesmo bug, o segundo addon funcionou, obs: só esse, e ja estava funcionando antes.

 

 

 

@EDIT

Ae, os addons consegui resolver sozinho, só falta a big feathers, alguem me ajuda?

 

@EDIT

 

AE CONSEGUI RESOLVER SOZINHO ALGUEM PODE FECHAR O TOPICO?

Editado por Lucaswc15
Link para o comentário
https://xtibia.com/forum/topic/186011-error-com-script-de-npc/#findComment-1258699
Compartilhar em outros sites

×
×
  • Criar Novo...