• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[TFS 1.2] Pet system

monsters please
have this error
Lua Script Error: [Chat Interface]
data/chatchannels/scripts/pet.lua:eek:nJoin
data/lib/pets_lib.lua:284: attempt to index a nil value
stack traceback:
[C]: in function '__index'
data/lib/pets_lib.lua:284: in function 'summonPet'
data/chatchannels/scripts/pet.lua:11: in function <data/chatchannels/scr
ipts/pet.lua:1>
[C]: in function 'openChannel'
...turescripts/scripts/custom/pet_owner_creaturescripts.lua:5: in functi
on <...turescripts/scripts/custom/pet_owner_creaturescripts.lua:1>
 
anyone have an example monster of this system's?
my monster test

<?xml version="1.0" encoding="UTF-8"?>
<monster name="Cat" nameDescription="a cat" race="blood" experience="0" speed="190" manacost="220">
<health now="100" max="100" />
<look type="276" corpse="7637" />
<targetchange interval="4000" chance="0" />
<flags>
<flag summonable="0" />
<flag attackable="1" />
<flag hostile="0" />
<flag illusionable="1" />
<flag convinceable="1" />
<flag pushable="1" />
<flag canpushitems="0" />
<flag canpushcreatures="0" />
<flag targetdistance="1" />
<flag runonhealth="8" />
</flags>
<attacks>
<attack name="melee" interval="2000" skill="0" attack="0" />
</attacks>
<defenses armor="5" defense="5" />
<voices interval="2000" chance="7">
<voice sentence="Mew!" />
<voice sentence="Meow!" />
<voice sentence="Meow meow!" />
</voices>
</monster>
19:24 [PET-SYSTEM]: You can catch only monsters!
 
anyone have an example monster of this system's?
my monster test

<?xml version="1.0" encoding="UTF-8"?>
<monster name="Cat" nameDescription="a cat" race="blood" experience="0" speed="190" manacost="220">
<health now="100" max="100" />
<look type="276" corpse="7637" />
<targetchange interval="4000" chance="0" />
<flags>
<flag summonable="0" />
<flag attackable="1" />
<flag hostile="0" />
<flag illusionable="1" />
<flag convinceable="1" />
<flag pushable="1" />
<flag canpushitems="0" />
<flag canpushcreatures="0" />
<flag targetdistance="1" />
<flag runonhealth="8" />
</flags>
<attacks>
<attack name="melee" interval="2000" skill="0" attack="0" />
</attacks>
<defenses armor="5" defense="5" />
<voices interval="2000" chance="7">
<voice sentence="Mew!" />
<voice sentence="Meow!" />
<voice sentence="Meow meow!" />
</voices>
</monster>
19:24 [PET-SYSTEM]: You can catch only monsters!

https://github.com/yrpen/lua-scripts/tree/master/pets_system/monsters/pets
 
link off

And put there monsters from package:
http://speedy*****malware.localhost/gkaSV/pets.tar.gz
 
Pokeball/Pet Container (Working on my TFS 1.1)

Features:
-Catches current pet and seals into egg.
-Saves pets level and max health.
-Can be traded and work with other players.

Instructions:
-Use first item on your current pet to capture
-Use second item on your character to add new pet.
-Current items in scripts is small emerald to catch which turns into small enchanted emerald but can be configured to the pictured egg easily.

petcontainer.png

actions.xml:
XML:
    <action itemid="2149" script="other/petcontainer.lua"/>
    <action itemid="7761" script="other/petcontainer2.lua"/>

actions/scripts/other/petcontainer.lua:
Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local topos = getCreaturePosition(target)
    local item = Item(item.uid)
  
    if not isCreature(target) then
        doPlayerSendTextMessage(cid, 19, "Use on your pet to capture.")
        return true
    end
  
    if Creature(target):getHealth() ~= Creature(target):getMaxHealth() then
        doPlayerSendTextMessage(cid, 19, "You may only capture pets with full health.")
        return true
    end
  
    if isSummon(target) and Creature(target):getMaster() == cid then
        doTransformItem(item.uid, 7761)
        item:setAttribute("defense", cid:getPetLevel())
        item:setAttribute("text", cid:getPetExperience())
        item:setAttribute("extradefense", cid:getPetType())
        item:setAttribute("attack", cid:getPetUid())      
        item:setAttribute("hitchance", cid:getPetMaxHealth())  
        item:setAttribute("armor", getCreatureName(target))
        item:setAttribute("description", "It contains a captured ".. getCreatureName(target) .." [Level ".. getItemAttribute(item.uid, "defense") .."].","[Level ".. getItemAttribute(item.uid, "defense") .."]")
        cid:doRemovePet()
        cid:doResetPet()
        doPlayerSendTextMessage(cid, 19, "You captured your ".. getCreatureName(target) .."!")
        cid:petSystemMessage("You captured your pet!")
        doSendMagicEffect(topos, CONST_ME_BLOCKHIT)
        else
        doPlayerSendTextMessage(cid, 19, "You may only capture your own pet.")
        return true
    end
end

actions/scripts/other/petcontainer2.lua:
Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local topos = getCreaturePosition(target)
    local validVocations = {0, 2, 6} --set here only the vocations that can use pets, if not remove this and line 6-9
    local item = Item(item.uid)
    local container=
  
    if not isInArray(validVocations, getPlayerVocation(cid)) then
        doPlayerSendTextMessage(cid, 19, "Only priests may own pets.")
        return false
    end
  
    if cid:getPetUid() > 0 then
        doPlayerSendTextMessage(cid, 19, "You already have a pet!")
        return false
    end
  
    if Creature(target) == cid then
        cid:doResetPet()
        cid:doAddPet(tonumber(item:getAttribute("extradefense")))
        cid:setPetType(item:getAttribute("extradefense"))
        cid:setPetUid(item:getAttribute("attack"))
        cid:setPetLevel(item:getAttribute("defense"))
        cid:setPetExperience(item:getAttribute("text"))
        cid:setPetMaxHealth(item:getAttribute("hitchance"))
        cid:setPetLostHealth(0)
        doSendMagicEffect(topos, CONST_ME_THUNDER)
        doSendMagicEffect(topos, CONST_ME_STUN)
        doPlayerSendTextMessage(cid, 19, "You received a new pet!")
        cid:petSystemMessage("You received a new pet!")
        cid:summonPet(cid:getPosition())
        doTransformItem(item.uid, 2149)
        item:removeAttribute("defense")
        item:removeAttribute("text")
        item:removeAttribute("extradefense")
        item:removeAttribute("attack")      
        item:removeAttribute("hitchance")  
        item:removeAttribute("armor")
        item:removeAttribute("description")
        else
        doPlayerSendTextMessage(cid, 19, "Use on yourself to add new pet.")
        return true
    end
end
 
Pokeball/Pet Container (Working on my TFS 1.1)

Features:
-Catches current pet and seals into egg.
-Saves pets level and max health.
-Can be traded and work with other players.

Instructions:
-Use first item on your current pet to capture
-Use second item on your character to add new pet.
-Current items in scripts is small emerald to catch which turns into small enchanted emerald but can be configured to the pictured egg easily.

View attachment 29249

actions.xml:
XML:
    <action itemid="2149" script="other/petcontainer.lua"/>
    <action itemid="7761" script="other/petcontainer2.lua"/>

actions/scripts/other/petcontainer.lua:
Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local topos = getCreaturePosition(target)
    local item = Item(item.uid)
  
    if not isCreature(target) then
        doPlayerSendTextMessage(cid, 19, "Use on your pet to capture.")
        return true
    end
  
    if Creature(target):getHealth() ~= Creature(target):getMaxHealth() then
        doPlayerSendTextMessage(cid, 19, "You may only capture pets with full health.")
        return true
    end
  
    if isSummon(target) and Creature(target):getMaster() == cid then
        doTransformItem(item.uid, 7761)
        item:setAttribute("defense", cid:getPetLevel())
        item:setAttribute("text", cid:getPetExperience())
        item:setAttribute("extradefense", cid:getPetType())
        item:setAttribute("attack", cid:getPetUid())      
        item:setAttribute("hitchance", cid:getPetMaxHealth())  
        item:setAttribute("armor", getCreatureName(target))
        item:setAttribute("description", "It contains a captured ".. getCreatureName(target) .." [Level ".. getItemAttribute(item.uid, "defense") .."].","[Level ".. getItemAttribute(item.uid, "defense") .."]")
        cid:doRemovePet()
        cid:doResetPet()
        doPlayerSendTextMessage(cid, 19, "You captured your ".. getCreatureName(target) .."!")
        cid:petSystemMessage("You captured your pet!")
        doSendMagicEffect(topos, CONST_ME_BLOCKHIT)
        else
        doPlayerSendTextMessage(cid, 19, "You may only capture your own pet.")
        return true
    end
end

actions/scripts/other/petcontainer2.lua:
Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local topos = getCreaturePosition(target)
    local validVocations = {0, 2, 6} --set here only the vocations that can use pets, if not remove this and line 6-9
    local item = Item(item.uid)
    local container=
  
    if not isInArray(validVocations, getPlayerVocation(cid)) then
        doPlayerSendTextMessage(cid, 19, "Only priests may own pets.")
        return false
    end
  
    if cid:getPetUid() > 0 then
        doPlayerSendTextMessage(cid, 19, "You already have a pet!")
        return false
    end
  
    if Creature(target) == cid then
        cid:doResetPet()
        cid:doAddPet(tonumber(item:getAttribute("extradefense")))
        cid:setPetType(item:getAttribute("extradefense"))
        cid:setPetUid(item:getAttribute("attack"))
        cid:setPetLevel(item:getAttribute("defense"))
        cid:setPetExperience(item:getAttribute("text"))
        cid:setPetMaxHealth(item:getAttribute("hitchance"))
        cid:setPetLostHealth(0)
        doSendMagicEffect(topos, CONST_ME_THUNDER)
        doSendMagicEffect(topos, CONST_ME_STUN)
        doPlayerSendTextMessage(cid, 19, "You received a new pet!")
        cid:petSystemMessage("You received a new pet!")
        cid:summonPet(cid:getPosition())
        doTransformItem(item.uid, 2149)
        item:removeAttribute("defense")
        item:removeAttribute("text")
        item:removeAttribute("extradefense")
        item:removeAttribute("attack")      
        item:removeAttribute("hitchance")  
        item:removeAttribute("armor")
        item:removeAttribute("description")
        else
        doPlayerSendTextMessage(cid, 19, "Use on yourself to add new pet.")
        return true
    end
end
Linked in forst post. Great job :)
 
First posts updated.
Changes:
Code:
2017.03.05
- reorganized posts
- moved files to github
- code cleanup:
   - replaced UID status 0, -1, -2 with well named variables in scripts
   - created method Player.doKillPet
   - changed tabulation (tab = 4 spaces)
 - added onLook script
 - added TELEPORT system (default on)
 - added MOUNT system (default off)
 
Pokeball/Pet Container (Working on my TFS 1.1)

Features:
-Catches current pet and seals into egg.
-Saves pets level and max health.
-Can be traded and work with other players.

Instructions:
-Use first item on your current pet to capture
-Use second item on your character to add new pet.
-Current items in scripts is small emerald to catch which turns into small enchanted emerald but can be configured to the pictured egg easily.

View attachment 29249

actions.xml:
XML:
    <action itemid="2149" script="other/petcontainer.lua"/>
    <action itemid="7761" script="other/petcontainer2.lua"/>

actions/scripts/other/petcontainer.lua:
Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local topos = getCreaturePosition(target)
    local item = Item(item.uid)
 
    if not isCreature(target) then
        doPlayerSendTextMessage(cid, 19, "Use on your pet to capture.")
        return true
    end
 
    if Creature(target):getHealth() ~= Creature(target):getMaxHealth() then
        doPlayerSendTextMessage(cid, 19, "You may only capture pets with full health.")
        return true
    end
 
    if isSummon(target) and Creature(target):getMaster() == cid then
        doTransformItem(item.uid, 7761)
        item:setAttribute("defense", cid:getPetLevel())
        item:setAttribute("text", cid:getPetExperience())
        item:setAttribute("extradefense", cid:getPetType())
        item:setAttribute("attack", cid:getPetUid())     
        item:setAttribute("hitchance", cid:getPetMaxHealth()) 
        item:setAttribute("armor", getCreatureName(target))
        item:setAttribute("description", "It contains a captured ".. getCreatureName(target) .." [Level ".. getItemAttribute(item.uid, "defense") .."].","[Level ".. getItemAttribute(item.uid, "defense") .."]")
        cid:doRemovePet()
        cid:doResetPet()
        doPlayerSendTextMessage(cid, 19, "You captured your ".. getCreatureName(target) .."!")
        cid:petSystemMessage("You captured your pet!")
        doSendMagicEffect(topos, CONST_ME_BLOCKHIT)
        else
        doPlayerSendTextMessage(cid, 19, "You may only capture your own pet.")
        return true
    end
end

actions/scripts/other/petcontainer2.lua:
Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local topos = getCreaturePosition(target)
    local validVocations = {0, 2, 6} --set here only the vocations that can use pets, if not remove this and line 6-9
    local item = Item(item.uid)
    local container=
 
    if not isInArray(validVocations, getPlayerVocation(cid)) then
        doPlayerSendTextMessage(cid, 19, "Only priests may own pets.")
        return false
    end
 
    if cid:getPetUid() > 0 then
        doPlayerSendTextMessage(cid, 19, "You already have a pet!")
        return false
    end
 
    if Creature(target) == cid then
        cid:doResetPet()
        cid:doAddPet(tonumber(item:getAttribute("extradefense")))
        cid:setPetType(item:getAttribute("extradefense"))
        cid:setPetUid(item:getAttribute("attack"))
        cid:setPetLevel(item:getAttribute("defense"))
        cid:setPetExperience(item:getAttribute("text"))
        cid:setPetMaxHealth(item:getAttribute("hitchance"))
        cid:setPetLostHealth(0)
        doSendMagicEffect(topos, CONST_ME_THUNDER)
        doSendMagicEffect(topos, CONST_ME_STUN)
        doPlayerSendTextMessage(cid, 19, "You received a new pet!")
        cid:petSystemMessage("You received a new pet!")
        cid:summonPet(cid:getPosition())
        doTransformItem(item.uid, 2149)
        item:removeAttribute("defense")
        item:removeAttribute("text")
        item:removeAttribute("extradefense")
        item:removeAttribute("attack")     
        item:removeAttribute("hitchance") 
        item:removeAttribute("armor")
        item:removeAttribute("description")
        else
        doPlayerSendTextMessage(cid, 19, "Use on yourself to add new pet.")
        return true
    end
end
Regarding this post, dumb mistake, can't edit. Remove "local container=" on line 5 in the second script if you're receiving errors.
 
Back
Top