Ir para conteúdo

Posts Recomendados

Olá amigos. Estou aqui hoje para pedir ajuda para vocês para montar um NPC que vende itens premium por dias de premium account. O meu projeto que estava montando mais nao tive muito sucesso foi esse:

 

local focus = 0

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

 

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

selfSay('Hello ' .. creatureGetName(cid) .. '! Im selling special itens ongame.')

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

 

if msgcontains(msg, 'vip sword') then

if (getPlayerPremiumDays(cid) >= 20) then

doPlayerAddPremiumDays(cid, -20)

doPlayerAddItem(cid, 5785, 1)

selfSay('Here you are.', cid)

else

selfSay('Sorry, you don\'t have 20 or more premium days!', cid)

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

 

A minha lógica ali foi usar as seguintes linhas de comandos para que o NPC vendesse o item por premium account:

 

if msgcontains(msg, 'vip sword') then

if (getPlayerPremiumDays(cid) >= 20) then

doPlayerAddPremiumDays(cid, -20)

doPlayerAddItem(cid, 5785, 1)

selfSay('Here you are.', cid)

else

selfSay('Sorry, you don\'t have 20 or more premium days!', cid)

end

 

mais deu erro na linha 35 e 39 do script (erro em falas) quando fala hi com o npc. Eu queria se alguem pode me ajudar obrigado.

Link para o comentário
https://xtibia.com/forum/topic/121406-monster-npc-de-items-premium/
Compartilhar em outros sites

Você postou na área incorreta, preste mais atenção antes de concluir um tópico.

Sempre leia as regras da seção, e, se tiver dúvidas visite as regras do fórum.

 

Aguarde que um moderador mova o tópico.

Abraços.

Editado por KaKilo
Link para o comentário
https://xtibia.com/forum/topic/121406-monster-npc-de-items-premium/#findComment-799425
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...