local sarcophagus = {1417,1418,1419,1420}
local chance = 5 -- % of 100
local bag = 1987
local items = {
{id=5909, minCount=2, maxCount=8}, -- white peice of cloth
{id=5914, minCount=2, maxCount=8}, -- yellow peice of cloth
{id=5913, minCount=2, maxCount=8}, -- brown peice of cloth
{id=2148, minCount=20, maxCount=100}, -- gold coin
{id=2145, minCount=1, maxCount=5}, -- small diamond
{id=2149, minCount=1, maxCount=10} -- small emerald
}
local creatureName = "Mummy"
local creaturePosition = {x=896,y=366,z=7}
local summonEffect = CONST_ME_YELLOWENERGY
local storageValue = 1002
function onUse(cid, item, fromPosition, itemEx, toPosition)
local playerStorage, randomValue, reward, count = 0, 0, 0, 0
if item.uid == 15580 and isInArray(sarcophagus, item.itemid) then
playerStorage = getPlayerStorageValue(cid,storageValue)
randomValue = math.random(1,100)
if (playerStorage == -1) or (playerStorage == 0) then
if (randomValue <= chance) or (playerStorage == 0) then
rewardContainer = doCreateItemEx(bag,1)
for i=1,#items do
doAddContainerItem(rewardContainer, items[i].id, math.random(items[i].minCount,items[i].maxCount))
end
local addItems = doPlayerAddItemEx(cid, rewardContainer, 0)
if addItems == RETURNVALUE_NOERROR then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You recieve a bag.")
setPlayerStorageValue(cid, storageValue, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Not enough capacity.")
setPlayerStorageValue(cid, storageValue, 0)
end
else
doSummonCreature(creatureName,creaturePosition)
doSendMagicEffect(creaturePosition, summonEffect)
setPlayerStorageValue(cid, storageValue, 1)
end
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "It is empty.")
end
end
return true
end