I change one script by summ, because the player can receive more than 1 book each bookcase and i set atributte to limite this.. but dont work fine..
LUA:
local table = {
{bookCase = 15471, bookId = 15429, chance = 10, keyBreak = 5},
{bookCase = 15470, bookId = 15427, chance = 20, keyBreak = 10},
{bookCase = 15469, bookId = 15428, chance = 30, keyBreak = 15}
}
function onUse(cid, item, fromPos, itemEx, toPos)
if getItemAttribute(itemEx.uid, "ative") == 1 then
return true
else
doPlayerSendTextMessage(cid, 21, "You already have this item")
end
for _, info in pairs(table) do
if itemEx.itemid == info.bookCase then
if(math.random(100) <= info.keyBreak) then
doRemoveItem(item.uid)
return true
end
if math.random(100) <= info.chance then
if getPlayerStorageValue(cid,62343) == -1 then
doPlayerAddItem(cid, info.bookId)
doItemSetAttribute(itemEx.uid, "ative",1)
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid, 21, "A hidden stash appears the very moment you turn the key.Unfortunately the key breaks as you attempt to remove it from the lock.")
setPlayerStorageValue(cid, 62343, storageplus)
return true
else
doPlayerSendTextMessage(cid, 21, "You\'re not allowed")
end
end
end
end
return true
end