cara, eu posso te postar o npc pet trainer que funcione, mas o pet system MEEEESMO, eu nao to conseguindo nem pro meu ot, pelomenos o pet trainer meu funfa =]
la vai:
1- crie um arquivo .xml chamado pet trainer em data/npcs.
cole isso dentro:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Arthur Pet Manager" script="pettrainer.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="128" head="39" body="85" legs="77" feet="0" addons="2"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|, I sell {pet}'s also I can {revive} or teach {spells} to your Pet...and maybe you want to {sell} your pet, uh? also I have some {mission}'s for You!. but if you want to know more about pets, just ask for {information}."/>
</parameters>
</npc>
2- agora crie um arquivo .lua chamado pettrainer em data/npcs/scripts.
cole isso dentro:
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 dead = 0
local pet
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
if msgcontains(msg, 'offer') then
local b = false
local c = 0
local response = "Here %s the following %s that you can buy:"
for _, it in pairs(pets) do
if it.cost and it.cost > 0 then
c = c + 1
b = true
local voc, sep = "", ", "
for i = 1, #it.vocations do
if i == #it.vocations - 1 then
sep = " and "
elseif i == #it.vocations then
sep = ""
end
voc = voc .. getVocationInfo(it.vocations).name .. sep
end
response = response .. "\n Name: " .. it.monster .. ", Cost: " .. it.cost .. ", Level: " .. it.level .. ", Vocations: " .. voc .. "."
end
end
response = string.format(response, (c > 1 and "are" or "is"), (c > 1 and "pets" or "pet"))
npcHandler:say(response, cid)
elseif msgcontains(msg, 'revive') then
for i = 1, #pets do
if getCreatureStorage(cid, tables.isDead) > 0 then
dead = dead + 1
end
end
if dead > 0 then
npcHandler:say('Do you want to revive ' .. dead .. ' of your pets for ' .. reviveCost * dead .. ' gold coins?.', cid)
talkState[talkUser] = 1
else
npcHandler:say('Any of your pet is dead.', cid)
talkState[talkUser] = 0
end
elseif msgcontains(msg, 'buy') then
npcHandler:say('Please tell me the name of the pet that you can buy.', cid)
talkState[talkUser] = 2
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if doPlayerRemoveMoney(cid, reviveCost * dead) then
for i = 1, #tables.isDead do
doCreatureSetStorage(cid, tables.isDead, 0)
end
npcHandler:say('Your pets has been revived.', cid)
talkState[talkUser] = 0
else
npcHandler:say('You do not have enough money.', cid)
talkState[talkUser] = 0
end
elseif talkState[talkUser] == 2 then
pet = getPetIdByName(msg)
if not pet then
npcHandler:say('There is not any pet with that name.', cid)
talkState[talkUser] = 0
return true
end
if getCreatureStorage(cid, tables.buyed[pet]) > 0 then
npcHandler:say('You already bought this pet.', cid)
talkState[talkUser] = 0
return true
end
if pets[pet].cost and pets[pet].cost > 0 then
npcHandler:say('Do you want to buy ' .. pets[pet].monster .. ' [' .. pets[pet].level .. '] for ' .. pets[pet].cost .. ' gold coins?', cid)
talkState[talkUser] = 3
else
npcHandler:say('This pet is not buyable, please tell me the name of the pet that you can buy.', cid)
talkState[talkUser] = 2
end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
if doPlayerRemoveMoney(cid, pets[pet].cost) then
doCreatureSetStorage(cid, tables.buyed[pet], 1)
npcHandler:say('Congratulations! you bought ' .. pets[pet].monster .. ' [' .. pets[pet].level .. '].', cid)
talkState[talkUser] = 0
else
npcHandler:say('You do not have enough money to buy this pet.', cid)
talkState[talkUser] = 0
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
vlww mano boa sorte pra vc =]