local t = {
[10621] = { -- Chest Action Id
storage = 10621, -- Storage
keyId = 2089, -- Key Item Id
actionId = 32002 -- Key Action Id
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local k = t[item.actionid]
if k then
if getPlayerStorageValue(cid, k.storage) < 0 then
local id = doCreateItemEx(k.keyId, 1)
if doPlayerAddItemEx(cid, id) ~= RETURNVALUE_NOERROR then
doPlayerSendCancel(cid, "You cannot carry this item.")
else
doSetItemActionId(id, k.actionId)
[COLOR="#FF0000"]doPlayerSave(cid, true)[/COLOR]
setPlayerStorageValue(cid, k.storage, 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a " .. getItemName(k.keyId) .. "!")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "The " .. getItemName(item.itemid) .. " is empty.")
end
end
return true
end