Olá a todos.Antes de mais nada vou avisando que esse NPC eu tinha criado no ano passado (se me recordo bem).
Se houver algum erro, avise-me!
-Disse o Hokage Chuck do [site retirado]
Pois bem. Vim lhes mostrar um npc que encontrei perdido por ai, e mostrarei ele aqui para vocês.
Como vocês podem ver no "Quote" esse script não é de minha autoria.
Apenas estou trazendo ele para o XTibia :smile_positivo:
Então vamos lá:
O NPC consiste em dar algum presente para o jogador. Esse jogador tem uma certa chance entre três presentes. Dependendo da sorte, ele ganhará tal presente.
Depois de ganhar seu presente de Natal, não irá ganhar mais. Para evitar que jogadores fiquem criando contas, você também pode colocar um level mínimo para ganhar presentes.
O Papai Noel é bem exigente quanto ao level! (Haha)
Enfim, agora que terminei a descrição vou passar o script e explicá-lo.
---Primeira Parte // Scripts.
Abra o bloco de notas, e salve o arquivo como papai.lua, ou um nome que você quiser, mas com .lua no final e na pasta data/npc/scripts
No arquivo, digite:
focus = 0talk_start = 0
target = 0
following = false
attacking = false
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Flws...')
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)
cname = creatureGetName(cid)
lvl = getPlayerLevel(cname)
msglvl = 'MSG DE FALTA DE LVL'
lvlmin = LEVEL_PARA_GANHAR
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 and lvl >= lvlmin then
msg_inicial = 'COLOQUE A MSG INICIAL AQUI.'
selfSay(msg_inicial)
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 and lvl >= lvlmin then
selfSay('Desculpe, ' .. creatureGetName(cid) .. '! Falo com voce em um minutinho.')
elseif (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 and lvl < lvlmin then
selfSay(msglvl)
focus = 0
talk_start = 0
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'sim') then
sorte = math.random(1,6)
jogoid = UNIQUE ID PARA O 'JOGO'
jogo = getPlayerStorageValue(cid,jogoid)
id1 = ALGUM ID
id2 = ALGUM ID
id3 = ALGUM ID
msgid1 = 'Voce ganhou alguma coisa!'
msgid2 = 'Voce ganhou alguma coisa!'
msgid3 = 'Voce ganhou alguma coisa!'
msgerro = 'Voce ja ganhou alguma coisa!'
if sorte == 1 and jogo == -1 or sorte == 2 and jogo == -1 then
selfSay(msgid2)
buy(cid,id2,1,0)
setPlayerStorageValue(cid,jogoid,1)
focus = 0
talk_start = 0
elseif sorte == 3 and jogo == -1 or sorte == 4 and jogo == -1 or sorte == 5 and jogo == -1 then
selfSay(msgid1)
buy(cid,id1,1,0)
setPlayerStorageValue(cid,jogoid,1)
focus = 0
talk_start = 0
elseif sorte == 6 and jogo == -1 then
selfSay(msgid3)
buy(cid,id3,1,0)
setPlayerStorageValue(cid,jogoid,1)
focus = 0
talk_start = 0
elseif jogo == 1 then
selfSay(msgerro)
focus = 0
talk_start = 0
end
end
if string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
selfSay('Flws, ' .. 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(0)
end
if ((myy-y==0) and (myx-x>=0 and myx-x<=4)) then
selfTurn(2)
end
if ((myx-x==0) and (myy-y<=0 and myy-y>=-4)) then
selfTurn(1)
end
if ((myx-x==0) and (myy-y>=0 and myy-y<=4)) then
selfTurn(3)
end
if ((myy-y==-2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(1)
end
if ((myy-y==2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(3)
end
if ((myx-x==2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(2)
end
if ((myx-x==-2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(0)
end
if ((myy-y==-3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(1)
end
if ((myy-y==3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(3)
end
if ((myx-x==3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(2)
end
if ((myx-x==-3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(0)
end
if ((myy-y==-4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(1)
end
if ((myy-y==4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(3)
end
if ((myx-x==4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(2)
end
if ((myx-x==-4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(0)
end
end
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Proximo...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Flws...')
focus = 0
end
end
end
Prontinho! A primeira parte já foi explicada, agora, só para dar um toque de papai noel, abra o bloco de notas, digite:
<?xml version="1.0"?> <npc name="Papai Noel" script="data/npc/scripts/papai.lua" access="5" lookdir="1"> <health now="1000" max="1000"/> <look type="160" head="19" body="94" legs="132" feet="95" addon="0" corpse="3128"/> </npc>
E salve como Papai Noel.xml na pasta data/npc!
OBS: caso você salvou o script com outro nome, modifique o papai.lua para o nome que você salvou!
Fim, você fez o seu papai noel!
Créditos:
99% By Hokage Chuck
1% By Alisson Linneker (Por trazer ele aqui. )
Até mais//
Bem, como vocês podem ver, é um script facil de se configurar, mais em breve irei fazer algumas modificações legais nele. Desculpen os errus de hortografiah ce tever. "suahsua"