Ir para conteúdo

(Resolvido)[PEDIDO] Npc que libera venda de items pra x storage

Featured Replies

  • Respostas 12
  • Visualizações 1.1k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Vamos lá :3   1- Vá em Data/Npc.. Crie um arquivo.xml e Nomeio de brutal.xml, Abra-o e coloque isso.. \/       2- Vá em Data/Npc/Scripts.. E crie um arquivo lua com o nome de brutalitens.l

Posted Images

Postado

Não sou muito bom com NPC mais testa ai;

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 = {2164, 2167, 2168, 2169, 2213, 2214, 2161, 2170, 2200, 2201} -- ID dos Itens
local nome = {'might ring', 'energy ring', 'life ring', 'time ring', 'dwarven ring', 'ring of healing', 'strange talisman', 'silver amulet', 'protection amulet', 'dragon necklace'}  -- Nome dos Itens
local valor = {2145, 25} -- 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])..'}, {'..getItemNameById(items[8])..'}, {'..getItemNameById(items[9])..'} e {'..getItemNameById(items[10])..'}.', 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
if getPlayerStorageValue(cid, 1038) == 1 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 permissao.', cid)
    talkState[talkUser] = 0
    end
   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
if getPlayerStorageValue(cid, 1038) == 1 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 permissao.', cid)
    talkState[talkUser] = 0
    end
   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
if getPlayerStorageValue(cid, 1038) == 1 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 permissao.', cid)
    talkState[talkUser] = 0
    end
   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
if getPlayerStorageValue(cid, 1038) == 1 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 permissao.', cid)
    talkState[talkUser] = 0
    end
   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
if getPlayerStorageValue(cid, 1038) == 1 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 permissao.', cid)
    talkState[talkUser] = 0
    end
   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
if getPlayerStorageValue(cid, 1038) == 1 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 permissao.', cid)
    talkState[talkUser] = 0
    end
   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
if getPlayerStorageValue(cid, 1038) == 1 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 permissao.', cid)
    talkState[talkUser] = 0
    end
   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
if getPlayerStorageValue(cid, 1038) == 1 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 permissao.', cid)
    talkState[talkUser] = 0
    end
   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
if getPlayerStorageValue(cid, 1038) == 1 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 permissao.', cid)
    talkState[talkUser] = 0
    end
   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
if getPlayerStorageValue(cid, 1038) == 1 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 permissao.', cid)
    talkState[talkUser] = 0
    end
   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())

Postado
  • Autor
  • Solução
local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 




-- OTServ event handling functions start 
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 
-- OTServ event handling functions end 


local shopModule = ShopModule:new() 
npcHandler:addModule(shopModule) 


function creatureSayCallback(cid, type, msg)
if getPlayerStorageValue(cid, 1038) == 1 then
npcHandler:say("No have money.")
else
npcHandler:say("Sorry not possible.")
  return false
end 


shopModule:addSellableItem({'might ring'}, 2164, 250, 'might ring') 
shopModule:addSellableItem({'energy ring'}, 2167, 100, 'energy ring') 
shopModule:addSellableItem({'life ring'}, 2168, 50, 'life ring') 
shopModule:addSellableItem({'time ring'}, 2169, 100, 'time ring') 
shopModule:addSellableItem({'dwarven ring'}, 2213, 100, 'dwarven ring')
shopModule:addSellableItem({'ring of healing'}, 2214, 100, 'ring of healing') 
shopModule:addSellableItem({'strange talisman'}, 2161, 30, 'strange talisman') 
shopModule:addSellableItem({'silver amulet'}, 2170, 50, 'silver amulet') 
shopModule:addSellableItem({'protection amulet'}, 2200, 100, 'protection amulet')  
shopModule:addSellableItem({'dragon necklace'}, 2201, 100, 'dragon necklace') 
shopModule:addSellableItem({'snakebite rod'}, 2182, 100, 'snakebite rod') 
shopModule:addSellableItem({'moonlight rod'}, 2186, 200, 'moonlight rod') 
shopModule:addSellableItem({'volcanic rod'}, 2185, 1000, 'volcanic rod') 
shopModule:addSellableItem({'quagmire rod'}, 2181, 2000, 'quagmire rod') 
shopModule:addSellableItem({'tempest rod'}, 2183, 3000, 'tempest rod') 
shopModule:addSellableItem({'ankh'}, 2193, 100, 'ankh') 
shopModule:addSellableItem({'mysterious fetish'}, 2194, 50, 'mysterious fetish') 




shopModule:addBuyableItem({'might ring'}, 2164, 5000, 'might ring') 
shopModule:addBuyableItem({'energy ring'}, 2167, 2000, 'energy ring') 
shopModule:addBuyableItem({'life ring'}, 2168, 900, 'life ring') 
shopModule:addBuyableItem({'time ring'}, 2169, 2000, 'time ring') 
shopModule:addBuyableItem({'dwarven ring'}, 2213, 2000, 'dwarven ring')
shopModule:addBuyableItem({'ring of healing'}, 2214, 2000, 'ring of healing') 
shopModule:addBuyableItem({'strange talisman'}, 2161, 100, 'strange talisman') 
shopModule:addBuyableItem({'silver amulet'}, 2170, 100, 'silver amulet')
shopModule:addBuyableItem({'protection amulet'}, 2200, 700, 'protection amulet')
shopModule:addBuyableItem({'dragon necklace'}, 2201, 1000, 'dragon necklace')
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 519.6k

Informação Importante

Confirmação de Termo