Ir para conteúdo

Featured Replies

Postado

Quero um npc q troque uma boots of haste por uma soft boots

Mas so pode trocar uma vez por play...

Ajuda ae tk.....

Rep +

Resolvido por Frenesy

Ir para solução
  • Respostas 19
  • Visualizações 940
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • luanluciano93
    luanluciano93

    Não sei se você entende um pouco, e vai saber implementar o script e configura-lo, qualquer duvida poste aqui ...   local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(ke

  • É um NPC, que trocará itens com o player, ou seja, pedirá Item1 e dará o Item2, que poderá ser configurado no script. troka.lua local keywordHandler = KeywordHandler:new() local npcHandler = Np

  • @wesleyyy cuidado com double post amigo,caso queira acrescentar alguma coisa é só editar o ultimo comentario,não tem necessidade de criar mais um ! Leia as regras do fórum : http://www.tibiaking.com/

Postado

Não sei se você entende um pouco, e vai saber implementar o script e configura-lo, qualquer duvida poste aqui ...

 

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 change(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then return false end
    
	local config =
	{
		STORAGE = 85222,
		ITEM = {2160, 1},
		REWARD = {2160, 1}
	}
	
	if getPlayerStorageValue(cid, config.STORAGE) == 0 then
		if getPlayerItemCount(cid, config.ITEM[1]) >= config.ITEM[2] then
			if doPlayerRemoveItem(cid, config.ITEM[1], config.ITEM[2]) then
				npcHandler:say('Here is your item!', cid)
				setPlayerStorageValue(cid, config.STORAGE, 1)
				doPlayerAddItem(cid, config.REWARD[1], config.REWARD[2])
			end
		else
			npcHandler:say('You don\'t have these items!', cid)
		end
	else
		npcHandler:say('VocÊ já pegou seu item', cid)
	end
end

local node1 = keywordHandler:addKeyword({'change'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hum Humm! Welcume lil. Me can do unbroken but Big Ben want gold 5000 and Big Ben need a lil time to make it unbroken. Yes or no??'})
    node1:addChildKeyword({'yes'}, change, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true})
	
npcHandler:addModule(FocusModule:new())
Postado

É um NPC, que trocará itens com o player, ou seja, pedirá Item1 e dará o Item2, que poderá ser configurado no script.

troka.lua


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


-- Config --

local configs = {
    
    FirstItemId = 2455,
    FirstItemCount = 5,
    SecondItemId = 2321,
    SecondItemCount = 1,

    isQuest = "false",    
    questStorage = 17890,

    msgMeet = 'Você deseja trocar '..FirstItemCount .. ' '.. getItemName(FirstItemId) ..' por '.. SecondItemCount ..' '.. getItemName(SecondItemId) ..'?',
    msgQuestCompleted = "Você já fez essa quest.",
    msgQuestNotItem = "Voce não tem o item necessario.",

    }


function npcTroca(cid, message, keywords, parameters, node)

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

    if (configs.isQuest == "true") then
    if (getPlayerStorageValue(configs.questStorage) <= 0) then
        if (getItemCount(cid, configs.FirstItemId) == configs.FirstItemCount) then
            doRemoveItem(configs.FirstItemId, config.FirstItemCount)
            doPlayerAddItem(cid, configs.SecondItemId, configs.SecondItemCount)
        else
            return     doPlayerSendTextMessage(cid, 27, configs.msgQuestNotItem)
        end
    else
        return doPlayerSendTextMessage(cid, 27, configs.msgQuestCompleted)
    end
else
    if (getItemCount(cid, configs.FirstItemId) == configs.FirstItemCount) then
        doRemoveItem(configs.FirstItemId, config.FirstItemCount)
        doPlayerAddItem(cid, configs.SecondItemId, configs.SecondItemCount)
    else
        return     doPlayerSendTextMessage(cid, 27, configs.msgQuestNotItem)
    end    
end
end

itemTrade = keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = configs.msgMeet})
itemTrade:addChildKeyword({'yes'}, npcTroca, {})
itemTrade:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then.', reset = true})
        
npcHandler:addModule(FocusModule:new())

 

O código acima possui a acessibilidade de troca de IDs e Quantidades, para isso vá no CONFIGS e altere.

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

Postado
  • Autor

Obrigado macalo :)

Mais tarde eu testo e dou rep+

Agr to no cel..

Sobre leitura de script nao entendo muito

Pode mostra como configurar??

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