Ir para conteúdo

Featured Replies

Postado

Explicação: Criei este npc(Ty) para trocar 2 small diamonds(circulado em amarelo) por uma recording camera(circulado em laranja), está tudo funcionando, ele está fazendo a troca, logo, gostaria de acrescentar no npc(Ty) se o "jogador tem certeza que quer fazer essa troca", tipo o Sweety Cyclops do Tibia.

explication.png?1516369991

 

Como está: 

Ty: Hello | PLAYERNAME | I change 2 small diamonds for recording camera.

Tavarb: recording camera / camera

Ty: You just wap 2 small diamond for 1 recording camera.

 

 

Como preciso:

Ty: Hello | PLAYERNAME | I change 2 small diamonds for recording camera.

Tavarb: recording camera / camera

Ty: Do you want to trade 2 small diamonds for recording camera?

Tavarb: yes / no

(CASO YES) Ty: You just wap 2 small diamond for 1 recording camera.

(CASO NO) Ty: Ok, good bye.

(TIPO ESSE SRIPT) do Sweety Cyclops:

local node5 = keywordHandler:addKeyword({'ticket'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to trade a 50k for a ticket?'})
    node5:addChildKeyword({'yes'}, ticket, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true})

SCRIPT DO NPC DO MEU SERVIDOR:

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
 
local items = {
          item1 = {2145, 12330}, -- id do small diamond, id da recording camera
          item2 = {2145, 12330} -- id do small diamond, id da recording camera
}
local counts = {
          count1 = {2, 1}, -- 2 small diamonds por uma recording camera
          count2 = {2, 1} -- 2 small diamonds por uma recording camera
}
 
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, 'camera') then
                    if getPlayerItemCount(cid, items.item1[1]) >= counts.count1[1] then
                              doPlayerRemoveItem(cid, items.item1[1], counts.count1[1])
                              doPlayerAddItem(cid, items.item1[2], counts.count1[2])
                              selfSay('You just swap '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..' for '.. counts.count1[2] ..' '.. getItemNameById(items.item1[2]) ..'.', cid)
                    else
                              selfSay('You need '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..'.', cid)
                    end

          elseif msgcontains(msg, 'recording camera') then
                    if getPlayerItemCount(cid, items.item2[1]) >= counts.count2[1] then
                              doPlayerRemoveItem(cid, items.item2[1], counts.count2[1])
                              doPlayerAddItem(cid, items.item2[2], counts.count2[2])
                              selfSay('You just swap '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..' for '.. counts.count2[2] ..' '.. getItemNameById(items.item2[2]) ..'.', cid)
                    else
                              selfSay('You need '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..'.', cid)
                    end
          end
          return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Postado

Testa este código, se der algum erro poste ele

 

Spoiler

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
 
local items = {
    item1 = {2145, 12330}, -- id do small diamond, id da recording camera
    item2 = {2145, 12330} -- id do small diamond, id da recording camera
}
local counts = {
    count1 = {2, 1}, -- 2 small diamonds por uma recording camera
    count2 = {2, 1} -- 2 small diamonds por uma recording camera
}
 
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 talkState[cid] == 1 then
        if msgcontains(msg, 'yes') then
            if getPlayerItemCount(cid, items.item1[1]) >= counts.count1[1] then
                doPlayerRemoveItem(cid, items.item1[1], counts.count1[1])
                doPlayerAddItem(cid, items.item1[2], counts.count1[2])
                selfSay('You just swap '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..' for '.. counts.count1[2] ..' '.. getItemNameById(items.item1[2]) ..'.', cid)
            else
                selfSay('You need '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..'.', cid)
            end
        elseif msgcontains(msg, 'no') then
            selfSay('Ok, good bye.', cid)
        end
        return TRUE
    elseif talkState[cid] == 2 then
        if msgcontains(msg, 'yes') then
            if getPlayerItemCount(cid, items.item2[1]) >= counts.count2[1] then
                doPlayerRemoveItem(cid, items.item2[1], counts.count2[1])
                doPlayerAddItem(cid, items.item2[2], counts.count2[2])
                selfSay('You just swap '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..' for '.. counts.count2[2] ..' '.. getItemNameById(items.item2[2]) ..'.', cid)
            else
                selfSay('You need '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..'.', cid)
            end
        elseif msgcontains(msg, 'no') then
            selfSay('Ok, good bye.', cid)
        end
        return TRUE   
    end

    if msgcontains(msg, 'camera') then
        talkState[cid] = 1;
        selfSay('Do you want to trande '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..' for '.. counts.count1[2] ..' {'.. getItemNameById(items.item1[2]) ..'}?', cid)
    elseif msgcontains(msg, 'recording camera') then
        talkState[cid] = 2;
        selfSay('Do you want to trande '.. counts.count2[1] ..' '.. getItemNameById(items.item2[1]) ..' for '.. counts.count2[2] ..' {'.. getItemNameById(items.item2[2]) ..'}?', cid)
    end
    
    return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

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 520k

Informação Importante

Confirmação de Termo