Ir para conteúdo
  • Cadastre-se

(Resolvido)[Erro] Script Npc Bless.


Ir para solução Resolvido por olokomeu,

Posts Recomendados

Olá pessoal do TibiaKing!. Bem, achei um topico aqui no forum do npc Bless, porém, esse script ta dando um certo erro:

 

- O npc não me da bless.

 

Eu falo "hi", ele me responde "Ola (player).. eu vendo blessing" ai quando respondo " blessing" ele não retornar e nao da bless. Se alguem puder me ajudar agradeceria. Deixarei o script abaixo para vocês olharem:

 

xml npc :

 

 

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

<npc name="Sacerdote da Villa" script="sacerdote da villa.lua" walkinterval="2000" floorchange="0">
    <health now="150" max="150" />
    <look type="57" head="57" body="59" legs="40" feet="76" corpse="2212" />
</npc>

 

 

.lua npc:

 

 

local focuses = {}

local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end
 
local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end
local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end
end
local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v)) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end
 
local price = 50000 -- Valor da bless
 
function onCreatureSay(cid, type, msg)
    if(not (isFocused(cid)) and (msg == "hi" or msg == "hello")) then
        selfSay("Ola, ".. getCreatureName(cid) ..". Eu vendo {blessing}.", cid)
        addFocus(cid)
    elseif((isFocused(cid)) and (msg == "bless" or msg == "blessing")) then
        selfSay("Voce gostaria de comprar blessing por ".. doNumberFormat(price) .." gold coins?", cid)
    elseif((isFocused(cid)) and (msg == "yes")) then
        if getPlayerMoney(cid) >= price then
            selfSay("Tudo certo.", cid)
            doPlayerRemoveMoney(cid, price)
            doPlayerAddBlessing(cid, 1)
            doPlayerAddBlessing(cid, 2)
            doPlayerAddBlessing(cid, 3)
            doPlayerAddBlessing(cid, 4)
            doPlayerAddBlessing(cid, 5)
            doPlayerAddBlessing(cid, 6)
        else
            selfSay("You don't have enough money.", cid)
        end
    elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
        selfSay("Adeus, que os anjos lhe proteja!", cid)
        closeShopWindow(cid)
        removeFocus(cid)
    end
end
 
function onThink()
    for i, focus in pairs(focuses) do
        if(not isCreature(focus)) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                selfSay("Ei, onde voce esta indo?")
                removeFocus(focus)
            end
        end
    end
    lookAtFocus()
end
Editado por olokomeu (veja o histórico de edições)

Eu te Ajudei? Então solta aquele REP+ !!

Meus Tutoriais [Tutorial] Bug "Temple position is wrong" (MySql)

Outros:    [Meu Show OFF | Mapa próprio 8.6] 

Link para o post
Compartilhar em outros sites

npc.xml

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Tiger Lucan" script="data/npc/scripts/bless.lua" walkinterval="1000" floorchange="0">
<health now="100" max="100"/>
<look type="73" head="0" body="0" legs="0" feet="0" addons="0"/>
<parameters>
     <parameter key="message_greet" value="Hi, Selling 5 Types of Bless. {First Bless}, {Second Bless}, {Third Bless}, {Fourth Bless}, {Fifth Bless} Want to Buy?'"/>
     <parameter key="message_farewell" value="bye.."/>
     <parameter key="module_keywords" value="1" />
     <parameter key="keywords" value="job;" />
     <parameter key="keyword_reply1" value="I am a busy man. I run the Ironhouse also im selling bless." />
     <parameter key="module_shop" value="1"/>
     <parameter key="shop_sellable" value="" />
     <parameter key="shop_buyable" value="" />
</parameters>
</npc>

em npc/scripts crie bless.lua :

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

local node1 = keywordHandler:addKeyword({'first bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first blessing for 10000 gold?'})
     node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 1, premium = true, cost = 10000})
     node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node2 = keywordHandler:addKeyword({'second bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the second blessing for 10000 gold?'})
     node2:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 2, premium = true, cost = 10000})
     node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node3 = keywordHandler:addKeyword({'third bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the third blessing for 10000 gold?'})
     node3:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 3, premium = true, cost = 10000})
     node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node4 = keywordHandler:addKeyword({'fourth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fourth blessing for 10000 gold?'})
     node4:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 4, premium = true, cost = 10000})
     node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node5 = keywordHandler:addKeyword({'fifth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fifth blessing for 10000 gold?'})
     node5:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 5, premium = true, cost = 10000})
     node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
npcHandler:addModule(FocusModule:new())
Link para o post
Compartilhar em outros sites
  • Solução

 

npc.xml

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Tiger Lucan" script="data/npc/scripts/bless.lua" walkinterval="1000" floorchange="0">
<health now="100" max="100"/>
<look type="73" head="0" body="0" legs="0" feet="0" addons="0"/>
<parameters>
     <parameter key="message_greet" value="Hi, Selling 5 Types of Bless. {First Bless}, {Second Bless}, {Third Bless}, {Fourth Bless}, {Fifth Bless} Want to Buy?'"/>
     <parameter key="message_farewell" value="bye.."/>
     <parameter key="module_keywords" value="1" />
     <parameter key="keywords" value="job;" />
     <parameter key="keyword_reply1" value="I am a busy man. I run the Ironhouse also im selling bless." />
     <parameter key="module_shop" value="1"/>
     <parameter key="shop_sellable" value="" />
     <parameter key="shop_buyable" value="" />
</parameters>
</npc>

em npc/scripts crie bless.lua :

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

local node1 = keywordHandler:addKeyword({'first bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first blessing for 10000 gold?'})
     node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 1, premium = true, cost = 10000})
     node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node2 = keywordHandler:addKeyword({'second bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the second blessing for 10000 gold?'})
     node2:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 2, premium = true, cost = 10000})
     node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node3 = keywordHandler:addKeyword({'third bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the third blessing for 10000 gold?'})
     node3:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 3, premium = true, cost = 10000})
     node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node4 = keywordHandler:addKeyword({'fourth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fourth blessing for 10000 gold?'})
     node4:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 4, premium = true, cost = 10000})
     node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node5 = keywordHandler:addKeyword({'fifth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fifth blessing for 10000 gold?'})
     node5:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 5, premium = true, cost = 10000})
     node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
npcHandler:addModule(FocusModule:new())

Já tentei usar esse script, mas dá erro. Mas obrigado :).

 

Já consegui arrumar meu Script que estava com defeito. Tópico já pode ser fechado. Obg :D

Editado por olokomeu (veja o histórico de edições)

Eu te Ajudei? Então solta aquele REP+ !!

Meus Tutoriais [Tutorial] Bug "Temple position is wrong" (MySql)

Outros:    [Meu Show OFF | Mapa próprio 8.6] 

Link para o post
Compartilhar em outros sites

O tópico foi movido para a área correta, preste mais atenção da próxima vez!

Leia as regras do fórum: http://tibiaking.com/forum/topic/1281-regras-gerais/?p=7680

Este tópico foi movido:

De: "OTServScriptingMonsters e NPCs"

Para: "OTServSuporte OTServSuporte de Scripts"

F5MHzGo.gif

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo