Lopaskurwa
Active Member
- Joined
- Oct 6, 2017
- Messages
- 873
- Solutions
- 2
- Reaction score
- 49
Hello how can i add multiple items in this code and extra feature which i have in my functions.lua which is
And need level requirement
Not sure whats the right structure for it maybe something should look like this
Lua:
addExtraHealth = Howmuchyouwanttoadd
addExtraMana = Howmuchyouwanttoadd,
And need level requirement
Not sure whats the right structure for it maybe something should look like this
Lua:
local rewards = {
[1] = {chest_uid = 1587},
{
rewards = {
addExtraHealth = 1000,
addExtraMana = 1000,
addItem = {{id = 14316, count = 1}, {id = 14317, count = 1}, {id = 14318, count = 1}},
},
needLevel = 300,
}
[2] and etc
Lua:
local storage_id = 2550
local rewards = {
[1] = {chest_uid = 1587, reward_id = 1531, reward_count = 1},
[2] = {chest_uid = 1588, reward_id = 1533, reward_count = 1},
[3] = {chest_uid = 1589, reward_id = 12747, reward_count = 1},
[4] = {chest_uid = 1590, reward_id = 14681, 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_INFO_DESCR, "It is empty.")
end
local reward
for i = 1, #rewards do
if rewards[i].chest_uid == item.uid then
reward = rewards[i]
break
end
end
local reward_type = ItemType(reward.reward_id)
if reward_type then
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