Guest User

Untitled

a guest
May 20th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.00 KB | None | 0 0
  1. local amount = 100
  2. local itemId = 53038  
  3. local mailto = "bankerName"
  4. local mailItemI =1  
  5. local freeBagSlots = 0  
  6. local bagged =0  
  7. for i=0,NUM_BAG_SLOTS do  
  8.    freeBagSlots = freeBagSlots  GetContainerNumFreeSlots(i)  
  9. end  
  10. local bagInfo={}  
  11. for bag = 0,NUM_BAG_SLOTS do  
  12.    for slot=1,GetContainerNumSlots(bag) do  
  13.       local id = GetContainerItemID(bag,slot) or 0  
  14.       local _,c,l = GetContainerItemInfo(bag, slot)  
  15.       if id == itemId and l == nil then  
  16.          table.insert(bagInfo,{bag,slot,c})  
  17.       end  
  18.    end  
  19. end  
  20. local sortF = function (a,b)  
  21.    if a == nil and b == nil or b == nil then return false end  
  22.    if a == nil or  a[3] < b[3] then return true else return false end  
  23. end  
  24. if #bagInfo == 0 then return -1 end  
  25. table.sort(bagInfo,sortF)  
  26. local bagI = #bagInfo  
  27. while bagI > 0 do  
  28.    if GetSendMailItem(mailItemI) == nil then  
  29.       while bagInfo[bagI][3] > amount-bagged and bagI >1 do bagI = bagI - 1 end  
  30.       if bagInfo[bagI][3] + bagged <= amount or freeBagSlots == 0 then  
  31.          PickupContainerItem(bagInfo[bagI][1], bagInfo[bagI][2])  
  32.          ClickSendMailItemButton(mailItemI)  
  33.          bagged = bagged + bagInfo[bagI][3]  
  34.          bagI = bagI - 1  
  35.       else  
  36.          local cnt = bagInfo[bagI][3]-amount  
  37.          SplitContainerItem(bagInfo[bagI][1],bagInfo[bagI][2], cnt)  
  38.          local bagSpaces ={}   for b=NUM_BAG_SLOTS,0,-1 do  
  39.             bagSpaces = GetContainerFreeSlots(b)  
  40.             if #bagSpaces > 0 then  
  41.                PickupContainerItem(b,bagSpaces[#bagSpaces])  
  42.                return 0  
  43.             end  
  44.          end  
  45.       end  
  46.    end  
  47.    if bagged >= amount then return -1 end  
  48.    mailItemI = mailItemI + 1  
  49.    if mailItemI > ATTACHMENTS_MAX_SEND then  
  50.       break  
  51.    end  
  52. end  
  53. local cnt = 0
  54. for i=1,ATTACHMENTS_MAX_SEND do
  55.    if GetSendMailItem(i) ~= nil then cnt = cnt + 1 end
  56. end
  57. if cnt == ATTACHMENTS_MAX_SEND then
  58.    SendMail (mailto," ",'')
  59.    return 1
  60. end
  61. return 0
Add Comment
Please, Sign In to add comment