Olá, eu sou GuhPk, e venho até vocês Xtibianos trazer 1 tutorial de como criar 1 npc task quest para poketibia server!!!
==========================================================================================================================
1º Passo - Copie 1 arquivo.xml da sua pasta data/npc e mude o nome para o nome que você, depois cole isso dentro dele:
-- Script Npc Task BY GuhPk
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Brender" script="default.lua" walkinterval="350000" floorchange="0" speed="0">
<health now="150" max="150"/>
<look type="255" head="91" body="114" legs="86" feet="0"/>
<parameters>
<parameter key="message_greet" value="Ola |PLAYERNAME|.Voce que fazer a {task} rapido!"/> </parameters>
</npc>
Azul = nome do script.lua que você vai colocar na pasta data/npc/script.
Vermelho = nome do Npc.
Verde = roupa do seu npc, vou ver se tem tópico explicando como fazer, se tiver eu posto aqui, se não eu crio aqui posto.
http://www.xtibia.co...pcs-e-monstros/
==========================================================================================================================
2º Passo - Agora vai em data/npc/script copia qualquer arquivo.lua de la coloca o nome que você quizer (este nome vai colocar onde esta de azul no script acima) e cola isso dentro:
-- Script Npc Task By GuhPk
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {20}
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false
storage = x -- storage id
item = x -- coloca aqui o id do item que vai ter que ir buscar
quantiitem = x -- quantidade do item acima que precisa pegar
premio1 = x -- coloque aqui o id do dinheiro
quant1 = x -- quantidade de grana que vai ganhar
pexp = x -- experiencia que vai ganhar no premio
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 onThingMove(creature, thing, oldpos, oldstackpos, item, itemEx)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Tchau, e boa sorte.',cid)
focus = 0
talk_start = 0
talkState[talkUser] = 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)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if getDistanceToCreature(cid) > 4 then
return false
end
if talkState[talkUser] ~= 3 then
msg = string.lower(msg)
end
if (msgcontains(msg, 'hi')) then
if #getCreatureSummons(cid) >= 1 then
selfSay('Porfavor, chame o pokemon para a pokebola...', cid)
focus = 0
talkState[talkUser] = 1
return false
end
if getPlayerStorageValue(cid, 17001) == 1 then
focus = 0
talkState[talkUser] = 1
selfSay('Saia do Ride.', cid)
return false
end
if getPlayerStorageValue(cid, 7778) >= 1 then
focus = 0
talkState[talkUser] = 1
selfSay('Você está usando alguma habilidade.', cid)
return false
end
fala = "Hey, eu estou precisando urgentemente de x itens. Será que você poderia me ajudar?"
selfSay(fala,cid)
talkState[talkUser] = 1
elseif ( ( msgcontains(msg,"yes") or (msgcontains(msg,"sim") ) ) and talkState[talkUser] == 1 ) then
quest1 = getPlayerStorageValue(cid,storage)
if quest1 == 2 then
selfSay('Cara, você já me ajudou!',cid)
else
if quest1 ==1 then
selfSay('Bom! Então vc trouxe os meus itens? Deixe-me ver.',cid)
if doPlayerRemoveItem(cid, item, quantiitem) == true then
selfSay('Obrigado! Agora poderei fazer meu projeto. Aqui esta sua recompença!',cid)
doPlayerAddItem(cid,premio1,quant1)
doPlayerAddExp(cid,pexp)
setPlayerStorageValue(cid,storage, 2)
talkState[talkUser] = 0
else
selfSay('Voce não trouxe os meus itens... Volte quando tive-los.',cid)
talkState[talkUser] = 0
end
else
selfSay('Me traga os itens para o meu projeto.',cid)
setPlayerStorageValue(cid,storage, 1)
end
end
elseif(msgcontains(msg, 'no')) then
talkState[talkUser] = 0
selfSay('Okay, obrigado mesmo assim.', cid)
elseif(msgcontains(msg, 'bye')) then
selfSay('Até mais!', cid)
talkState[talkUser] = 0
end
end
function onCreatureChangeOutfit(creature)
end
Tudo oque marquei com este azulzinho são as falas do npc que você pode editar caso queira...
É isso ai, esse é meu primeiro 'Tutorial'.
Npc não fui eu que criei totalmente, meu amigo que me passou, então só coloquei créditos a mim e a ele por ter me explicado!!!
Até a próxima pessoal, e fuiz!!
GuhPk