Postado Junho 20, 2014 11 anos Autor 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 local shopWindow = {} local moeda = 2145 -- [ID DA MOEDA] local t = { [2195] = {price = 5} -- [ID DO ITEM QUE SERÁ VENDIDO] = {QUANTO IRÁ CUSTAR} } local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) if t[item] and not doPlayerRemoveItem(cid, moeda, t[item].price) then selfSay("você não tem "..t[item].price.." "..getItemNameById(moeda), cid) else doPlayerAddItem(cid, item) selfSay("aqui está seu item!", cid) end return true end if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then for var, ret in pairs(t) do table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)}) end openShopWindow(cid, shopWindow, onBuy, onSell) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Junho 20, 2014 11 anos É só repetir a função, mudando o nome, e depois embaixo mudar o número do node, e chamar o nome da função ... Por exemplo: 1 - Crie a função ... function FUNÇÃO_NAME(cid, message, keywords, parameters, node)if(not npcHandler:isFocused(cid)) then return false endif getPlayerItemCount(cid,ITEM_ID) >= QUANTIDADE_ITEM thenif doPlayerRemoveItem(cid, ITEM_ID, QUANTIDADE_ITEM) thennpcHandler:say('Aqui esta seu item!', cid)doPlayerAddItem(cid, ITEM_ID_RECOMPENSA, QUANTIDADE_ITEM_RECOMPENSA)endelsenpcHandler:say('Voce nao tem diamond suficiente!', cid)endend Depois de criar a função crie as o node ... abaixo dessas 3 linhas do node1: local node1 = keywordHandler:addKeyword({'crystal coin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce quer trocar 50 diamonds por 100 crystal coins?? Yes or no??'}) node1:addChildKeyword({'yes'}, jestervip, {npcHandler = npcHandler, onlyFocus = true, reset = true}) node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok, volte quando quiser negociar!', reset = true}) Crie o node2 abaixo delas, tente ler o código, você irá add a msg falada e as resposta ai. local node2 = keywordHandler:addKeyword({'mensagem'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to trade a Dragon Shield and an Obsidian Lance for a Obsidian Knife?'}) node2:addChildKeyword({'yes'}, FUNÇÃO_NAME, {npcHandler = npcHandler, onlyFocus = true, reset = true}) node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true}) É só prestar atenção que tu consegue fazer, é bem simples ... qualquer dúvida pergunte! STYLLER OT 2022
Postado Junho 20, 2014 11 anos Autor @luan tou ligado mais essa script desse NPC ai pq quando falo trade é como se eu não tivesse o item? 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 local shopWindow = {} local moeda = 2145 -- [ID DA MOEDA] local t = { [2195] = {price = 5} -- [ID DO ITEM QUE SERÁ VENDIDO] = {QUANTO IRÁ CUSTAR} } local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) if t[item] and not doPlayerRemoveItem(cid, moeda, t[item].price) then selfSay("você não tem "..t[item].price.." "..getItemNameById(moeda), cid) else doPlayerAddItem(cid, item) selfSay("aqui está seu item!", cid) end return true end if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))then for var, ret in pairs(t) do table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)}) end openShopWindow(cid, shopWindow, onBuy, onSell) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Fevereiro 18, 2015 10 anos Ólar pessoal queria o npc de poketibia trocasse item por Diamond pelo trade exemplo óla amigo jogador, eu vendo items baratos para você,e so falar (trade) para ver as oferta! dai abria a loja do trade com os item pra vender so que aoinveis de vender por gold seria por diamonds tipo o npc mark so que por diamonds Tenta esse : "data/npc/diamondnpc.xml" : <?xml version="1.0"?> <npc name="Diamond NPC" script="data/npc/scripts/diamondnpc.lua" access="5" lookdir="2" walkinterval="0"> <health now="200" max="200" /> <look type="139" head="95" body="95" legs="95" feet="95" addons="3" /> <parameters> <parameter key="message_greet" value="Ola |PLAYERNAME|. posso trocar uns items por diamond? Diga {items}." /> </parameters> </npc> "data/npc/scripts/diamondnpc.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 -- STRIKE START -- function jestervip(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then return false end if getPlayerItemCount(cid,2145) >= 50 then if doPlayerRemoveItem(cid,2145,50) then npcHandler:say('Aqui esta seu item!', cid) doPlayerAddItem(cid,2160,100) end else npcHandler:say('Voce nao tem diamond suficiente!', cid) end end -- STRIKE END -- keywordHandler:addKeyword({'items'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Eu troco {crystal coin} por diamonds."}) local node1 = keywordHandler:addKeyword({'crystal coin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce quer trocar 50 diamonds por 100 crystal coins?? Yes or no??'}) node1:addChildKeyword({'yes'}, jestervip, {npcHandler = npcHandler, onlyFocus = true, reset = true}) node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok, volte quando quiser negociar!', reset = true}) npcHandler:addModule(FocusModule:new()) Ólar pessoal queria o npc de poketibia trocasse item por Diamond pelo trade exemplo óla amigo jogador, eu vendo items baratos para você,e so falar (trade) para ver as oferta! dai abria a loja do trade com os item pra vender so que aoinveis de vender por gold seria por diamonds tipo o npc mark so que por diamonds É só repetir a função, mudando o nome, e depois embaixo mudar o número do node, e chamar o nome da função ... Por exemplo: 1 - Crie a função ... function FUNÇÃO_NAME(cid, message, keywords, parameters, node) if(not npcHandler:isFocused(cid)) then return false end if getPlayerItemCount(cid,ITEM_ID) >= QUANTIDADE_ITEM then if doPlayerRemoveItem(cid, ITEM_ID, QUANTIDADE_ITEM) then npcHandler:say('Aqui esta seu item!', cid) doPlayerAddItem(cid, ITEM_ID_RECOMPENSA, QUANTIDADE_ITEM_RECOMPENSA) end else npcHandler:say('Voce nao tem diamond suficiente!', cid) end end Depois de criar a função crie as o node ... abaixo dessas 3 linhas do node1: local node1 = keywordHandler:addKeyword({'crystal coin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voce quer trocar 50 diamonds por 100 crystal coins?? Yes or no??'}) node1:addChildKeyword({'yes'}, jestervip, {npcHandler = npcHandler, onlyFocus = true, reset = true}) node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok, volte quando quiser negociar!', reset = true}) Crie o node2 abaixo delas, tente ler o código, você irá add a msg falada e as resposta ai. local node2 = keywordHandler:addKeyword({'mensagem'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to trade a Dragon Shield and an Obsidian Lance for a Obsidian Knife?'}) node2:addChildKeyword({'yes'}, FUNÇÃO_NAME, {npcHandler = npcHandler, onlyFocus = true, reset = true}) node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true}) É só prestar atenção que tu consegue fazer, é bem simples ... qualquer dúvida pergunte! Ólar pessoal queria o npc de poketibia trocasse item por Diamond pelo trade exemplo óla amigo jogador, eu vendo items baratos para você,e so falar (trade) para ver as oferta! dai abria a loja do trade com os item pra vender so que aoinveis de vender por gold seria por diamonds tipo o npc mark so que por diamonds
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.