Ir para conteúdo

Posts Recomendados

Boa noite.

 

Estava fazendo um npc e deu um erro no console em seu script, precisaria que alguem que conheça por gentileza desse uma olhada.

Segue tudo:

 

Script do NPC:

local focus = 0

local talk_start = 0

 

function onThingMove(creature, thing, oldpos, oldstackpos)

 

end

 

 

function onCreatureAppear(creature)

 

end

 

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('Good bye then.')

focus = 0

talk_start = 0

end

end

 

 

function onCreatureTurn(creature)

 

end

 

 

function msgcontains(txt, str)

return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))

end

 

 

function onCreatureSay(cid, type, msg)

msg = string.lower(msg)

 

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then

selfSay('Hiho ' .. getCreatureName(cid) .. ' I can grant you the addons {Summoner}.')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

 

elseif focus == cid then

talk_start = os.clock()

 

if msgcontains(msg, 'help') then

selfSay('Bring me 100 empty potions and 5 scarab coins in exchange for addons.')

 

 

elseif msgcontains(msg, 'Summoner') then

if getPlayerStorageValue(cid,999998) >= 2 then

selfSay('you already have this addon.')

 

else if getPlayerStorageValue(cid,999998) == 1 then

selfSay('need 100 empty potions and 5 scarab coins, did you bring?')

addon_state = 2

else

setPlayerStorageValue(cid,999998,1)

selfSay('need 100 empty potions and 5 scarab coins, did you bring?')

end

end

elseif msgcontains(msg, 'yes') and addon_state == 2 then

if doPlayerRemoveItem(cid,2159, 5) == 0 and doPlayerRemoveItem(cid,7636, 100) == 0 then

selfSay('Sorry, you do not have the necessary items.')

else

selfSay('Congratulations, now you have the addon of Summoner!')

doPlayerAddOutfit(cid, 141, 1)

doPlayerAddOutfit(cid, 141, 2)

setPlayerStorageValue(cid,999998,2)

end

 

else

doPlayerAddOutfit(cid, 133, 1)

doPlayerAddOutfit(cid, 133, 2)

setPlayerStorageValue(cid,999998,2)

talk_state = 1

end

end

end

 

if msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye, Cya.')

focus = 0

talk_start = 0

end

 

if msg ~= "" then

selfSay('Sorry, I do not understand you.')

talk_state = 0

end

 

function onCreatureChangeOutfit(creature)

end

 

function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 30 then

if focus > 0 then

selfSay('Next!!...')

end

focus = 0

talk_start = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good Bye')

focus = 0

talk_start = 0

end

end

end

 

Erro no console:

[23/12/2010 22:12:33] Lua Script Error: [Npc interface]

[23/12/2010 22:12:33] data/npc/scripts/summoner.lua

 

[23/12/2010 22:12:33] data/npc/scripts/summoner.lua:29: bad argument #1 to 'find' (string expected, got nil)

[23/12/2010 22:12:33] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/summoner.lua

 

Obrigado e agradeço qualquer boa ajuda.

Link para o comentário
https://xtibia.com/forum/topic/148089-erro-no-npc-de-addon/
Compartilhar em outros sites

×
×
  • Criar Novo...