Ir para conteúdo
Banner com Efeitos

Featured Replies

Postado
  • Autor

Deve até ter, mas creio que será um pouco mais chatinho de fazer.

 

Este seria um exemplo:

Script.

 

Só que pra mim fazer agora, infelizmente, seria inviável.

Enfim, boa sorte.

 

Olá tem um problema quando falo HI e Trade o NPC diz só alguns items e ainda fala o nome de alguns items errados :(

 

script

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
------------------- Configuração dos Itens -----------------------
 
local items = {1820, 1821, 2037, 2038, 2097, 2098, 2096, 2099, 2400, 11454} -- ID dos Itens
local nome = {'item1', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7', 'item8', 'item9', 'item10'}  -- Nome dos Itens
local valor = {2145, 5} -- id da moeda, quantidade
 
------------------- MESSAGES INICIAIS ----------------------------------------
if msgcontains(msg, nome[1]) then
selfSay('Deseja comprar um {'..getItemNameById(items[1])..'} pagando '..valor[2]..' {'..getItemNameById(valor[1])..'?}', cid)
talkState[talkUser] = 1
 
elseif msgcontains(msg, nome[2]) then
selfSay('Deseja comprar um {'..getItemNameById(items[2])..'} pagando '..valor[2]..' {'..getItemNameById(valor[1])..'?}', cid)
talkState[talkUser] = 2
 
elseif msgcontains(msg, nome[3]) then
selfSay('Deseja comprar um {'..getItemNameById(items[3])..'} pagando '..valor[2]..' {'..getItemNameById(valor[1])..'?}', cid)
talkState[talkUser] = 3
 
elseif msgcontains(msg, nome[4]) then
selfSay('Deseja comprar um {'..getItemNameById(items[4])..'} pagando '..valor[2]..' {'..getItemNameById(valor[1])..'?}', cid)
talkState[talkUser] = 4
 
elseif msgcontains(msg, nome[5]) then
selfSay('Deseja comprar um {'..getItemNameById(items[5])..'} pagando '..valor[2]..' {'..getItemNameById(valor[1])..'?}', cid)
talkState[talkUser] = 5
 
elseif msgcontains(msg, nome[6]) then
selfSay('Deseja comprar um {'..getItemNameById(items[6])..'} pagando '..valor[2]..' {'..getItemNameById(valor[1])..'?}', cid)
talkState[talkUser] = 6
 
elseif msgcontains(msg, nome[7]) then
selfSay('Deseja comprar um {'..getItemNameById(items[7])..'} pagando '..valor[2]..' {'..getItemNameById(valor[1])..'?}', cid)
talkState[talkUser] = 7
 
elseif msgcontains(msg, nome[8]) then
selfSay('Deseja comprar um {'..getItemNameById(items[8])..'} pagando '..valor[2]..' {'..getItemNameById(valor[1])..'?}', cid)
talkState[talkUser] = 8
 
elseif msgcontains(msg, nome[9]) then
selfSay('Deseja comprar um {'..getItemNameById(items[9])..'} pagando '..valor[2]..' {'..getItemNameById(valor[1])..'?}', cid)
talkState[talkUser] = 9
 
elseif msgcontains(msg, nome[10]) then
selfSay('Deseja comprar um {'..getItemNameById(items[10])..'} pagando '..valor[2]..' {'..getItemNameById(valor[1])..'?}', cid)
talkState[talkUser] = 10
 
elseif (msgcontains(msg, 'trade') or msgcontains(msg, 'hi')) then
selfSay(' Digite qual item deseja adquirir.', cid)
selfSay('Atualmente temos {'..getItemNameById(items[1])..'}, {'..getItemNameById(items[2])..'}, {'..getItemNameById(items[3])..'}, {'..getItemNameById(items[4])..'}, {'..getItemNameById(items[5])..'}, {'..getItemNameById(items[6])..'}, {'..getItemNameById(items[7])..'} e {'..getItemNameById(items[8])..'}.', cid)
talkState[talkUser] = 0
 
---------------------- NEGOCIAÇÃO -------------------------------
 
elseif talkState[talkUser] == 1 then
if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
    if getPlayerItemCount(cid, valor[1]) >= valor[2] then
        doPlayerRemoveItem(cid, valor[1], valor[2])
        doPlayerAddItem(cid, items[1], 1)
        selfSay('Parabens, voce acaba de adquirir um '..getItemNameById(items[1])..'.', cid)
    else
        selfSay('Voce nao tem dinheiro o suficiente.', cid)
    talkState[talkUser] = 0
    end
end
 
elseif talkState[talkUser] == 2 then
if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
    if getPlayerItemCount(cid, valor[1]) >= valor[2] then
        doPlayerRemoveItem(cid, valor[1], valor[2])
        doPlayerAddItem(cid, items[2], 1)
        selfSay('Parabens, voce acaba de adquirir um '..getItemNameById(items[2])..'.', cid)
    else
        selfSay('Voce nao tem dinheiro o suficiente.', cid)
    talkState[talkUser] = 0
    end
end
 
elseif talkState[talkUser] == 3 then
if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
    if getPlayerItemCount(cid, valor[1]) >= valor[2] then
        doPlayerRemoveItem(cid, valor[1], valor[2])
        doPlayerAddItem(cid, items[3], 1)
        selfSay('Parabens, voce acaba de adquirir um '..getItemNameById(items[3])..'.', cid)
    else
        selfSay('Voce nao tem dinheiro o suficiente.', cid)
    talkState[talkUser] = 0
    end
end
 
elseif talkState[talkUser] == 4 then
if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
    if getPlayerItemCount(cid, valor[1]) >= valor[2] then
        doPlayerRemoveItem(cid, valor[1], valor[2])
        doPlayerAddItem(cid, items[4], 1)
        selfSay('Parabens, voce acaba de adquirir um '..getItemNameById(items[4])..'.', cid)
    else
        selfSay('Voce nao tem dinheiro o suficiente.', cid)
    talkState[talkUser] = 0
    end
end
 
elseif talkState[talkUser] == 5 then
if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
    if getPlayerItemCount(cid, valor[1]) >= valor[2] then
        doPlayerRemoveItem(cid, valor[1], valor[2])
        doPlayerAddItem(cid, items[5], 1)
        selfSay('Parabens, voce acaba de adquirir um '..getItemNameById(items[5])..'.', cid)
    else
        selfSay('Voce nao tem dinheiro o suficiente.', cid)
    talkState[talkUser] = 0
    end
end
 
elseif talkState[talkUser] == 6 then
if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
    if getPlayerItemCount(cid, valor[1]) >= valor[2] then
        doPlayerRemoveItem(cid, valor[1], valor[2])
        doPlayerAddItem(cid, items[6], 1)
        selfSay('Parabens, voce acaba de adquirir um '..getItemNameById(items[6])..'.', cid)
    else
        selfSay('Voce nao tem dinheiro o suficiente.', cid)
    talkState[talkUser] = 0
    end
end
 
elseif talkState[talkUser] == 7 then
if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
    if getPlayerItemCount(cid, valor[1]) >= valor[2] then
        doPlayerRemoveItem(cid, valor[1], valor[2])
        doPlayerAddItem(cid, items[7], 1)
        selfSay('Parabens, voce acaba de adquirir um '..getItemNameById(items[7])..'.', cid)
    else
        selfSay('Voce nao tem dinheiro o suficiente.', cid)
    talkState[talkUser] = 0
    end
end
 
elseif talkState[talkUser] == 8 then
if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
    if getPlayerItemCount(cid, valor[1]) >= valor[2] then
        doPlayerRemoveItem(cid, valor[1], valor[2])
        doPlayerAddItem(cid, items[8], 1)
        selfSay('Parabens, voce acaba de adquirir um '..getItemNameById(items[8])..'.', cid)
    else
        selfSay('Voce nao tem dinheiro o suficiente.', cid)
    talkState[talkUser] = 0
    end
end
 
elseif talkState[talkUser] == 9 then
if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
    if getPlayerItemCount(cid, valor[1]) >= valor[2] then
        doPlayerRemoveItem(cid, valor[1], valor[2])
        doPlayerAddItem(cid, items[9], 1)
        selfSay('Parabens, voce acaba de adquirir um '..getItemNameById(items[9])..'.', cid)
    else
        selfSay('Voce nao tem dinheiro o suficiente.', cid)
    talkState[talkUser] = 0
    end
end
 
elseif talkState[talkUser] == 10 then
if (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) then
    if getPlayerItemCount(cid, valor[1]) >= valor[2] then
        doPlayerRemoveItem(cid, valor[1], valor[2])
        doPlayerAddItem(cid, items[10], 1)
        selfSay('Parabens, voce acaba de adquirir um '..getItemNameById(items[10])..'.', cid)
    else
        selfSay('Voce nao tem dinheiro o suficiente.', cid)
    talkState[talkUser] = 0
    end
end
 
end
return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

imagem

http://prntscr.com/4c6ays

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

  • Respostas 24
  • Visualizações 1.9k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Adriano SwaTT
    Adriano SwaTT

    Aí é o nome que vc tem que falar para o NPC. Ex: Hi / Demon Armor / Yes   E lembre-se, tem que estar na mesma ordem de que as ids acima.

  • Adriano SwaTT
    Adriano SwaTT

    Todos estes itens por 5 diamantes ou cada um destes itens vale 5 diamante? E eles são itens agrupáveis? ou usaremos 1 de cada mesmo?

  • Adriano SwaTT
    Adriano SwaTT

    No caso, cada 1 ou cada grupo de 100 itens valem 5 diamantes?   #Por favor, facilite nas informações, passe já com maiores detalhes.

Postado

Conforme disse, o script não foi feito para ter a função TRADE.

E se está falando o nome errado, é porque a ID está errada, pois ele pega o nome diretamente no Items.XML através da ID dos itens do script.

 

E como você adicionou novos itens.

Esqueceu de declara-los na resposta do NPC:

 

elseif (msgcontains(msg, 'trade') or msgcontains(msg, 'hi')) then
selfSay(' Digite qual item deseja adquirir.', cid)
selfSay('Atualmente temos {'..getItemNameById(items[1])..'}, {'..getItemNameById(items[2])..'}, {'..getItemNameById(items[3])..'}, {'..getItemNameById(items[4])..'}, {'..getItemNameById(items[5])..'}, {'..getItemNameById(items[6])..'}, {'..getItemNameById(items[7])..'} e {'..getItemNameById(items[8])..'}.', cid)
talkState[talkUser] = 0

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

Gosta do meu trabalho?

Curta e siga a página do meu projeto de 2016 e 2017 (Lab Z Games) que trará vários servidores OTServs.

 

Atenciosamente,
Adriano Swatt'

 

Para ver meus tutoriais acesse meu perfil.

 

cbCyOSZ.png

Postado

Porque tem que substituir nestas linhas.

local nome = {'item1', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7', 'item8', 'item9', 'item10'}  -- Nome dos Itens

Adicionando o nome dos itens, em ordem.

Ex:

local nome = {'demon armor', 'fire axe', 'item3', 'item4', 'item5', 'item6', 'item7', 'item8', 'item9', 'item10'}  -- Nome dos Itens

Entendeu?

Gosta do meu trabalho?

Curta e siga a página do meu projeto de 2016 e 2017 (Lab Z Games) que trará vários servidores OTServs.

 

Atenciosamente,
Adriano Swatt'

 

Para ver meus tutoriais acesse meu perfil.

 

cbCyOSZ.png

Postado
  • Autor

Porque tem que substituir nestas linhas.

local nome = {'item1', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7', 'item8', 'item9', 'item10'}  -- Nome dos Itens

Adicionando o nome dos itens, em ordem.

Ex:

local nome = {'demon armor', 'fire axe', 'item3', 'item4', 'item5', 'item6', 'item7', 'item8', 'item9', 'item10'}  -- Nome dos Itens

Entendeu?

é mas só tem que trocar ai ? 

ou tem que ir trocando em outros Lugares?

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo