MaXwEllDeN

Untitled

Jun 16th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. function getAllItemsInContainer(container, uid) -- by MaXwEllDeN
  2.     local items = {}
  3.  
  4.     for slot = 0, getContainerSize(container.uid) - 1 do
  5.         local item = getContainerItem(container.uid, slot)
  6.         if item.uid > 100 then
  7.             if isContainer(item.uid) then
  8.                 for _, v in pairs(getAllItemsInContainer(item, uid)) do
  9.                     table.insert(items, v)
  10.                 end
  11.             else
  12.                 table.insert(items, uid and item.uid or item)
  13.             end
  14.         end
  15.     end
  16.  
  17.     return items
  18. end
  19.  
  20. function getPlayerItemsById(uid, id) -- by MaXwEllDeN
  21.     local ret = {}
  22.  
  23.     for slot = CONST_SLOT_FIRST, CONST_SLOT_LAST do
  24.         local item = getPlayerSlotItem(uid, slot)
  25.  
  26.         if item.uid > 100 then
  27.             if item.itemid == id then
  28.                 table.insert(ret, item)
  29.             end
  30.  
  31.             if isContainer(item.uid) then
  32.                 for _, v in pairs(getAllItemsInContainer(item)) do
  33.                     if v.itemid == id then
  34.                         table.insert(ret, v)
  35.                     end
  36.                 end
  37.             end
  38.         end
  39.     end
  40.  
  41.     return ret
  42. end
  43.  
  44.  
  45. function onDeath(cid)
  46.     local player = getCreatureMaster(cid)
  47.     local maxhealth = getCreatureMaxHealth(getCreatureSummons(player)[1])
  48.  
  49.     setPlayerStorageValue(player, 12889, 0)
  50.     setPlayerStorageValue(player, 12890, maxhealth)
  51.     setPlayerStorageValue(player, 12891, 0)
  52.     doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_BLUE, "Seu pet está morto.")
  53.  
  54.  
  55.     for _, item in pairs(getPlayerItemsById(player, 7633)) do
  56.         if getItemAttribute(item.uid, "namepet") == getCreatureName(cid) then
  57.             doTransformItem(item.uid, 7632)
  58.             break
  59.         end
  60.     end
  61.  
  62.     return false
  63. end
Advertisement
Add Comment
Please, Sign In to add comment