• 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!

Random Chest how to put StorageValue

adrianootavares

New Member
Joined
Jul 23, 2012
Messages
112
Reaction score
4
Location
Salvador - Bahia - Brasil
Lua:
local rewards = {
  { item = 9019, count = 1 },
  { item = 5809, count = 1 },
  { item = 8982, count = 1 }
}   

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
local random = math.random(1, #rewards)
player:addItem(rewards[random].item, rewards[random].count)
player:sendTextMessage(36, 'You have found '.. ItemType(rewards[random].item):getName() ..'')
player:sendTextMessage(36, 'You have found '.. rewards[random].item ..'')
return true
end

I want to put this chest with
StorageValue
for play to do the quest only once
 
Solution
Lua:
local rewards = {
  { item = 9019, count = 1 },
  { item = 5809, count = 1 },
  { item = 8982, count = 1 }
}  

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
local random = math.random(1, #rewards)
player:addItem(rewards[random].item, rewards[random].count)
player:sendTextMessage(36, 'You have found '.. ItemType(rewards[random].item):getName() ..'')
player:sendTextMessage(36, 'You have found '.. rewards[random].item ..'')
return true
end

I want to put this chest with
StorageValue
for play to do the quest only once
Try this:
Remember to change the storage number and variable name xD
Lua:
local rewards = {
  { item = 9019, count = 1 },
  { item = 5809, count = 1 },
  { item = 8982, count = 1 }
}   

local...
Lua:
local rewards = {
  { item = 9019, count = 1 },
  { item = 5809, count = 1 },
  { item = 8982, count = 1 }
}  

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
local random = math.random(1, #rewards)
player:addItem(rewards[random].item, rewards[random].count)
player:sendTextMessage(36, 'You have found '.. ItemType(rewards[random].item):getName() ..'')
player:sendTextMessage(36, 'You have found '.. rewards[random].item ..'')
return true
end

I want to put this chest with
StorageValue
for play to do the quest only once
Try this:
Remember to change the storage number and variable name xD
Lua:
local rewards = {
  { item = 9019, count = 1 },
  { item = 5809, count = 1 },
  { item = 8982, count = 1 }
}   

local YOUR_STORAGE_NUMBER = 5000

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:getStorageValue(YOUR_STORAGE_NUMBER) ~= 1 then
        local random = math.random(1, #rewards)
        player:addItem(rewards[random].item, rewards[random].count)
        player:sendTextMessage(36, 'You have found '.. ItemType(rewards[random].item):getName() ..'.')
        player:setStorageValue(YOUR_STORAGE_NUMBER, 1)
    else
         player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You already opened this chest.")
    end
    return true
end
 
Solution
Back
Top