PDA

View Full Version : Moving items, deposit for backpack - HELP?



diegopros
01-12-2016, 06:37 AM
Anyone know how to move dp spear to backpack ?
a script to perform this action ?




and this the right way?





local withdrawList

function registerWithdrawing(item, amount, to, from)
withdrawList = withdrawList or {}
table.insert(withdrawList {item, from, to or 0, amount or 1})
end

local function WithdrawItems(...)

local function getNonContainerSpot(container)
for spot = 0, container:ItemCount() - 1 do
local item = container:GetItemData(spot)
if not Item.isContainer(item.id) then
return spot
end
end
end

local function withdraw(itemID, toBP, amount)
local to = Container.New(toBP)
local remainingCount = amount

while true do
local from = Container:GetLast()

for fromSpot = from:ItemCount() - 1, 0, -1 do
local item = from:GetItemData(fromSpot)
if item.id == itemID then
local moveCount = math.min(remainingCount, item.count)
from:MoveItemToContainer(fromSpot, to:Index(), getNonContainerSpot(to), moveCount)
remainingCount = remainingCount - moveCount
wait(200, 500)
if remainingCount <= 0 then
from:Close()
wait(200, 500)
return true
end
end
end