panda12milo 2 Postado Maio 29, 2008 Share Postado Maio 29, 2008 (editado) Vamos começar: Porque fazer um NPC que compra joias? Se você como eu, gosta de um ot com um sistema de negociação, exemplo, os players estão vendendo o item da caçada, é muito bom, por que aumenta a frequencia da negociação Para começar recomendo ter Sistema de Mineração, aqui no XTibia tem um monte, é só você ir la e escolher E também recomendo uma Cidade de Dwarfs, e la o unico lugar para ter esse NPC Começando Vá em Data/NPC, copie um arquivo xml renomeie para Jack e dentro coloque: <?xml version="1.0"?> <npc name="Jack" script="data/npc/scripts/joias.lua" access="3" lookdir="1" autowalk="100" speed="200"> <health now="100" max="100"/> <look type="69" head="57" body="59" legs="40" feet="76" addons="2" corpse="2212"/> <parameters/> </npc> Explicando: <npc name="Jack"... Nome do NPC, mude a vontade... script="data/npc/scripts/joais.lua"...Nome do script aonde o NPC reconhece os comandos, não mude access="3"...É o acesso do NPC, caso você coloque menos de 3 os players poderão atacar, recomendo 3. speed="200">...Velociadade do NPC <Look type="69"...Look do NPC, a "roupa" dele, no caso 69 é roupa de Dwarf, mas mude ao seu gosto Agora que ja foi explicado vamos ao Script Vá em data/npc/scripts copiei um arquivo do tipo LUA, renomeie para joias e dentro coloque: -----By MatheusMSN----- target = 0 following = false attacking = false focus = 0 itemid = 0 count = 0 payback = 0 talkcount = 0 talk_start = 0 function onThingMove(creature, thing, oldpos, oldstackpos) end function onCreatureAppear(creature) end function onCreatureDisappear(id) if id == target then target = 0 attacking = false selfAttackCreature(0) following = false end focus = 0 itemid = 0 end function onCreatureTurn(creature) end function onCreatureSay(cid, type, msg) msg = string.lower(msg) dist = getDistanceToCreature(cid) if dist >= 8 then return end talk_start = os.clock() if string.find(msg, 'hi') and string.len(msg) == 2 then if focus == cid then selfSay('Ja to falando contigo') else if focus > 0 then selfSay('Estou ocupado') end end if(focus == 0) then selfSay('Olá , compro joias, ' .. creatureGetName(cid) .. '.') focus = cid end talk_start = os.clock() end if string.find(msg, '(%a*)sell black pearl(%a*)') and focus == cid then selfSay('Do you want to sell a Black Pearl for 280gps?') talk_start = os.clock() price = 280 talkcount = 2 itemid = 2144 count = 1 return end if string.find(msg, '(%a*)sell white pearl(%a*)') and focus == cid then selfSay('Do you want to sell a White Pearl for 280gps?') talk_start = os.clock() price = 280 talkcount = 2 itemid = 2143 count = 1 return end if string.find(msg, '(%a*)sell small diamond(%a*)') and focus == cid then selfSay('Do you want to sell a Small Diamond for 225gps?') talk_start = os.clock() price = 225 talkcount = 2 itemid = 2145 count = 1 return end if string.find(msg, '(%a*)sell small sapphire(%a*)') and focus == cid then selfSay('Do you want to sell a Small Sapphire for 200gps?') talk_start = os.clock() price = 200 talkcount = 2 itemid = 2146 count = 1 return end if string.find(msg, '(%a*)sell small ruby(%a*)') and focus == cid then selfSay('Do you want to sell a Small Ruby for 300gps?') talk_start = os.clock() price = 300 talkcount = 2 itemid = 2147 count = 1 return end if string.find(msg, '(%a*)sell small smerald(%a*)') and focus == cid then selfSay('Do you want to sell a Small Smerald for 180gps?') talk_start = os.clock() price = 180 talkcount = 2 itemid = 2149 count = 1 return end if string.find(msg, '(%a*)sell small amethyst(%a*)') and focus == cid then selfSay('Do you want to sell a Small Amethyst for 200gps?') talk_start = os.clock() price = 200 talkcount = 2 itemid = 2150 count = 1 return end if string.find(msg, '(%a*)sell gold nugget(%a*)') and focus == cid then selfSay('WoW, you have a Gold Nugget? I return 500gps.') talk_start = os.clock() price = 500 talkcount = 2 itemid = 2157 count = 1 return end if string.find(msg, '(%a*)sell some golden fruits(%a*)') and focus == cid then selfSay('Wow, you have Some Golden Fruits for 1000gps?') talk_start = os.clock() price = 1000 talkcount = 2 itemid = 2137 count = 1 return end if string.find(msg, '(%a*)yes(%a*)') and cid == focus then if talkcount == 1 then buy(cid,itemid,count,price) talk_start = os.clock() end if talkcount == 2 then sell(cid,itemid,count,price) talk_start = os.clock() end if string.find(msg, '(%a*)bye(%a*)') and focus == cid and getDistanceToCreature(cid) < 3 then selfSay('Adeus') focus = 0 itemid = 0 talk_start = 0 talkcount = 0 end end function onCreatureChangeOutfit(creature) end function onThink() if (os.clock() - talk_start) > 30 then if focus > 0 then selfSay('Até logo...') talkcount = 0 end focus = 0 itemid = 0 talk_start = 0 end if focus == 0 then cx, cy, cz = selfGetPosition() randmove = math.random(1,50) if randmove == 1 then nx = cx + 1 end if randmove == 2 then nx = cx - 1 end if randmove == 3 then ny = cy + 1 end if randmove == 4 then ny = cy - 1 end if randmove >= 5 then nx = cx ny = cy end moveToPosition(nx, ny, cz) --summons = 30 --summons2 = 30 end end end Pronta agora teste. Primeiramente já havia um NPC comprador de jóias no XTibia, ele porém, no meu OT, não funcionava, a dona do primeiro se chama UpKing Lembre-se, eu só copiei a idéia, mas não copiei preços e ids. Editado Maio 29, 2008 por MatheusMSN Link para o comentário Compartilhar em outros sites More sharing options...
cobraot 0 Postado Junho 4, 2008 Share Postado Junho 4, 2008 ae valeu ^^ estava precisando de um Link para o comentário Compartilhar em outros sites More sharing options...
Abobalhado 0 Postado Junho 6, 2008 Share Postado Junho 6, 2008 Excelente, Ele funciona o The Forgotten Sv? (TFS) Link para o comentário Compartilhar em outros sites More sharing options...
fahel 1 Postado Junho 6, 2008 Share Postado Junho 6, 2008 Legal Link para o comentário Compartilhar em outros sites More sharing options...
bonazza 7 Postado Junho 7, 2008 Share Postado Junho 7, 2008 mto bom mano. ja botei no meu ot... Link para o comentário Compartilhar em outros sites More sharing options...
panda12milo 2 Postado Junho 12, 2008 Autor Share Postado Junho 12, 2008 Excelente,Ele funciona o The Forgotten Sv? (TFS) Não tenho certeza, eu só uso um. Obrigado pelos comentários e pelos elogios, para aqueles que veem, copiam e etc. e nem comentam: Comentar não mata E para quem copiou sem postar os créditos, não ligo, nem todos sabem fazer Scripts de NPC, é meio dificil, eu compreendo. Se quiserem copiar sem postar os créditos tudo bem Se quiserem copiar e editar e não postar os créditos tudo bem Mas pelo menos comenta Link para o comentário Compartilhar em outros sites More sharing options...
BillyBola 1 Postado Junho 12, 2008 Share Postado Junho 12, 2008 rokzin espero que de te mais nps ou so esse??? Link para o comentário Compartilhar em outros sites More sharing options...
panda12milo 2 Postado Junho 14, 2008 Autor Share Postado Junho 14, 2008 rokzin espero que de te mais nps ou so esse??? Breve colocarei novos NPCS :smile_positivo: Link para o comentário Compartilhar em outros sites More sharing options...
MarioxSenderos 0 Postado Junho 26, 2008 Share Postado Junho 26, 2008 MT BOM .. ME AJUDO MT .. MAS PARA KEM EH NOVO E SABE POCO VC PRECISA IR NA PASTA DO SEU MAP EDITOR E IR EM CREATURES,EDITAR E NA PARTE DOS NPCS COLOKE ISSO <creature looktype="69" name="Joalheiro" head="57" body="59" legs="40" feet="76" type="npc"/> FLWS.. ESPERO TER AJUDADO :smile_positivo: Link para o comentário Compartilhar em outros sites More sharing options...
Racast 0 Postado Julho 10, 2008 Share Postado Julho 10, 2008 Fico bom, o unico ruim desse npc é q ele não compra joias juntas exemplo:se um cara for vender 100 small sapphires ele vai ter q ficar falando sell small saphire sell small saphire sell small saphire sell small saphire sell small saphire sell small saphire sell small saphire...(São 94 vezes sell small saphire depois do ...) Link para o comentário Compartilhar em outros sites More sharing options...
Posts Recomendados