Postado Julho 29, 2018 6 anos se algum puder me ajudar preciso de um NPC que troque item mais diferente e que reaja a esse item . ex : eu tenho uma 'ice raper' falo com o npc "QUER FORTIFICAR SUA ICE RAPER ?" i ele troca , tem chance de perder tudo ou melhor a minha sword caso ganhe o npc vai dar o um sword um poco mais forte "Superior Ice raper" esses items editados ja existem . se tiver um npc que troca por item aleatorios tbm serve mais tem que ser de arma pra arma agradeço desde ja! 10 horas atrás, dersinho disse: se algum puder me ajudar preciso de um NPC que troque item mais diferente e que reaja a esse item . ex : eu tenho uma 'ice raper' falo com o npc "QUER FORTIFICAR SUA ICE RAPER ?" i ele troca , tem chance de perder tudo ou melhor a minha sword caso ganhe o npc vai dar o um sword um poco mais forte "Superior Ice raper" esses items editados ja existem . se tiver um npc que troca por item aleatorios tbm serve mais tem que ser de arma pra arma agradeço desde ja! consegui dar um geito arumei um npc que entrega os itens mas preciso colocar mais itens e colocar chance de o npc quebrar a arma chance de erro preciso colcar outras armas e mais itens a serem trocados quem puder me ajuda agradeço desde ja! Citar 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:lower()) end function onThink() npcHandler:onThink() end local talkState = {} function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if msgcontains(msg, "Demorage sword") then selfSay("Voce tem certeza que deseja fazer Forja ?", cid) talkState[talkUser] = 1 elseif (msgcontains(msg, "yes") and talkState[talkUser] == 1) and (getPlayerItemCount(cid, 2160) < 2) or (getPlayerItemCount(cid, 10558) < 2) then selfSay("Desculpe, voce precisa ter 30 jemas e 2 kk.", cid) talkState[talkUser] = 1 elseif (msgcontains(msg, "yes") and talkState[talkUser] == 1) and (getPlayerItemCount(cid, 2160) >= 2) and (getPlayerItemCount(cid, 10558) >= 2) then doPlayerRemoveItem(cid, 2160, 2) doPlayerRemoveItem(cid, 10558, 2) doPlayerAddEditedItem(cid, 103, 1) selfSay("Obrigado, Tome sua Fusion Armor !", cid) talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Editado Julho 29, 2018 6 anos por dersinho (veja o histórico de edições)
Postado Julho 30, 2018 6 anos Veja se você tem essas funções na lib, se não tiver as coloque! function getItemsFromList(items) local str = '' if table.maxn(items) > 0 then for i = 1, table.maxn(items) do str = str .. items[i][2] .. ' ' .. getItemNameById(items[i][1]) if i ~= table.maxn(items) then str = str .. ', ' end end end return str end function doRemoveItemsFromList(cid,items) local count = 0 if table.maxn(items) > 0 then for i = 1, table.maxn(items) do if getPlayerItemCount(cid,items[i][1]) >= items[i][2] then count = count + 1 end end end if count == table.maxn(items) then for i = 1, table.maxn(items) do doPlayerRemoveItem(cid,items[i][1],items[i][2]) end else return false end return true end ------------------------------- Data/npc Aldro Forjador.xml <?xml version="1.0"?> <npc name="Aldro Forjador" script="data/npc/scripts/forjar_itens.lua" walkinterval="50000" floorchange="0"> <health now="100" max="100"/> <look type="129" head="95" body="116" legs="121" feet="115" addons="3"/> <parameters> <parameter key="message_greet" value="Ola |PLAYERNAME|.Eu posso forjar alguns {itens} itens para voce!" /> </parameters> </npc> Data/npc/scripts forjar_itens.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 function doChangeWeapon(cid, message, keywords, parameters, node) -- by vodka if(not npcHandler:isFocused(cid)) then return false end if (isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then if(parameters.level ~= nil and getPlayerLevel(cid) < parameters.level) then npcHandler:say('Desculpe, voce precisa ter level ' .. parameters.level .. ' ou mais para forjar este item.', cid) elseif not doRemoveItemsFromList(cid,parameters.items) then npcHandler:say('Desculpe, mas voce não tem '..getItemsFromList(parameters.items)..' para forjar este item!', cid) else local r = parameters.chance local v = math.random(1, 100) if r > v then npcHandler:say('Sucesso! Aqui esta seu item.', cid) doPlayerAddItem(cid,parameters.give,1) doSendMagicEffect(getPlayerPosition(cid), math.random(28,30)) else npcHandler:say('Desculpe, mas seu item falho na forja!', cid) doSendMagicEffect(getPlayerPosition(cid), 2) end npcHandler:resetNpc() end else npcHandler:say('Desculpe, mas apenas forjo esse item para jogadores premium account.', cid) end npcHandler:resetNpc() return true end local list = { {"demon armor", items = {{2466,3},{2160,2}}, item_give = 2494, chance = 30, level = 10, premium = false}, {"solar axe", items = {{2432,10},{2160,5},{8924,1}}, item_give = 8925, chance = 50, level = 15, premium = true}, {"broadsword", items = {{2376,10},{2160,2}}, item_give = 2413, chance = 90, level = 15, premium = false}, {"magic longsword", items = {{2400,5},{2393,5},{2160,5}}, item_give = 2390, chance = 90, level = 25, premium = false}, {"ice rapier", items = {{7449,2},{2160,5}}, item_give = 2396, chance = 10, level = 25, premium = false}, {"itens", text = "Eu posso te forjar alguns itens como: {demon armor},{solar axe},{broadsword} ou {magic longsword}!"} } for i = 1, #list do local get = list[i] if type(get.items) == "table" then local node = keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Para forjar o item " .. get[1] .. " é necessário "..getItemsFromList(get.items)..". Você tem tudo isso para me dar?"}) node:addChildKeyword({"yes"}, doChangeWeapon, {items = get.items, give = get.item_give, chance = get.chance, level = get.level, premium = get.premium}) node:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "tudo bem entao.", reset = true}) else keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = get.text}) end end mounts = nil npcHandler:addModule(FocusModule:new()) explicando: na tabela "list" existe essa linha por exemplo: {"demon armor", items = {{2466,3},{2160,2}}, item_give = 2494, chance = 30, level = 10, premium = false}, "nome do item que vai ser trocado" ------------------------------------- items = {} -- tabela de itens que vai ser preciso dar ao npc pra trocar de itens coloque assim -- > {{itemid,quantidade}} para mais de um item -- > {{itemid, quantidade},{itemid, quantidade}} exemplo que eu botei: items = {{2466,3},{2160,2}} -- 3 golden armor e 2 crystal coin --------------------------------------------------- item_give -- aqui é o id final do item que vai ser dado ao jogador ----------------------------------------------- chance -- é a chance de a forja dar certo, quanto maior a chance maior a chance de dar certoa forja do iten ------------------------------------ level -- é para forjar o item ---------------------------- premium -- se precisa ser premium pra forjar o itens em questao, true ou false. [*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*] DISCORD: vodkart#6090
Postado Julho 31, 2018 6 anos Autor pra começa obrigado mais e asim eu criei uns itens mais so com a Sprite >>doPlayerAddEditedItem(cid, 103, 1) preciso desse comando pra add o item no player % ex : Demonrage sword 47 atk vai troca por Superior Demorage Sword 60 atk que no caso e o ide 101 os itens ja existem o npc troca o iten pelo outro item mais nao tem chance de quebra mais uma duvida pra que serve aquela lib eu procuro ela na 000-constant ? Editado Julho 31, 2018 6 anos por dersinho (veja o histórico de edições)
Postado Julho 31, 2018 6 anos a lib você joga na na pasta lib e abre o 050-function.lua e joga la no final mesmo;. sobre o npc, troque esta linha doPlayerAddItem(cid,parameters.give,1) por doPlayerAddEditedItem(cid, parameters.give, 1) isso adiciona o item editado ne? o 103 é o id do item editado? [*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*] DISCORD: vodkart#6090
Postado Julho 31, 2018 6 anos Autor deu erro na lib mais a lib e pro npc ? o erro ta aki vlw por ajuda velho! Spoiler
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.