JH
pedido

Npc Que Vende Itens Por Golden Nugget.

Por jhowxd, 11 de ago. de 2012 em Scripts

9
2.9k
jhowxdJ
11 de agosto de 2012 às 01:02

Bom o nome do tópico já diz tudo hehehehe

 

mas é basicamente isso quero um npc que venda vários itens porem a moeda de compra seja o Golden Nugget em vez de gold.

 

Por exemplo o npc vende a VIP ROD por 7 golden nugget, VIP WAND por 7 Golden e VIP armor por 5 golden nugget.

 

mas quero saber como configurar por que esse npc vai vender todos os itens VIP do OT.

NewtonnotwenN
11 de agosto de 2012 às 01:23

Esse npc eu já havia feito para outro player.

 

Em data/npc/scripts crie um arquivo.lua nomeie para npcvip e adicione:

local focus = 0

local talk_start = 0

local target = 0

local days = 0

 

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)

 

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then

selfSay('Ola ' .. creatureGetName(cid) .. '! Eu vendo VIP e itens VIP.')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Desculpe, ' .. creatureGetName(cid) .. '! Falarei com voce em alguns instantes.')

 

elseif focus == cid then

talk_start = os.clock()

 

if msgcontains(msg, 'promoted') or msgcontains(msg, 'promotion') then

if getPlayerVocation(cid) > 4 then

selfSay('Desculpe, voce ja esta promovido.')

talk_state = 0

elseif getPlayerLevel(cid) < 20 then

selfSay('Voce precisa ter no minimo level 20...')

talk_state = 0

elseif not getPlayerPremium(cid) then

selfSay('Compre vip antes, depois eu lhe promoverei.')

talk_state = 0

else

selfSay('Voce quer ser promovido por 20k?')

talk_state = 1

end

 

elseif msgcontains(msg, 'premium') or msgcontains(msg, 'vip') then

selfSay('Você quer comprar Premium?')

talk_state = 2

 

elseif talk_state == 1 then

if msgcontains(msg, 'yes') then

if pay(cid,20000) then

doPlayerSetVocation(cid, getPlayerVocation(cid)+4)

selfSay('Voce foi promovido!')

else

selfSay('Voce nao tem dinheiro suficiente.')

end

end

talk_state = 0

 

elseif talk_state == 2 then

if msgcontains(msg, 'yes') then

if doPlayerRemoveItem(cid,2159,50) == TRUE then

addPremium(cid, 30)

selfSay('Voce recebeu 30 dias de premium!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

elseif focus == cid then

talk_start = os.clock()

 

if msgcontains(msg, 'shield of honor') then

if doPlayerRemoveItem(cid,2159,200) == TRUE then

doPlayerAddItem(cid,2535,1)

selfSay('Voce recebeu Shield of Honor!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

if msgcontains(msg, 'helmet of honor') then

if doPlayerRemoveItem(cid,2159,50) == TRUE then

doPlayerAddItem(cid,2506,1)

selfSay('Voce recebeu Helmet of Honor!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

if msgcontains(msg, 'armor of honor') then

if doPlayerRemoveItem(cid,2159,50) == TRUE then

doPlayerAddItem(cid,2505,1)

selfSay('Voce recebeu Armor of Honor!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

if msgcontains(msg, 'legs of honor') then

if doPlayerRemoveItem(cid,2159,50) == TRUE then

doPlayerAddItem(cid,2507,1)

selfSay('Voce recebeu Legs of Honor!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

if msgcontains(msg, 'sword of honor') then

if doPlayerRemoveItem(cid,2159,200) == TRUE then

doPlayerAddItem(cid,7382,1)

selfSay('Voce recebeu Sword of Honor!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

if msgcontains(msg, 'axe of honor') then

if doPlayerRemoveItem(cid,2159,200) == TRUE then

doPlayerAddItem(cid,7388,1)

selfSay('Voce recebeu Axe of Honor!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

if msgcontains(msg, 'club of honor') then

if doPlayerRemoveItem(cid,2159,200) == TRUE then

doPlayerAddItem(cid,7392,1)

selfSay('Voce recebeu Club of Honor!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

if msgcontains(msg, 'damage ring') then

if doPlayerRemoveItem(cid,2159,150) == TRUE then

doPlayerAddItem(cid,2210,1)

selfSay('Voce recebeu Damage Ring!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

if msgcontains(msg, 'warrior ring') then

if doPlayerRemoveItem(cid,2159,150) == TRUE then

doPlayerAddItem(cid,2211,1)

selfSay('Voce recebeu Warrior Ring!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

if msgcontains(msg, 'magician ring') then

if doPlayerRemoveItem(cid,2159,150) == TRUE then

doPlayerAddItem(cid,2212,1)

selfSay('Voce recebeu Magician Ring!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

if msgcontains(msg, 'flames sword') then

if doPlayerRemoveItem(cid,2159,250) == TRUE then

doPlayerAddItem(cid,7748,1)

selfSay('Voce recebeu Flames Sword!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

if msgcontains(msg, 'united axe') then

if doPlayerRemoveItem(cid,2159,250) == TRUE then

doPlayerAddItem(cid,7751,1)

selfSay('Voce recebeu United Axe!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

if msgcontains(msg, 'quero tal item') then

if doPlayerRemoveItem(cid,id,quantidade) == TRUE then

doPlayerAddItem(cid,7756,1)

selfSay('Voce recebeu seu item!')

else

selfSay('Voce nao tem dinheiro!')

end

end

if msgcontains(msg, 'onyx arrow') then

if doPlayerRemoveItem(cid,2159,200) == TRUE then

doPlayerAddItem(cid,7365,1)

selfSay('Voce recebeu Onix Arrow!')

else

selfSay('Sorry, you do not have scarab Coins.')

end

end

 

talk_state = 0

 

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()

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) > 4 then

selfSay('Good bye then.')

focus = 0

end

end

end

Editando:

 

-Vermelho: Mensagem que o player irá falar.

-Verde Escuro: Mensagem que o npc ira responder.

-Marrom: Função para falar o nome do player.

-Laranja: Mensagem do player para comprar vip.

-Roxo: Mensagem que o npc ira responder.

-Verde claro: Id do item (que ira custar o premium)

-Rosa: Quantidade do item id.

-Azul escuro: Quantidade de dias premium.

-Azul claro: Fala do npc ao comprar premium.

-Cinza: Fala do npc ao cancelar (quando player não tem o dinheiro suficiente).

-Salmão: Mensagem para comprar item.

-Teal: Id do item / Quantidade (preço).

-Dourado: Item que irá receber e quantidade.

-Pale turques: Mensagem de confirmação (quando tem dinheiro)

-Light Blue: Mensagem de negação (quando não tem dinheiro)

 

Obs: Vários items estão no tutorial bastando apenas edita-los, também possui função de promotion.

 

Itens por: Medicalghosr

 

Creditos:

 

Funções by: MUTAN0

Script e tutorial by: Newtonnotwen

jhowxdJ
11 de agosto de 2012 às 01:31

Blz mas tipo ele ano pode vender premi queria tipo assim o player fala TRADE e ja abre a caixa sabe com os itens porem em vez do player vender os itens por Gold vender por Golden Nuggets

 

Tem como fazer assim?

Editado Agosto 11 por jhowxd

OneshotO
11 de agosto de 2012 às 09:51


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 onPlayerEndTrade(cid)                npcHandler:onPlayerEndTrade(cid)            end
function onPlayerCloseChannel(cid)            npcHandler:onPlayerCloseChannel(cid)        end

function onBuyCallback(cid, itemid, subType, amount, ignoreCap, inBackpacks)
   local shopItem = nil
   for _, item in ipairs(npcHandler.shopItems) do
       if(item.id == itemid and item.subType == subType) then
           shopItem = item
           break
       end
   end

   if getPlayerItemCount(cid, 2157) < shopItem.buy then
       npcHandler:say("Sorry, but you do not have enough gold nuggets.", cid)
       return false
   end
   doPlayerRemoveItem(cid, 2157, shopItem.buy)
   return true
end

npcHandler:setCallback(CALLBACK_ONBUY, onBuyCallback)
npcHandler:addModule(FocusModule:new())

 

Está bem simples e o jogador precisa ter além dos gold nuggets, o dinheiro normal para que o NPC venda o item. Claro que eu poderia fazer algo bem mais elaborado, mas levaria tempo e não estou interessado.

 

Um grande abraço.

NewtonnotwenN
11 de agosto de 2012 às 12:36

@Oneshot

 

Me explica essa parte, é que não entendi direito, ele compra por gold nuggets e dinheiro? Como assim?

...Está bem simples e o jogador precisa ter além dos gold nuggets, o dinheiro normal...

OneshotO
11 de agosto de 2012 às 13:05

É que como é um callback, ele ainda checa nas funções normais se o jogador possui o dinheiro normal (gold coins, platinum coins, crystal coins). Por exemplo, vamos dizer que o jogador queira comprar uma Magic Sword que custa 10 gold nuggets, além dos 10 gold nuggets, o jogador vai precisar de 10 gp para comprar o item.

NewtonnotwenN
11 de agosto de 2012 às 13:10

Compreendo, mas ele só checa gold?

 

Tipo, platinum coin e crystal não?

 

Ex:

 

Player tem 50 platinum e nenhum gold, ai vai dar pra comprar?

OneshotO
11 de agosto de 2012 às 13:14

Sim, claro que dará. Ele checa todos os tipos de moeda.

MatheusGladM
12 de agosto de 2012 às 10:49

http://www.xtibia.com/forum/topic/191796-npc-que-usa-outro-item-como-dinheiro/

 

Acho que isso resolve o problema :)