Ir para conteúdo
  • Cadastre-se

Normal [AJUDA] 2 Scripts de trocas de itens


Posts Recomendados

Tipo o script ta funcionando, mas se o cara só tem um dos itens, tipo tem q ter skull helmet e 100 behe claws, se tiver um só ele remove, mas não entrega
Qm manja vai se ligar qnd ver o script
N tem como ver se ele tem o item em vez de ver se tirou o item dele? Help

   if msgcontains(msg, "change") then
      selfSay("You want to exchange 100 behemoth claws and 1 skull helmet for a damaged steel helmet?", cid)
      talkState[talkUser] = 1
   elseif msgcontains(msg, "yes") then
      if talkState[talkUser] == 1 then
         if doPlayerRemoveItem(cid, t.item[1], t.item[2]) and doPlayerRemoveItem(cid, t.segitem[1], t.segitem[2]) then
            doPlayerAddItem(cid, t.reward, 1)
            selfSay("Here it is.", cid)
            talkState[talkUser] = 0
         else
            selfSay("You don't have 100 behemoth claws and 1 skull helmet.", cid)
            talkState[talkUser] = 0
         end
      end

O msm vale pra o outro script que é troca de item, mas troca 2500 power bolts, alguem pode me ajudar? Não ta funcionando
local t = {
    item = {7636, 2500}, -- ID do item e quantidade necessária.
    reward = 5957 -- Item que irá ganhar.
}
 
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
    msg = msg:lower();
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

   if msgcontains(msg, "change") then
      selfSay("You want to exchange 2500 power bolts for a crossbow?", cid)
      talkState[talkUser] = 1
   elseif msgcontains(msg, "yes") then
      if talkState[talkUser] == 1 then
         if doPlayerRemoveItem(cid, t.item[1], t.item[2]) then
            doPlayerAddItem(cid, t.reward, 1)
            selfSay("Here it is.", cid)
            talkState[talkUser] = 0
         else
            selfSay("You don't have 2500 power bolts.", cid)
            talkState[talkUser] = 0
         end
      end
   elseif msgcontains(msg, "no") then
      if talkState[talkUser] == 1 then
         selfSay("Okay...")
         talkState[talkUser] = 0
      end
   end
end    

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Link para o post
Compartilhar em outros sites

Tente assim

 

 

Crossbow

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


function creatureSayCallback(cid, type, msg)
local player = Player(cid)


if (not npcHandler:isFocused(cid)) then
return false
end


if isInArray({"change", "bolt"}, msg:lower()) then
        npcHandler:say('Do you want to trade 2500 power bolts for crossbow?', cid)
        npcHandler.topic[cid] = 1 


elseif msgcontains(msg,'yes') and npcHandler.topic[cid] <= 4 and npcHandler.topic[cid] >= 1 then


local trade = {
{NeedItem = 7636, Ncount = 2500, GiveItem = 5957, Gcount = 1}, -- Crossbow
}


        if player:getItemCount(trade[npcHandler.topic[cid]].NeedItem) >= trade[npcHandler.topic[cid]].Ncount then
player:removeItem(trade[npcHandler.topic[cid]].NeedItem, trade[npcHandler.topic[cid]].Ncount)
player:addItem(trade[npcHandler.topic[cid]].GiveItem, trade[npcHandler.topic[cid]].Gcount)
return npcHandler:say(msg,'Here you are')
        else
            npcHandler:say('Sorry but you don\'t have the item', player)
        end


elseif msgcontains(msg,'no') and (npcHandler.topic[cid] >= 1 and npcHandler.topic[cid] <= 5) then
npcHandler:say(msg,'Ok then', player)
npcHandler.topic[cid] = 0
npcHandler:releaseFocus(cid)
end
return true
end


local function onTradeRequest(cid)
TradeRequest(cid, npcHandler, getTable(), BlueDjinn, 4)
end


npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 
você pode usar nos 2 casos, apenas mudar os ids o script é configurável. 
Editado por pedrook (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

tentei aqui e não consegui!

ta dando erro, nem ta abrindo o ot com eles, eles nem aparecem:

 

crossbow

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


function creatureSayCallback(cid, type, msg)
local player = Player(cid)


if (not npcHandler:isFocused(cid)) then
return false
end


if isInArray({"change", "bolt"}, msg:lower()) then
        npcHandler:say('Do you want to trade 2500 power bolts for my crossbow?', cid)
        npcHandler.topic[cid] = 1


elseif msgcontains(msg,'yes') and npcHandler.topic[cid] <= 4 and npcHandler.topic[cid] >= 1 then


local trade = {
    {NeedItem = 2547, Ncount = 2500, GiveItem = 5947, Gcount = 1}, -- Crossbow
}


        if player:getItemCount(trade[npcHandler.topic[cid]].NeedItem) >= trade[npcHandler.topic[cid]].Ncount then
player:removeItem(trade[npcHandler.topic[cid]].NeedItem, trade[npcHandler.topic[cid]].Ncount)
player:addItem(trade[npcHandler.topic[cid]].GiveItem, trade[npcHandler.topic[cid]].Gcount)
return npcHandler:say(msg,'Here you are')
        else
            npcHandler:say('Sorry but you don\'t have the item', player)
        end


elseif msgcontains(msg,'no') and (npcHandler.topic[cid] >= 1 and npcHandler.topic[cid] <= 5) then
npcHandler:say(msg,'Ok then', player)
npcHandler.topic[cid] = 0
npcHandler:releaseFocus(cid)
end
return true
end


local function onTradeRequest(cid)
TradeRequest(cid, npcHandler, getTable(), BlueDjinn, 4)
end


npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

helmet

local t = {
    item = {5930, 100}, -- ID do item e quantidade necessária.
    segitem = {5741, 1},
    reward = 5924 -- Item que irá ganhar.
}
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)
local player = Player(cid)


if (not npcHandler:isFocused(cid)) then
return false
end


if isInArray({"change"}, msg:lower()) then
        npcHandler:say('Do you want to trade 100 behemoth claws and 1 skull helmet for damaged steel helmet?', cid)
        npcHandler.topic[cid] = 1


elseif msgcontains(msg,'yes') and npcHandler.topic[cid] <= 4 and npcHandler.topic[cid] >= 1 then


local trade = {
    {NeedItem = 5930, Ncount = 100, segNeedItem = 5741, segNcount = 1, GiveItem = 5924, Gcount = 1},
}


        if player:getItemCount(trade[npcHandler.topic[cid]].NeedItem) >= trade[npcHandler.topic[cid]].Ncount and player:getItemCount(trade[npcHandler.topic[cid]].segNeedItem) >= trade[npcHandler.topic[cid]].segNcount then
            player:removeItem(trade[npcHandler.topic[cid]].NeedItem, trade[npcHandler.topic[cid]].Ncount)
            player:addItem(trade[npcHandler.topic[cid]].GiveItem, trade[npcHandler.topic[cid]].Gcount)
            return npcHandler:say(msg,'Here you are')
        else
            npcHandler:say('Sorry but you don\'t have the item', player)
        end


elseif msgcontains(msg,'no') and (npcHandler.topic[cid] >= 1 and npcHandler.topic[cid] <= 5) then
npcHandler:say(msg,'Ok then', player)
npcHandler.topic[cid] = 0
npcHandler:releaseFocus(cid)
end
return true
end


local function onTradeRequest(cid)
TradeRequest(cid, npcHandler, getTable(), BlueDjinn, 4)
end


npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

nobody know?

Link para o post
Compartilhar em outros sites
  • Sub-Admin

to confuso, fala pra mim que esses npcs fazem ? qual é a quatidade de itens pra troca correta ? não to entendendo nada "só sei que eles fazem trocas mais cade os ids dos itens pra troca por outro ?' ai fica foda

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

Link para o post
Compartilhar em outros sites
local t = {
    item = {7636, 2500}, -- ID do item e quantidade necessária.
    reward = 5957 -- Item que irá ganhar.
}

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
    msg = msg:lower();
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    
    if msgcontains(msg, "change") then
        selfSay("You want to exchange 2500 power bolts for a crossbow?", cid)
        talkState[talkUser] = 1
    elseif msgcontains(msg, "yes") then
        if talkState[talkUser] == 1 then
            if getPlayerItemCount(cid, t.item[1]) >= t.item[2] then
                doPlayerRemoveItem(cid, t.item[1], t.item[2])
                doPlayerAddItem(cid, t.reward, 1)
                selfSay("Here it is.", cid)
                talkState[talkUser] = 0
            else
                selfSay("You don't have 2500 power bolts.", cid)
                talkState[talkUser] = 0
            end
        end
    elseif msgcontains(msg, "no") then
        if talkState[talkUser] == 1 then
            selfSay("Okay...")
            talkState[talkUser] = 0
        end
    end
end 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Isso é um daqueles scripts chamados... Er... Feito por pessoas preguiçosas que não querem fazer a verificação direito.

if msgcontains(msg, "change") then
    selfSay("You want to exchange 100 behemoth claws and 1 skull helmet for a damaged steel helmet?", cid)
    talkState[talkUser] = 1
elseif msgcontains(msg, "yes") then
    if talkState[talkUser] == 1 then
        if getPlayerItemCount(cid, t.item[1]) >= t.item[2] and getPlayerItemCount(cid, t.segitem[1]) >= t.segitem[2] then
            doPlayerRemoveItem(cid, t.item[1], t.item[2])
            doPlayerRemoveItem(cid, t.segitem[1], t.segitem[2])
            doPlayerAddItem(cid, t.reward, 1)
            selfSay("Here it is.", cid)
            talkState[talkUser] = 0
        else
            selfSay("You don't have 100 behemoth claws and 1 skull helmet.", cid)
            talkState[talkUser] = 0
        end
    end

                              _
                          .-'` `}
                  _./)   /       }
                .'o   \ |       }
                '.___.'`.\    {`
                /`\_/  , `.    }                                      ME DA UMA NOZ!
                \=' .-'   _`\  {
                 `'`;/      `,  }
                    _\   @   ;  }
                   /__`;-...'--'

Cluck!

Link para o post
Compartilhar em outros sites

Pelo menos o Jobs tentou ajudar, em vez de ficar apontando o dedo e movendo os tópicos...

 

Não sei a função de fazer checagem sem remover o item... Alguém pelo menos tem algo parecido pra que eu possa ter uma base?


atualizado:

 

Erros:

RpNLNpt.png

 

Scripts:

elanecrossbowchange

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


function creatureSayCallback(cid, type, msg)
local player = Player(cid)


if (not npcHandler:isFocused(cid)) then
return false
end


if isInArray({"change", "bolt"}, msg:lower()) then
        npcHandler:say('Do you want to trade 2500 power bolts for my crossbow?', cid)
        npcHandler.topic[cid] = 1


elseif msgcontains(msg,'yes') and npcHandler.topic[cid] <= 4 and npcHandler.topic[cid] >= 1 then


local trade = {
    {NeedItem = 2547, Ncount = 2500, GiveItem = 5947, Gcount = 1}, -- Crossbow
}


        if player:getItemCount(trade[npcHandler.topic[cid]].NeedItem) >= trade[npcHandler.topic[cid]].Ncount then
player:removeItem(trade[npcHandler.topic[cid]].NeedItem, trade[npcHandler.topic[cid]].Ncount)
player:addItem(trade[npcHandler.topic[cid]].GiveItem, trade[npcHandler.topic[cid]].Gcount)
return npcHandler:say(msg,'Here you are')
        else
            npcHandler:say('Sorry but you don\'t have the item', player)
        end


elseif msgcontains(msg,'no') and (npcHandler.topic[cid] >= 1 and npcHandler.topic[cid] <= 5) then
npcHandler:say(msg,'Ok then', player)
npcHandler.topic[cid] = 0
npcHandler:releaseFocus(cid)
end
return true
end


local function onTradeRequest(cid)
TradeRequest(cid, npcHandler, getTable(), BlueDjinn, 4)
end


npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

gregdamagedsteelhelmet

local t = {
    item = {5930, 100}, -- ID do item e quantidade necessária.
    segitem = {5741, 1},
    reward = 5924 -- Item que irá ganhar.
}
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)
local player = Player(cid)


if (not npcHandler:isFocused(cid)) then
return false
end


if isInArray({"change"}, msg:lower()) then
        npcHandler:say('Do you want to trade 100 behemoth claws and 1 skull helmet for damaged steel helmet?', cid)
        npcHandler.topic[cid] = 1


elseif msgcontains(msg,'yes') and npcHandler.topic[cid] <= 4 and npcHandler.topic[cid] >= 1 then


local trade = {
    {NeedItem = 5930, Ncount = 100, segNeedItem = 5741, segNcount = 1, GiveItem = 5924, Gcount = 1},
}


        if player:getItemCount(trade[npcHandler.topic[cid]].NeedItem) >= trade[npcHandler.topic[cid]].Ncount and player:getItemCount(trade[npcHandler.topic[cid]].segNeedItem) >= trade[npcHandler.topic[cid]].segNcount then
            player:removeItem(trade[npcHandler.topic[cid]].NeedItem, trade[npcHandler.topic[cid]].Ncount)
            player:addItem(trade[npcHandler.topic[cid]].GiveItem, trade[npcHandler.topic[cid]].Gcount)
            return npcHandler:say(msg,'Here you are')
        else
            npcHandler:say('Sorry but you don\'t have the item', player)
        end


elseif msgcontains(msg,'no') and (npcHandler.topic[cid] >= 1 and npcHandler.topic[cid] <= 5) then
npcHandler:say(msg,'Ok then', player)
npcHandler.topic[cid] = 0
npcHandler:releaseFocus(cid)
end
return true
end


local function onTradeRequest(cid)
TradeRequest(cid, npcHandler, getTable(), BlueDjinn, 4)
end


npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
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.

  • Conteúdo Similar

    • Por Jaurez
      .
    • Por Cat
      Em alguns casos, o tibia 8.60 comum não abre de jeito nenhum no map editor, mesmo desmarcando check file signatures e configurando o path corretamente.
       
      Este é o client 8.60 adaptado para o Remere's Map Editor. Resolvi postar já que ele foi removido do site oficial do RME. (ficou apenas a versão para linux lá)
      Se estiver tendo problemas para abrir a versão 8.60, tente utilizar este.
                                                                                                                     
      Baixar o Tibia Client 8.60 que funciona no Remere’s Map Editor
      Essa versão do Tibia 8.60 client resolve o erro unsupported client version ou Could not locate tibia.dat and/or tibia.spr, please navigate to your tibia 8.60 installation folder.
       
      Downloads
      https://tibiaking.com/applications/core/interface/file/attachment.php?id=47333

      Scan: https://www.virustotal.com/gui/file/333e172ac49ba2028db9eb5889994509e7d2de28ebccfa428c04e86defbe15cc
       
    • Por danilo belato
      Fala Galera To Com um problema aki 
       
      quero exporta umas sprites de um server para colocar em outro 
       
      eu clico na sprites ai aparece tds a forma delas do lado de la >>
       
      ai eu clico nela e ponho a opiçao de export mais quando salvo a sprite ela n abri 
       
      aparece isso quando tento vê-la 
       
      visualização não disponível ( no formatos png e bitmap)
       
      Agora no formato idc fala que o paint n pode ler 
       
      me ajudem ae...
    • Por Vitor Bicaleto
      Galera to com o script do addon doll aqui, quando eu digito apenas "!addon" ele aparece assim: Digite novamente, algo está errado!"
      quando digito por exemplo: "!addon citizen" ele não funciona e não da nenhum erro
       
      mesma coisa acontece com o mount doll.. 
    • Por Ayron5
      Substitui uma stone no serve, deu tudo certo fora  esse  erro ajudem  Valendo  Rep+  Grato  

      Erro: data/actions/scripts/boost.lua:557: table index is nil
       [Warning - Event::loadScript] Cannot load script (data/actions/scripts/boost.lua)

      Script:
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo