I have this script and whenever I try to do quest it tells me
It is empty.
How can I solve this?
It is empty.
How can I solve this?
LUA:
local vocationItemIds = {
[1] = {5917, 3968}, -- Sorcerer
[5] = {5917, 3968}, -- Sorcerer
[2] = {5917, 3968}, -- Druid
[6] = {5917, 3968}, -- Druid
[3] = {7901, 7898}, -- Paladin
[7] = {7901, 7898}, -- Paladin
[4] = {2506, 2492}, -- Knight
[8] = {2506, 2492}, -- Knight
}
local action = Action()
function action.onUse(player, item, fromPos, target, toPos, isHotkey)
if not item:getType():isContainer() then
return true
end
local uniqueId = item:getUniqueId()
if player:getStorageValue(uniqueId) ~= 0 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
return true
end
local vocation = player:getVocation():getBase()
local vocationId = vocation:getId()
local itemIds = vocationItemIds[vocationId]
if itemIds then
for _, itemId in ipairs(itemIds) do
local get = item:getItem(itemId)
if get then
local weight = get:getWeight()
if player:getFreeCapacity() < weight then
player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You need %.2f weight.", weight / 100))
return true
end
local reward = get:clone()
if player:addItemEx(reward) == RETURNVALUE_NOERROR then
player:setStorageValue(uniqueId, 1)
if reward:getType():isContainer() then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You found: " .. reward:getContentDescription())
else
player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You found: %d %s.", reward:getCount(), reward:getName()))
end
else
reward:remove()
player:sendCancelMessage(RETURNVALUE_NOTENOUGHCAPACITY)
end
end
end
end
return true
end
action:aid(10107)
action:register()