Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onLogin(cid)
- registerCreatureEvent(cid, "ChangeCorpse")
- return true
- end
- function onDeath(cid, corpse, deathList)
- local voc = {
- [2] = 2945,
- [6] = 2945,
- [15] = 2945,
- [16] = 2945,
- [17] = 2945,
- [18] = 2945,
- [19] = 2945,
- [20] = 2945,
- [21] = 2820,
- [22] = 2820,
- [23] = 2820,
- [24] = 2820,
- [25] = 2820,
- [26] = 2820,
- [27] = 2820,
- [28] = 2820,
- [29] = 2820,
- [30] = 2820,
- }
- local newCorpse = voc[getPlayerVocation(cid)]
- if newCorpse and newCorpse ~= corpse.itemid then
- local corpseItem = doCreateItem(newCorpse, getThingPos(cid))
- if isContainer(corpseItem) and isContainer(corpse.uid) then
- addEvent(function (pos, newId, oldId)
- local newCorpse = getTileItemById(pos, newId)
- local oldCorpse = getTileItemById(pos, oldId)
- if oldCorpse.uid <= 1 or newCorpse.uid <= 1 then return end
- local oldCorpseItem = 0
- local addedItems = 0
- repeat
- oldCorpseItem = getContainerItem(oldCorpse.uid, 0)
- if oldCorpseItem.uid <= 1 then break end
- doAddContainerItem(newCorpse.uid, oldCorpseItem.itemid, oldCorpseItem.type)
- doRemoveItem(oldCorpseItem.uid)
- addedItems = addedItems + 1
- until addedItems >= getItemInfo(newCorpse.itemid).maxItems
- doRemoveItem(oldCorpse.uid)
- end, 1, getThingPos(cid), newCorpse, corpse.itemid)
- else
- addEvent(function (pos, id)
- local I = getTileItemById(pos, id).uid
- return I > 1 and doRemoveItem(I)
- end, 1, getThingPos(cid), corpse.itemid)
- end
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement