Queria um npc que comprasse todo tipow de Diamantes
Red Gem
Yellow Gem
Small Shappire
essas coisa esses diamantes
se ja tiver algum poderia me mandar o link? obg
Queria um npc que comprasse todo tipow de Diamantes
Red Gem
Yellow Gem
Small Shappire
essas coisa esses diamantes
se ja tiver algum poderia me mandar o link? obg
Olá amigo!
Ai vai o código do NPC, espero que te ajude.
local focus = 0local talk_start = 0
local target = 0
local following = false
local attacking = false
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
focus = 0
talk_start = 0
end
end
function onCreatureTurn(creature)
end
function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
-- greeting phrase
if string.find(msg, '(%a*)hi(%a*)') and focus == 0 and string.len(msg) == 2 and getDistanceToCreature(cid) < 4 then
selfSay('Oi ' .. creatureGetName(cid) .. '! Eu compro as seguintes joias:Black Pearl , White Pearl , Small Amethyst , Small Emerald ,Small Ruby,Small Diamons,Small Sapphire.')
selfSay('Diga info para saber informações sobre o npc')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')
elseif focus == cid then
talk_start = os.clock()
-- Mensages:
buy_error = 'Sorry, you dont have enough money.'
buy_ok = 'Here you are.'
buy_no = 'Ok. Maybe another time.'
--
sell_error = 'Sorry, you dont have that item.'
sell_ok = 'Thanks for this item.'
sell_no = 'Ok. Maybe another time.'
--
-- Joias
if msgcontains(msg, 'sell') and msgcontains(msg, 'small diamond') or msgcontains(msg, 'small diamonds') then
bs,itemid,count,subtype,price,iscountable,article,name,plural = 'sell',2145,getCountNumber(msg),1,300,1,'a','small diamond','small diamonds'
sendMsgBuySell(cid,itemid,count,price,article,name,plural,bs)
talk_state = 786
elseif msgcontains(msg, 'sell') and msgcontains(msg, 'white pearl') or msgcontains(msg, 'white pearls') then
bs,itemid,count,subtype,price,iscountable,article,name,plural = 'sell',2143,getCountNumber(msg),1,160,1,'a','white pearl','white pearls'
sendMsgBuySell(cid,itemid,count,price,article,name,plural,bs)
talk_state = 786
elseif msgcontains(msg, 'sell') and (msgcontains(msg, 'small emerald') or msgcontains(msg, 'small emerald')) then
bs,itemid,count,subtype,price,iscountable,article,name,plural = 'sell',2149,getCountNumber(msg),1,500,1,'a','small emerald','small emeralds'
sendMsgBuySell(cid,itemid,count,price,article,name,plural,bs)
talk_state = 786
elseif msgcontains(msg, 'sell') and msgcontains(msg, 'small amethyst') or msgcontains(msg, 'small amethysts') then
bs,itemid,count,subtype,price,iscountable,article,name,plural = 'sell',2150,getCountNumber(msg),1,400,1,'a','small amethyst','small amethysts'
sendMsgBuySell(cid,itemid,count,price,article,name,plural,bs)
talk_state = 786
elseif msgcontains(msg, 'sell') and msgcontains(msg, 'small sapphire') or msgcontains(msg, 'small sapphires') then
bs,itemid,count,subtype,price,iscountable,article,name,plural = 'sell',2146,getCountNumber(msg),1,300,1,'a','small sapphire','small sapphires'
sendMsgBuySell(cid,itemid,count,price,article,name,plural,bs)
talk_state = 786
elseif msgcontains(msg, 'sell') and msgcontains(msg, 'black pearl') or msgcontains(msg, 'black pearls') then
bs,itemid,count,subtype,price,iscountable,article,name,plural = 'sell',2144,getCountNumber(msg),1,280,1,'a','black pearl','black pearls'
sendMsgBuySell(cid,itemid,count,price,article,name,plural,bs)
talk_state = 786
elseif msgcontains(msg, 'sell') and msgcontains(msg, 'small ruby') or msgcontains(msg, 'small rubys') then
bs,itemid,count,subtype,price,iscountable,article,name,plural = 'sell',2147,getCountNumber(msg),1,500,1,'a','small ruby','small rubys'
sendMsgBuySell(cid,itemid,count,price,article,name,plural,bs)
talk_state = 786
----------------------
elseif msgcontains(msg, 'info') then
selfSay('Npc feito por Upking preços = a tibia global')
talk_state = 786
-----------------------
elseif talk_state == 786 then
if msgcontains(msg, 'yes') or msgcontains(msg, 'no') or msgcontains(msg, 'info') then
if bs == 'buy' then
buyItem(cid,itemid,count,subtype,price,iscountable,name,plural,buy_error,buy_ok,
buy_no,msg)
else
sellItem(cid,itemid,count,subtype,price,iscountable,sell_error,sell_ok,sell_no,m
sg)
end
talk_state = 0
end
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if focus > 0 then
x, y, z = creatureGetPosition(focus)
myx, myy, myz = selfGetPosition()
if ((myy-y==0) and (myx-x<=0 and myx-x>=-4)) then
selfTurn(1)
end
if ((myy-y==0) and (myx-x>=0 and myx-x<=4)) then
selfTurn(3)
end
if ((myx-x==0) and (myy-y<=0 and myy-y>=-4)) then
selfTurn(2)
end
if ((myx-x==0) and (myy-y>=0 and myy-y<=4)) then
selfTurn(0)
end
if ((myy-y==-2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(2)
end
if ((myy-y==2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(0)
end
if ((myx-x==2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(3)
end
if ((myx-x==-2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(1)
end
if ((myy-y==-3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(2)
end
if ((myy-y==3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(0)
end
if ((myx-x==3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(3)
end
if ((myx-x==-3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(1)
end
if ((myy-y==-4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(2)
end
if ((myy-y==4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(0)
end
if ((myx-x==4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(3)
end
if ((myx-x==-4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(1)
end
end
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
end
end
"Tibia Global much more fun, quality and support"
coming soon...
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
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addSellableItem({'wand of vortex', 'vortex'}, 2190, 250, 'wand of vortex')
shopModule:addSellableItem({'wand of dragonbreath', 'dragonbreath'}, 2191, 500, 'wand of dragonbreath')
shopModule:addSellableItem({'wand of decay', 'decay'}, 2188, 2500, 'wand of decay')
shopModule:addSellableItem({'wand of draconia', 'draconia'}, 8921, 3750, 'wand of draconia')
shopModule:addSellableItem({'wand of cosmic energy', 'cosmic energy'}, 2189, 5000, 'wand of cosmic energy')
shopModule:addSellableItem({'wand of inferno', 'inferno'},2187, 7500, 'wand of inferno')
shopModule:addSellableItem({'wand of starstorm', 'starstorm'}, 8920, 9000, 'wand of starstorm')
shopModule:addSellableItem({'wand of voodoo', 'voodoo'}, 8922, 11000, 'wand of voodoo')
shopModule:addSellableItem({'snakebite rod', 'snakebite'}, 2182, 250,'snakebite rod')
shopModule:addSellableItem({'moonlight rod', 'moonlight'}, 2186, 500, 'moonlight rod')
shopModule:addSellableItem({'necrotic rod', 'necrotic'}, 2185, 2500, 'necrotic rod')
shopModule:addSellableItem({'northwind rod', 'northwind'}, 8911, 3750, 'northwind rod')
shopModule:addSellableItem({'terra rod', 'terra'}, 2181, 5000, 'terra rod')
shopModule:addSellableItem({'hailstorm rod', 'hailstorm'}, 2183, 7500, 'hailstorm rod')
shopModule:addSellableItem({'springsprout rod', 'springsprout'}, 8912, 9000, 'springsprout rod')
shopModule:addSellableItem({'underworld rod', 'underworld'}, 8910, 11000, 'underworld rod')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
vc tem que editar os nomes, os ids e os preços dos items
Assinatura bugada, movido para "sobre mim"