Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if questSystem[item.actionid].rewards.items then
- local backpack = player:getSlotItem(CONST_SLOT_BACKPACK)
- if Container(backpack) and Container(backpack):getEmptySlots(true) >= 1 then
- local totalWeight = 0
- local items = questSystem[item.actionid].rewards.items
- for i = 1, #items do
- local item = ItemType(items[i].id)
- if item then
- local weight = item:getWeight(items[i].count)
- totalWeight = totalWeight + weight
- end
- end
- if player:getFreeCapacity() > totalWeight then
- if #items > 1 then
- local bag = (#items > 8 and 1988 or 1987)
- local message = "You have found " .. ItemType(bag):getArticle() .. " " .. ItemType(bag):getName() .. " containing "
- local add = player:addItem(bag)
- add = Container(add)
- if add then
- for i = 1, #items do
- add:addItem(items[i].id, items[i].count)
- if i < #items then
- message = message .. (items[i].count > 1 and items[i].count or ItemType(items[i].id):getArticle()) .. " " .. (items[i].count > 1 and ItemType(items[i].id):getPluralName() or ItemType(items[i].id):getName()) .. ", "
- else
- message = message .. "and " .. (items[i].count > 1 and items[i].count or ItemType(items[i].id):getArticle()) .. " " .. (items[i].count > 1 and ItemType(items[i].id):getPluralName() or ItemType(items[i].id):getName()) .. "."
- end
- end
- player:addItemEx(add)
- player:sendTextMessage(MESSAGE_INFO_DESCR, message)
- else
- print("Internal error: questSystem - no container to add items to.")
- player:sendTextMessage(MESSAGE_STATUS_WARNING, "Internal error, please contact the GM.")
- end
- else
- player:addItem(items[1].id, items[1].count)
- player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found " .. (items[1].count > 1 and items[1].count or ItemType(items[1].id):getArticle()) .. " " .. (items[1].count > 1 and ItemType(items[1].id):getPluralName() or ItemType(items[1].id):getName()) .. ".")
- end
- else
- player:sendTextMessage(MESSAGE_STATUS_WARNING, "bla bla bla u no gots cap")
- end
- else
- player:sendTextMessage(MESSAGE_STATUS_WARNING, "bla bla bla u no gots room")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement