mylorc 0 Postado Outubro 18, 2013 Share Postado Outubro 18, 2013 Olá galera,estou precisando de um npc que venda donate itens no meu otserv,porém ele vendera por scarab coins. Alguém pode me ajudar com isso? Se tiver um script pronto poderia postar e me dar uma esplicadinha? Agradeço! Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/ Compartilhar em outros sites More sharing options...
0 markindoot 46 Postado Outubro 18, 2013 Share Postado Outubro 18, 2013 Isso é bem simples, pegue um NPC comun que vende aol, acrescente os items e mude o ID do item que o NPC (ao inveiz de ser Money) aceita, no seu caso é o Scarab Coins ae achei esse pra voce. local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)local talkState = {}function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) endfunction onThink() npcHandler:onThink() endfunction creatureSayCallback(cid, type, msg)if(not npcHandler:isFocused(cid)) thenreturn falseendlocal talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cidlocal shopWindow = {}local moeda = 9020 -- ID da moedalocal t = {[2195] = {price = 15}, -- [ITEM ID PARA VENDER] = {QNTO CUSTARÁ}[2493] = {price = 25},[2361] = {price = 30},[8851] = {price = 20},[8925] = {price = 30},[2640] = {price = 50},[2494] = {price = 100},[9932] = {price = 50},[2472] = {price = 70},[8931] = {price = 100}}local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)if t[item] and not doPlayerRemoveItem(cid, moeda, t[item].price) thenselfSay("you dont have"..t[item].price.." "..getItemNameById(moeda), cid)elsedoPlayerAddItem(cid, item)selfSay("Here your item!", cid)endreturn trueendif (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))thenfor var, ret in pairs(t) dotable.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)})endopenShopWindow(cid, shopWindow, onBuy, onSell)endreturn trueendnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new()) Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1573636 Compartilhar em outros sites More sharing options...
0 JonatasLucasf 60 Postado Outubro 18, 2013 Share Postado Outubro 18, 2013 acho que duvida sanada. Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1573648 Compartilhar em outros sites More sharing options...
0 mylorc 0 Postado Outubro 18, 2013 Autor Share Postado Outubro 18, 2013 Não esta dando certo,coloquei 6 itens no npc e esta aparecendo apenas um,e ainda estar pelo dinheiro do jogo. Estou postando o script aqui para que você possa olhar,caso esteja algo errado por favor ajude-me: -> XML <?xml version="1.0" encoding="UTF-8"?> <npc name="Equip Seller" script="data/npc/scripts/donate.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="142" head="57" body="59" legs="40" feet="76" addons="2"/> <parameters> <parameter key="module_shop" value="6"/> <parameter key="shop_buyable" value="shield world war,2540,20"/> <parameter key="shop_buyable" value="armor world war,2651,20"/> <parameter key="shop_buyable" value="helmet world war,2663,20"/> <parameter key="shop_buyable" value="wand world war,7430,20"/> <parameter key="shop_buyable" value="boots world war,7892,20"/> <parameter key="shop_buyable" value="legs world war,9928,20"/> </parameters> </npc> -> LUA 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 = 2159 local t = { [2540] = {price = 20}, [2651] = {price = 20}, [2663] = {price = 20}, [7430] = {price = 20}, [7892] = {price = 20}, [9928] = {price = 20}, } local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) if t[item] and not doPlayerRemoveItem(cid, moeda, t[item].price) then selfSay("you dont have"..t[item].price.." "..getItemNameById(moeda), cid) else doPlayerAddItem(cid, item) selfSay("Here your 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()) Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1573651 Compartilhar em outros sites More sharing options...
0 markindoot 46 Postado Outubro 18, 2013 Share Postado Outubro 18, 2013 xml? minha criança, issu é em NPC/Scripts e o numero do scarab coin é 3440, troca la o local moeda = 2159 <- (3440) e se o script já vende, retira o buyable e ve no que da, se continuar me manda ss do npc em trade com voce Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1573660 Compartilhar em outros sites More sharing options...
0 mylorc 0 Postado Outubro 18, 2013 Autor Share Postado Outubro 18, 2013 Agora esta aparecendo os itens no npc ,porem o dinheiro de compra ainda não é o scarab coin,e sim no meu ot o id é 2159. Você poderia ver os lugares que troca o id para mim? Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1573668 Compartilhar em outros sites More sharing options...
0 markindoot 46 Postado Outubro 18, 2013 Share Postado Outubro 18, 2013 Você pode postar uma ss? com o trade aberto e com 1kk na bag e mostrando no npc pra ver oq ele ta aceitando e não. Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1573675 Compartilhar em outros sites More sharing options...
0 mylorc 0 Postado Outubro 18, 2013 Autor Share Postado Outubro 18, 2013 (editado) Ai cara estou colocando o print do npc no jogo como que ta. Obs: os itens estão editados,as bolinhas meio douradas são os scarabs coins,que também foi editado. Editado Outubro 18, 2013 por mylorc Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1573679 Compartilhar em outros sites More sharing options...
0 markindoot 46 Postado Outubro 18, 2013 Share Postado Outubro 18, 2013 (editado) Show de bola o servidor eim... voltando: tenta esse aqui local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)local talkState = {}function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) endfunction onThink() npcHandler:onThink() endfunction creatureSayCallback(cid, type, msg)if(not npcHandler:isFocused(cid)) then return falseendlocal talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid-- Conversa Jogador/NPCif(msgcontains(msg, 'list')) then selfSay('Eu vendo {Vip Helmet }, {Vip Armor}.', cid) elseif(msgcontains(msg, 'Vip Helmet')) then selfSay('Voc\ê quer comprar Vip Helmet por 20 moedas de ouro?', cid) talkState[talkUser] = 1 elseif(msgcontains(msg, 'Vip Armor')) then selfSay('Voc\ê quer comprar Vip Armor por 100 moedas de ouro?', cid) talkState[talkUser] = 2-- Confirmação da Compra elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if(doPlayerRemoveItem(cid, 2159, 20) == true) then selfSay('Obrigado por comprar!', cid) doPlayerAddItem(cid, xxxx, 1) talkState[talkUser] = 0 else selfSay('Voc\ê n\ão tem 20 moedas de ouro', cid) talkState[talkUser] = 0 end elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then if(doPlayerRemoveItem(cid, 2159, 100) == true) then selfSay('Obrigado por comprar!', cid) doPlayerAddItem(cid, xxxx, 1) talkState[talkUser] = 0 else selfSay('Voc\ê n\ão tem 100 moedas de ouro', cid) talkState[talkUser] = 0 end endend npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new()) sanada? REP+ porfavor e reportar para ser movido! Editado Outubro 18, 2013 por markindoot Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1573690 Compartilhar em outros sites More sharing options...
0 mylorc 0 Postado Outubro 18, 2013 Autor Share Postado Outubro 18, 2013 Obrigado. Voltando ao assunto,também não deu certo,o script anterior:pode haver alguma coisa errada,um nome por exemplo,pois não há o id de outra moeda e mesmo assim aparece,faz uma ideia do que pode ser? Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1573702 Compartilhar em outros sites More sharing options...
0 markindoot 46 Postado Outubro 18, 2013 Share Postado Outubro 18, 2013 nesse que lhe passei deu oq? vou dar uma olhada no script anterior e vejo oq posso fazer 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 = 2159 local t = { [2540] = {price = 20}, [2651] = {price = 20}, [2663] = {price = 20}, [7430] = {price = 20}, [7892] = {price = 20}, [9928] = {price = 20}, } local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) if t[item] and not doPlayerRemoveItem(cid, 2159, t[item].price) then selfSay("you dont have"..t[item].price.." "..getItemNameById(2159), cid) else doPlayerAddItem(cid, item) selfSay("Here your 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()) ve se vai esse, vou chegar em casa e vou criar 1 npc para testar antes de ficar lhe mandando ok? é que tou no trampo e n tenho o tibia e pior ainda 1 otserv, entao 16:30 eu chego e jogo até... Abraço! Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1573708 Compartilhar em outros sites More sharing options...
0 mylorc 0 Postado Outubro 18, 2013 Autor Share Postado Outubro 18, 2013 Ok,obrigado. O anterior eu falo trade e ele não abre a barra ou nem se quer responde. O outro que me passou primeiro realmente parece bom,só que falta trocar o scarab coin pelo iten. Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1573719 Compartilhar em outros sites More sharing options...
0 markindoot 46 Postado Outubro 19, 2013 Share Postado Outubro 19, 2013 tenta esse npc, ele é um NPC de troca, ele troca Queijo por items, troque o ID do queiro pelo Scarab Coins e o item que o NPC dará ao player pelo seu shop.-- NPC de troca - By Conde Sapolocal focus = 0local talk_start = 0local target = 0local following = falselocal attacking = falselocal addon_state = 0function onThingMove(creature, thing, oldpos, oldstackpos)endfunction onCreatureAppear(creature)endfunction onCreatureDisappear(cid, pos) if focus == cid then selfSay('Good bye then.') focus = 0 talk_start = 0 endendfunction onCreatureTurn(creature)endfunction msgcontains(txt, str) return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))endfunction onCreatureSay(cid, type, msg) msg = string.lower(msg) if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then selfSay('Olá ' .. getCreatureName(cid) .. '... Eu daria tudo por alguns queijos... Você tem 5 sobrando aí? Eu posso te dar meu escudo em troca!') focus = cid talk_start = os.clock() elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.') elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'queijo') or msgcontains(msg, 'escudo') then if doPlayerRemoveItem(cid,2696,5) == 0 then selfSay('Eu disse 5 QUEIJOS!') addon_state = 0 else selfSay('Obrigado, muito mesmo! Tome, isto pode ser útil para você!') doPlayerAddItem(cid, 2512, 1) talk_start = 0 end elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then selfSay('Good bye, ' .. getCreatureName(cid) .. '! Come back soon..') focus = 0 talk_start = 0 end endendfunction onCreatureChangeOutfit(creature)endfunction onThink() doNpcSetCreatureFocus(focus) if (os.clock() - talk_start) > 30 then if focus > 0 then selfSay('Next Please...') end focus = 0 end if focus ~= 0 then if getDistanceToCreature(focus) > 5 then selfSay('Good bye then.') focus = 0 end endend em NPC <?xml version="1.0"?> <npc name="Taxijab" script="data/npc/scripts/Cheese.lua" access="3" lookdir="1" autowalk="200" speed="200"> <health now="1" max="1"/> <look type="120" head="38" body="79" legs="107" feet="114"/></npc> Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1574131 Compartilhar em outros sites More sharing options...
0 mylorc 0 Postado Outubro 19, 2013 Autor Share Postado Outubro 19, 2013 É realmente troca,porém quando estou sem o scarab coins ele ainda da o item,no caso item gratis. Sabe consertar esse ou arrumar outro? Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1574176 Compartilhar em outros sites More sharing options...
0 ScythePhantom 83 Postado Outubro 19, 2013 Share Postado Outubro 19, 2013 Tente esse: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)local talkState = {}function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) endfunction onThink() npcHandler:onThink() endfunction creatureSayCallback(cid, type, msg)if(not npcHandler:isFocused(cid)) thenreturn falseendlocal talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cidlocal msg = string.lower(msg)local moeda = 9020local t = { ["boots of haste"] = {15, 2195}, -- ["nome do item"] = {quanto vai custar, id do tem que sera vendido} ["demon helmet"] = {25, 2493}, ["frozen starlight"] = {30, 2361}, ["royal crossbow"] = {20, 8851}, ["solar axe"] = {30, 8925}, ["soft boots"] = {50, 2640}, ["demon armor"] = {100, 2494}, ["firewalker boots"] = {50, 9932}, ["magic plate armor"] = {70, 2472}, ["flame blade"] = {100, 8931} }if (msgcontains(msg, 'trade') or msgcontains(msg, 'TRADE'))thenlocal str = ""str = str .. "Eu vendo estes items: "for name, pos in pairs(t) dostr = str.." {"..name.."} = "..pos[1].." Moedas /"endstr = str .. "."npcHandler:say(str, cid)elseif t[msg] then if doPlayerRemoveItem(cid,moeda,t[msg][1]) then doPlayerAddItem(cid,t[msg][2],1) npcHandler:say("Aqui está seu ".. getItemNameById(t[msg][2]) .."!", cid) else npcHandler:say("você não tem "..t[msg][1].." ".. getItemNameById(moeda), cid) endendreturn TRUEendnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Créditos: Vodkart Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1574179 Compartilhar em outros sites More sharing options...
0 mylorc 0 Postado Outubro 20, 2013 Autor Share Postado Outubro 20, 2013 Perfeito,obrigado. Estarei dando +rep aos 2 por ter me ajudado. Abraço. Link para o comentário https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/#findComment-1574212 Compartilhar em outros sites More sharing options...
Pergunta
mylorc 0
Olá galera,estou precisando de um npc que venda donate itens no meu otserv,porém ele vendera por scarab coins.
Alguém pode me ajudar com isso? Se tiver um script pronto poderia postar e me dar uma esplicadinha?
Agradeço!
Link para o comentário
https://xtibia.com/forum/topic/222825-npc-que-venda-donate-itens/Compartilhar em outros sites
17 respostass a esta questão
Posts Recomendados