

pawlacz741 requested a script that will check for all the players empty backpacks with the item id 1988. Here
So I thought I would help out.
The script will check the main backpack and ammo slot backpack (if they are there) for all the empty backpacks inside them and removes them all. It will not remove a backpack that has any other item in it. If you have a backpack inside a backpack then an item inside that backpack, that whole chain of backpacks won't be removed (I may change it so it moves the backpack with the items out to the main backpack when I have time). I Made it fairly configurable so you can add more backpacks types if you like.
I have tested it out and it works perfectly fine with 0.3.6pl1 and should work on 0.4, how ever I would suggest that you test it in your server first before making it public to your OT community

Add to drop.lua:
LUA:
--[[
!---------------------------------!
!---Created by Teh Maverick-------!
!-------www.otland.net------------!
!---------------------------------!
]]
--Config---
bagsToDelete = {1988, 2000, 2001} -- Add the backpack ids you want to be deleted here
function onSay(cid, words, param)
local container, bagItems = {}, {}
local firstBag = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK)
local arrowBag = getPlayerSlotItem(cid, CONST_SLOT_AMMO)
local bagCount = 0
--Check Main Backpack
if isItemContainer(firstBag.itemid) then
for i = 0, getContainerSize(firstBag.uid)-1 do
for i = 0, getContainerSize(firstBag.uid)-1 do
container[i] = getContainerItem(firstBag.uid, i)
if container[i].itemid > 0 then
if isItemContainer(container[i].itemid) then
doCheckNextBag(container[i])
end
end
end
end
end
--Check Arrow Slot
if isItemContainer(arrowBag.itemid) then
for i = 0, getContainerSize(arrowBag.uid)-1 do
for i = 0, getContainerSize(arrowBag.uid)-1 do
container[i] = getContainerItem(arrowBag.uid, i)
if container[i].itemid > 0 then
if isItemContainer(container[i].itemid) then
doCheckNextBag(container[i])
end
end
end
end
end
end
function doCheckNextBag(container)
local itemsInBag = {}
local bagEmptySlotCheck = 0
local bagSize = getContainerSize(container.uid)
for i = 0, getContainerSize(container.uid)-1 do
itemsInBag[i] = getContainerItem(container.uid, i)
if itemsInBag[i].itemid > 0 then
if isItemContainer(itemsInBag[i].itemid) then
doCheckNextBag(itemsInBag[i])
end
else
bagEmptySlotCheck = bagEmptySlotCheck + 1
end
end
if bagEmptySlotCheck == bagSize and isInArray(bagsToDelete, container.itemid) then
doRemoveItem(container.uid, 1)
bagEmptySlotCheck = 0
end
end
Add to your talkactions.xml:
XML:
<talkaction words="!drop" event="script" value="drop.lua"/>
Hope this is useful! I will probably get around to updating this later on as its late here and probably could tidy up the code a but haha.
Rep++ If you like!