PsyMcKenzie
New Member
- Joined
- Apr 24, 2012
- Messages
- 35
- Reaction score
- 1
Some time ago I was doing a pet system and I came across a problem, due to work and the college I set aside and now I decided to finish.
The problem is that when I logout with the pet summoned, the life of the pet does not save.
Status is 1 for summoned pet, 2 for pet catched and 3 for dead pet.
Can someone help me? what am I doing wrong?
The problem is that when I logout with the pet summoned, the life of the pet does not save.
Code:
function onLogout(cid)
for petslot = CONST_SLOT_FIRST, CONST_SLOT_LAST do
local item = getPlayerSlotItem(cid, petslot)
if isContainer(item.uid) then
local items = getItemsInContainerById(item.uid, 2126)
local status = getItemAttribute(item.uid, "status")
print(status)
if status == 3 then
return false
end
for i,x in pairs(items) do
local hp = tonumber(getItemAttribute(item.uid, "lifepet"))
local maxhp = tonumber(getItemAttribute(item.uid, "maxlifepet"))
print(hp)
doItemSetAttribute(x, "lifepet", hp)
doItemSetAttribute(x, "maxlifepet", maxhp)
doItemSetAttribute(x, "status", 2)
doTransformItem(x, 2125)
end
end
end
return TRUE
end
Status is 1 for summoned pet, 2 for pet catched and 3 for dead pet.
Can someone help me? what am I doing wrong?