• 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 Help AnihiChest

SkyZy

New Member
Joined
Jul 2, 2016
Messages
4
Reaction score
0
I'm trying to put the PresentBox prize together with the Doll, but nothing happens, the other three chests work normally, but Bear's doesn't.Any solution ?




Lua:
local storage_id = 2000

local rewards = {
    [2000] = {reward_id = 2494, reward_count = 1}, -- [chest uid] = {reward item id, reward item count},
    [2001] = {reward_id = 2400, reward_count = 1},
    [2002] = {reward_id = 2431, reward_count = 1},
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local storage = player:getStorageValue(storage_id)
    if storage > 0 then
        return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
    end

    local reward = rewards[item.uid]
    local reward_type = reward and ItemType(reward.reward_id)
    if reward_type then
                if itemUid == 2003 then
                    player:addItem(1990, 1):addItem(2326, 1)
                   player:setStorageValue(storage_id, 1)
end
        if player:addItem(reward.reward_id, reward.reward_count, false, 1, CONST_SLOT_WHEREEVER) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found a " .. reward_type:getName():lower() .. ".")
            player:setStorageValue(storage_id, 1)
        else
            local weight = reward_type:getWeight()
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found an item weighing ' .. weight / 100 .. ' oz it\'s too heavy or you do not have enough room.')
        end
end
    return true
end
 
Solution
Lua:
local rewards = {

    -- # [chest uid] = {item id, item count}
    [2000] = {id = 2494, count = 1},
    [2001] = {id = 2400, count = 1},
    [2002] = {id = 2431, count = 1},
    [2003] = {id = 1990, count = 1},

    storage = 2000
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    if player:getStorageValue(rewards.storage) > 0 then
        return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
    end

    local reward = rewards[item.uid]
    if not reward or ItemType(reward.id):getId() == 0 then
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    local virtualItem = Game.createItem(reward.id, reward.count)
    if reward.id == 1990 then...
Lua:
local rewards = {

    -- # [chest uid] = {item id, item count}
    [2000] = {id = 2494, count = 1},
    [2001] = {id = 2400, count = 1},
    [2002] = {id = 2431, count = 1},
    [2003] = {id = 1990, count = 1},

    storage = 2000
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    if player:getStorageValue(rewards.storage) > 0 then
        return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
    end

    local reward = rewards[item.uid]
    if not reward or ItemType(reward.id):getId() == 0 then
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    local virtualItem = Game.createItem(reward.id, reward.count)
    if reward.id == 1990 then
        virtualItem:addItem(2326)
    end

    if player:addItemEx(virtualItem) ~= RETURNVALUE_NOERROR then
        return player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found an item weighing " .. ("%.2f"):format(virtualItem:getWeight() / 100) .. " oz, it's too heavy or you do not have enough room.")
    end

    player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found a " .. virtualItem:getName():lower() .. ".")
    player:setStorageValue(rewards.storage, 1)
    return true
end
 
Solution
Lua:
local rewards = {

    -- # [chest uid] = {item id, item count}
    [2000] = {id = 2494, count = 1},
    [2001] = {id = 2400, count = 1},
    [2002] = {id = 2431, count = 1},
    [2003] = {id = 1990, count = 1},

    storage = 2000
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    if player:getStorageValue(rewards.storage) > 0 then
        return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
    end

    local reward = rewards[item.uid]
    if not reward or ItemType(reward.id):getId() == 0 then
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end

    local virtualItem = Game.createItem(reward.id, reward.count)
    if reward.id == 1990 then
        virtualItem:addItem(2326)
    end

    if player:addItemEx(virtualItem) ~= RETURNVALUE_NOERROR then
        return player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found an item weighing " .. ("%.2f"):format(virtualItem:getWeight() / 100) .. " oz, it's too heavy or you do not have enough room.")
    end

    player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found a " .. virtualItem:getName():lower() .. ".")
    player:setStorageValue(rewards.storage, 1)
    return true
end
WOWW ! Perfect !! THANks Very Much !! =D
 
Back
Top