Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getAllItemsInContainer(container, uid) -- by MaXwEllDeN
- local items = {}
- for slot = 0, getContainerSize(container.uid) - 1 do
- local item = getContainerItem(container.uid, slot)
- if item.uid > 100 then
- if isContainer(item.uid) then
- for _, v in pairs(getAllItemsInContainer(item, uid)) do
- table.insert(items, v)
- end
- else
- table.insert(items, uid and item.uid or item)
- end
- end
- end
- return items
- end
- function getPlayerItemsById(uid, id) -- by MaXwEllDeN
- local ret = {}
- for slot = CONST_SLOT_FIRST, CONST_SLOT_LAST do
- local item = getPlayerSlotItem(uid, slot)
- if item.uid > 100 then
- if item.itemid == id then
- table.insert(ret, item)
- end
- if isContainer(item.uid) then
- for _, v in pairs(getAllItemsInContainer(item)) do
- if v.itemid == id then
- table.insert(ret, v)
- end
- end
- end
- end
- end
- return ret
- end
- function onDeath(cid)
- local player = getCreatureMaster(cid)
- local maxhealth = getCreatureMaxHealth(getCreatureSummons(player)[1])
- setPlayerStorageValue(player, 12889, 0)
- setPlayerStorageValue(player, 12890, maxhealth)
- setPlayerStorageValue(player, 12891, 0)
- doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_BLUE, "Seu pet está morto.")
- for _, item in pairs(getPlayerItemsById(player, 7633)) do
- if getItemAttribute(item.uid, "namepet") == getCreatureName(cid) then
- doTransformItem(item.uid, 7632)
- break
- end
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment