Sim, eu sei qual é o problema.
O console acusa que em alguma linha dos dois scripts, está ocorrendo uma comparação entre um valor númerico e algo está retornando nil (ou nulo). Só achar as linhas e consertar.
Abraços.
Por juliok80, 01 de jan. de 2013 em Scripts
Sim, eu sei qual é o problema.
O console acusa que em alguma linha dos dois scripts, está ocorrendo uma comparação entre um valor númerico e algo está retornando nil (ou nulo). Só achar as linhas e consertar.
Abraços.
info
Grupo: Príncipe
Registrado: 19/08/10
Posts: 4k
Reputação: +1.1k
Gênero: Masculino

/\
o engraçado eh q no 1* script n tem linha 104 ;p nem se quer 94...
sobre o 2* tem q trocar todos os..
creatureGetName
por..
getCreatureName
info
Grupo: Artesão
Registrado: 15/11/12
Posts: 120
Reputação: +17
Char no Tibia: Ba Rao

/\
o engraçado eh q no 1* script n tem linha 104 ;p nem se quer 94...
sobre o 2* tem q trocar todos os..
creatureGetNamepor..
getCreatureName
Vou fazer essa troca e quando chegar em casa eu testo.
Só uma outra duvida, elseif não precisa de end?
Por que eu vejo 2 modos de elseif no script, junto e separado:
else if getPlayerStorageValue(cid,999998) == 1 then -- Esse precisa de end
elseif msgcontains(msg, 'addon 2') then -- Esse não precisa de end
Thanks guys!
Editado Janeiro 4 por juliok80
/\
o engraçado eh q no 1* script n tem linha 104 ;p nem se quer 94...
sobre o 2* tem q trocar todos os..
creatureGetNamepor..
getCreatureName
Vou fazer essa troca e quando chegar em casa eu testo.
Só uma outra duvida, elseif não precisa de end?
Thanks guys!
Não, não precisa.
Editado Janeiro 4 por Oneshot
info
Grupo: Artesão
Registrado: 15/11/12
Posts: 120
Reputação: +17
Char no Tibia: Ba Rao

/\
o engraçado eh q no 1* script n tem linha 104 ;p nem se quer 94...
sobre o 2* tem q trocar todos os..
creatureGetNamepor..
getCreatureName
Olha, eu alterei os códigos, porém continuou acusando erro... ai encontrei um script aqui no Xtibia que não está dando erro, porém mesmo que o player não tenha os itens necessários ele ainda recebe o addon!
Alguém saberia me dizer pq esse script está se comportando desta maneira?
Segue o novo script que estou usando:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false
local addon_state = 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('E ae ' .. getCreatureName(cid) .. ' você trouxe a minha Zaoan sword!?')
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, 'yes') or msgcontains(msg, 'sim') then
if doPlayerRemoveItem(cid,11301,1) == 0 then
selfSay('Cadê!?')
addon_state = 0
else
selfSay('Yeah, valeu!')
if getPlayerSex(cid) == 0 then
doPlayerAddOutfit(cid, 335, 1)
else
doPlayerAddOutfit(cid, 336, 1)
talk_start = 0
end
end
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. getCreatureName(cid))
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end
@Edit
Ae Galera... consegui arrumar o script!
Peguei o script de um NPC e fiz as alterações, agora está funcionando perfeitamente...
Segue o script do NPC Addon Warmaster 1 caso alguém precise, para o segundo addon é só editar as falas, a parte do addon que irá adicionar ao player e o item requerido:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
selfSay('Olá ' .. getCreatureName(cid) .. ', fale {addon 1} para mais informacoes!')
if(msgcontains(msg, 'addon 1') or msgcontains(msg, 'first addon') or msgcontains(msg, 'addon')) then
selfSay('Para conseguir o addon 1 do Warmaster eu preciso que voce me traga uma {Zaoan Sword}, voce trouxe uma?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(getPlayerItemCount(cid, 11301) >= 1) then
if(doPlayerRemoveItem(cid, 11301,1) == TRUE) then
if getPlayerSex(cid) == 0 then
doPlayerAddOutfit(cid, 335, 1)
else
doPlayerAddOutfit(cid, 336, 1)
talk_start = 0
end
selfSay('Parabéns! Agora você possui o primeiro Addon Warmaster.', cid)
else
selfSay('Desculpe, volte quando tiver uma {Zaoan Sword}.', cid)
end
else
selfSay('Desculpe, voce nao tem uma {Zaoan Sword}.', cid)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Ae moderação, pode fechar o tópico!
Muito obrigado a todos que me ajudaram! ![]()
Editado Janeiro 7 por juliok80
Tópico movido para a seção de dúvidas e pedidos resolvidos.
info
Grupo: Artesão
Registrado: 15/11/12
Posts: 120
Reputação: +17
Char no Tibia: Ba Rao
Olá xtibianos, blz!?
Olha, estou com problemas nos scripts dos NPCs do Warmaster Addon 1 e 2... quando alguém fala com esses NPCs surge os seguintes erros no console, e o NPC não está pegando os itens necessários para fazer o addon, segue os erros do console:
Segue o script dos NPCs:
Warmaster addon 1:
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) .. ' Eu posso lhe conceder o Warmaster addon 1, para mais infos. diga help...') focus = cid talk_start = os.clock() elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then selfSay('Desculpe, ' .. getCreatureName(cid) .. '! Eu falo com você em um minuto.') elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'help') then selfSay('Para saber o que eh preciso para obter o Warmaster addon 1 diga: addon 1') elseif msgcontains(msg, 'addon 1') then if getPlayerStorageValue(cid,999999) >= 2 then selfSay('Voce ja tem esse addon.') else if getPlayerStorageValue(cid,999999) == 1 then selfSay('Preciso de uma zaoan sword e de 100k, você trouxe para mim?') addon_state = 2 else setPlayerStorageValue(cid,999999,1) selfSay('Preciso de uma zaoan sword e de 100k, você trouxe para mim?') end end elseif msgcontains(msg, 'yes') and addon_state == 2 then if doPlayerRemoveItem(cid,2160, 10) == 0 or doPlayerRemoveItem(cid,11301, 1) == 0 then selfSay('Desculpe mas você não os tem 100k...') else selfSay('Obrigado, agora você tem o novo addon da terra dos Warmasters!') if getPlayerSex(cid) == 0 then doPlayerAddOutfit(cid, 335, 1) setPlayerStorageValue(cid,999999,2) else doPlayerAddOutfit(cid, 336, 1) setPlayerStorageValue(cid,999999,2) talk_state = 1 end end elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then selfSay('Adeus ' .. creatureGetName(cid) .. ', Volte sempre.') focus = 0 talk_start = 0 elseif msg ~= "" then selfSay('Como? Eu não entendi!') talk_state = 0 end end end function onCreatureChangeOutfit(creature) end function onThink() doNpcSetCreatureFocus(focus) if (os.clock() - talk_start) > 30 then if focus > 0 then selfSay('Proximo!...') 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 endWarmaster addon 2:
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) .. ' Eu posso lhe conceder o Warmaster addon 2, para mais infos. diga help...') focus = cid talk_start = os.clock() elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then selfSay('Desculpe, ' .. getCreatureName(cid) .. '! Eu falo com você em um minuto.') elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'help') then selfSay('Para saber o que eh preciso para obter o Warmaster addon 2 diga: addon 2') elseif msgcontains(msg, 'addon 2') then if getPlayerStorageValue(cid,999998) >= 2 then selfSay('Voce ja tem esse addon.') else if getPlayerStorageValue(cid,999998) == 1 then selfSay('Preciso de uma baiak sword e 100k , você trouxe para mim ?') addon_state = 2 else setPlayerStorageValue(cid,999998,1) selfSay('Preciso de uma baiak sword e 100k, você trouxe para mim ?') end end elseif msgcontains(msg, 'yes') and addon_state == 2 then if doPlayerRemoveItem(cid,2160, 10) == 0 or doPlayerRemoveItem(cid,8931, 1) == 0 then selfSay('Desculpe mas você não tem os 100k...') else selfSay('Obrigado, agora você tem o novo addon da terra dos Warmasters!') if getPlayerSex(cid) == 0 then doPlayerAddOutfit(cid, 335, 2) setPlayerStorageValue(cid,999998,2) else doPlayerAddOutfit(cid, 336, 2) setPlayerStorageValue(cid,999998,2) talk_state = 1 end end elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then selfSay('Adeus ' .. creatureGetName(cid) .. ', Volte Sempre.') focus = 0 talk_start = 0 elseif msg ~= "" then selfSay('Como? Eu não entendi!') talk_state = 0 end end end function onCreatureChangeOutfit(creature) end function onThink() doNpcSetCreatureFocus(focus) if (os.clock() - talk_start) > 30 then if focus > 0 then selfSay('Proximo!!...') 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 endAlguém saberia me dizer o que há de errado nos scrripts!?
Obrigado!
Upa upa cavalinho alazão!
Alguém me ajuda!?