Advertisement
Guest User

Untitled

a guest
Dec 6th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.11 KB | None | 0 0
  1. if questSystem[item.actionid].rewards.items then
  2.     local backpack = player:getSlotItem(CONST_SLOT_BACKPACK)
  3.     if Container(backpack) and Container(backpack):getEmptySlots(true) >= 1 then
  4.         local totalWeight = 0
  5.         local items = questSystem[item.actionid].rewards.items
  6.         for i = 1, #items do
  7.             local item = ItemType(items[i].id)
  8.             if item then
  9.                 local weight = item:getWeight(items[i].count)
  10.                 totalWeight = totalWeight + weight
  11.             end
  12.         end
  13.         if player:getFreeCapacity() > totalWeight then
  14.             if #items > 1 then
  15.                 local bag = (#items > 8 and 1988 or 1987)
  16.                 local message = "You have found " .. ItemType(bag):getArticle() .. " " .. ItemType(bag):getName() .. " containing "
  17.                 local add = player:addItem(bag)
  18.                 add = Container(add)
  19.                 if add then
  20.                     for i = 1, #items do
  21.                         add:addItem(items[i].id, items[i].count)
  22.                         if i < #items then
  23.                             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()) .. ", "
  24.                         else
  25.                             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()) .. "."
  26.                         end
  27.                     end
  28.                     player:addItemEx(add)
  29.                     player:sendTextMessage(MESSAGE_INFO_DESCR, message)
  30.                 else
  31.                     print("Internal error: questSystem - no container to add items to.")
  32.                     player:sendTextMessage(MESSAGE_STATUS_WARNING, "Internal error, please contact the GM.")
  33.                 end
  34.             else
  35.                 player:addItem(items[1].id, items[1].count)
  36.                 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()) .. ".")
  37.             end
  38.         else
  39.             player:sendTextMessage(MESSAGE_STATUS_WARNING, "bla bla bla u no gots cap")
  40.         end
  41.     else
  42.         player:sendTextMessage(MESSAGE_STATUS_WARNING, "bla bla bla u no gots room")
  43.     end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement