Ir para conteúdo

Featured Replies

Postado

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())
  • Respostas 5
  • Visualizações 371
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Tente assim     Crossbow   você pode usar nos 2 casos, apenas mudar os ids o script é configurável. 

  • 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(k

Postado

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)

Postado
  • Autor

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?

Postado
  • Diretor

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

 

Postado
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!

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