Advertisement
Skymagnum

Untitled

May 14th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 KB | None | 0 0
  1. function onLogin(cid)
  2.     registerCreatureEvent(cid, "ChangeCorpse")
  3. return true
  4. end
  5.  
  6. function onDeath(cid, corpse, deathList)
  7.     local voc = {
  8.         [2] = 2945,
  9.         [6] = 2945,
  10.         [15] = 2945,
  11.         [16] = 2945,
  12.         [17] = 2945,
  13.         [18] = 2945,
  14.         [19] = 2945,
  15.         [20] = 2945,
  16.         [21] = 2820,
  17.         [22] = 2820,
  18.         [23] = 2820,
  19.         [24] = 2820,
  20.         [25] = 2820,
  21.         [26] = 2820,
  22.         [27] = 2820,
  23.         [28] = 2820,
  24.         [29] = 2820,
  25.         [30] = 2820,
  26.     }
  27.  
  28.     local newCorpse = voc[getPlayerVocation(cid)]
  29.     if newCorpse and newCorpse ~= corpse.itemid then
  30.         local corpseItem = doCreateItem(newCorpse, getThingPos(cid))
  31.         if isContainer(corpseItem) and isContainer(corpse.uid) then
  32.             addEvent(function (pos, newId, oldId)
  33.                 local newCorpse = getTileItemById(pos, newId)
  34.                 local oldCorpse = getTileItemById(pos, oldId)
  35.                 if oldCorpse.uid <= 1 or newCorpse.uid <= 1 then return end
  36.                 local oldCorpseItem = 0
  37.                 local addedItems = 0
  38.                 repeat
  39.                     oldCorpseItem = getContainerItem(oldCorpse.uid, 0)
  40.                     if oldCorpseItem.uid <= 1 then break end
  41.                     doAddContainerItem(newCorpse.uid, oldCorpseItem.itemid, oldCorpseItem.type)
  42.                     doRemoveItem(oldCorpseItem.uid)
  43.                     addedItems = addedItems + 1
  44.                 until addedItems >= getItemInfo(newCorpse.itemid).maxItems
  45.                 doRemoveItem(oldCorpse.uid)
  46.                 end, 1, getThingPos(cid), newCorpse, corpse.itemid)
  47.         else
  48.             addEvent(function (pos, id)
  49.                 local I = getTileItemById(pos, id).uid
  50.                 return I > 1 and doRemoveItem(I)
  51.                 end, 1, getThingPos(cid), corpse.itemid)
  52.         end
  53.     end
  54.  
  55. return true
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement