Oxide.Rust
Oxide.Rust copied to clipboard
Added Hook "CanDropBackpack"
The hook prevents the backpack from falling out in the Wounded, Crawling, or Dead states.
Upon death, it will still drop if the backpack is not empty, due to the CanAcceptItem check. By changing containerVolumeWhenFilled to zero for ItemModBackpack, you can allow the backpack to move through containers, even if it is not empty.
The hook is also needed to access the backpack when dying, as the backpack will fall out before the OnPlayerDeath hook is triggered.
This is a quick crutch that will prevent a backpack from falling out of a corpse if it has resources. And after that it can only be stuffed into a backpack slot
private bool CanDropBackpack(Item backpack, PlayerInventory inventory)
{
ItemModBackpack component = backpack.info.GetComponent<ItemModBackpack>();
if (component != null)
{
component.containerVolumeWhenFilled = 0;
NextTick(() =>
{
component.containerVolumeWhenFilled = 1;
});
}
return false;
}
Merged with changes, thanks!
object OnBackpackDrop(Item backpack, PlayerInventory inventory)