all good.What is wrong with the caps?
--[[local specialQuests = {
[30002] = 30002, -- Annih
[30009] = 1010, -- Svargrond
[30010] = 1011, -- Svargrond
[30011] = 1012, -- Svargrond
[30039] = 1022,
[31248] = 1079, -- Dreamer Challenge Quest
}--]]
--[[local quests = {
[31286] = {storageKey = 2012, storageValue = 2}, -- Postman mission 8
[31287] = {storageKey = 2013, storageValue = 2}, -- Postman mission 9
[31289] = {storageKey = 2009, storageValue = 2} -- Postman mission 5
}--]]
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local storage = specialQuests[item.actionid]
if not storage then
storage = item.uid
if storage > 65535 then
return false
end
end
if player:getStorageValue(storage) > 0 then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'The ' .. ItemType(item.itemid):getName() .. ' is empty.')
return true
end
local targetItem = item
local items = {}
local reward = nil
local size = targetItem:isContainer() and Container(item.uid):getSize() or 0
if size == 0 then
reward = targetItem:clone()
else
local container = Container(item.uid)
for i = 0, container:getSize() - 1 do
items[#items + 1] = container:getItem(i):clone()
end
end
size = #items
if size == 1 then
reward = items[1]:clone()
end
local result = ''
local totalWeight = 0
if reward then
local ret = ItemType(reward:getId())
if ret:isRune() then
result = ret:getArticle() .. ' ' .. ret:getName() .. ' (' .. reward:getSubType() .. ' charges)'
elseif ret:isStackable() and reward:getCount() > 1 then
result = reward:getCount() .. ' ' .. ret:getPluralName()
else
result = ret:getArticle() .. ' ' .. ret:getName()
end
totalWeight = ret:getWeight(reward:getCount())
else
if size > 20 then
reward = Game.createItem(item.itemid, 1)
elseif size > 8 then
reward = Game.createItem(1988, 1)
else
reward = Game.createItem(1987, 1)
end
for i = 1, size do
local tmp = items[i]
if reward:addItemEx(tmp) ~= RETURNVALUE_NOERROR then
print('[Warning] QuestSystem:', 'Could not add quest reward to container')
else
local separator = ', '
if i == size then
separator = ' and '
elseif i == 1 then
separator = ''
end
result = result .. separator
local ret = ItemType(tmp:getId())
if ret:isRune() then
result = result .. ret:getArticle() .. ' ' .. ret:getName() .. ' (' .. tmp:getSubType() .. ' charges)'
elseif ret:isStackable() and tmp:getCount() > 1 then
result = result .. tmp:getCount() .. ' ' .. ret:getPluralName()
else
result = result .. ret:getArticle() .. ' ' .. ret:getName()
end
totalWeight = totalWeight + ret:getWeight(tmp:getCount())
end
end
totalWeight = totalWeight + ItemType(reward:getId()):getWeight()
end
if player:getFreeCapacity() < totalWeight then
player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You have found %s weighing %.2f oz, but you don\'t have enough capacity.', result, (totalWeight / 100)))
return true
end
if player:addItemEx(reward) ~= RETURNVALUE_NOERROR then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found ' .. result .. ', but you have no room to take it.')
return true
end
local targetTable = quests[item.uid]
if targetTable then
player:setStorageValue(targetTable.storageKey, targetTable.storageValue)
end
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found ' .. result .. '.')
player:setStorageValue(storage, 1)
return true
end
<action fromaid="1998" toaid="2000" script="system.lua"/>
THANK YOU!LUA:--[[local specialQuests = { [30002] = 30002, -- Annih [30009] = 1010, -- Svargrond [30010] = 1011, -- Svargrond [30011] = 1012, -- Svargrond [30039] = 1022, [31248] = 1079, -- Dreamer Challenge Quest }--]] --[[local quests = { [31286] = {storageKey = 2012, storageValue = 2}, -- Postman mission 8 [31287] = {storageKey = 2013, storageValue = 2}, -- Postman mission 9 [31289] = {storageKey = 2009, storageValue = 2} -- Postman mission 5 }--]] function onUse(player, item, fromPosition, target, toPosition, isHotkey) local storage = specialQuests[item.actionid] if not storage then storage = item.uid if storage > 65535 then return false end end if player:getStorageValue(storage) > 0 then player:sendTextMessage(MESSAGE_INFO_DESCR, 'The ' .. ItemType(item.itemid):getName() .. ' is empty.') return true end local targetItem = item local items = {} local reward = nil local size = targetItem:isContainer() and Container(item.uid):getSize() or 0 if size == 0 then reward = targetItem:clone() else local container = Container(item.uid) for i = 0, container:getSize() - 1 do items[#items + 1] = container:getItem(i):clone() end end size = #items if size == 1 then reward = items[1]:clone() end local result = '' local totalWeight = 0 if reward then local ret = ItemType(reward:getId()) if ret:isRune() then result = ret:getArticle() .. ' ' .. ret:getName() .. ' (' .. reward:getSubType() .. ' charges)' elseif ret:isStackable() and reward:getCount() > 1 then result = reward:getCount() .. ' ' .. ret:getPluralName() else result = ret:getArticle() .. ' ' .. ret:getName() end totalWeight = ret:getWeight(reward:getCount()) else if size > 20 then reward = Game.createItem(item.itemid, 1) elseif size > 8 then reward = Game.createItem(1988, 1) else reward = Game.createItem(1987, 1) end for i = 1, size do local tmp = items[i] if reward:addItemEx(tmp) ~= RETURNVALUE_NOERROR then print('[Warning] QuestSystem:', 'Could not add quest reward to container') else local separator = ', ' if i == size then separator = ' and ' elseif i == 1 then separator = '' end result = result .. separator local ret = ItemType(tmp:getId()) if ret:isRune() then result = result .. ret:getArticle() .. ' ' .. ret:getName() .. ' (' .. tmp:getSubType() .. ' charges)' elseif ret:isStackable() and tmp:getCount() > 1 then result = result .. tmp:getCount() .. ' ' .. ret:getPluralName() else result = result .. ret:getArticle() .. ' ' .. ret:getName() end totalWeight = totalWeight + ret:getWeight(tmp:getCount()) end end totalWeight = totalWeight + ItemType(reward:getId()):getWeight() end if player:getFreeCapacity() < totalWeight then player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You have found %s weighing %.2f oz, but you don\'t have enough capacity.', result, (totalWeight / 100))) return true end if player:addItemEx(reward) ~= RETURNVALUE_NOERROR then player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found ' .. result .. ', but you have no room to take it.') return true end local targetTable = quests[item.uid] if targetTable then player:setStorageValue(targetTable.storageKey, targetTable.storageValue) end player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found ' .. result .. '.') player:setStorageValue(storage, 1) return true end
you can use this system as the old tfs used to be
actionid [2000]
uniqueid [the storage value]
in actions.xml
XML:<action fromaid="1998" toaid="2000" script="system.lua"/>