It's all to do with SQL scripting, when an item is placed in the bag it has a number that is referenced in SQL. The same number that is used to remember a players items when they log, the bag also in each slot is referenced in the same way the Item protection script references to the slot the item is in. But it doesn't just stop with SQL scripting, as your also going to need to use Variable scripting as well as standard scripting. As you will need the server to check the item is in the bag and so not dropping it.
I did work on a script a long time ago, that worked in principle of not dropping integral from the bag when PK'd or dying. But it was a long way off from working, as only got the PK'ing bit working. But if I find it, I will release it.