• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Attribute

hasbro

Member
Joined
Feb 15, 2009
Messages
286
Reaction score
6
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
 
Yes , i'am trying use this but each book he receive +1 storage right, and if him use the key on the same bookcase he gain +1 storage understand?
 
LUA:
local table = {
    {bookCase = 15470, bookId = 15429, chance = 10, keyBreak = 5, storage = 9011},
    {bookCase = 15470, bookId = 15427, chance = 20, keyBreak = 10, storage = 9012},
    {bookCase = 15470, bookId = 15428, chance = 30, keyBreak = 15, storage = 9013}
}
 
function onUse(cid, item, fromPos, itemEx, toPos)
    for _, info in pairs(table) do
        if itemEx.itemid == info.bookCase and getPlayerStorageValue(cid, info.storage) < 1 then
            if(math.random(100) <= info.keyBreak) then
                doRemoveItem(item.uid)
                return true
            end
            if math.random(100) <= info.chance then
                doPlayerAddItem(cid, info.bookId)
				setPlayerStorageValue(cid, info.storage, 1)
                return true
            end
        end
    end
    return true
end
 
Back
Top