Jump to content

How to ban some slots in Inventory bar so that they wouldn't fill by Items I picked up


Recommended Posts

GLOBAL.TUNING.BAN_SLOTS_COUNT = GetModConfigData("ban_slots_count")
local function GetNextAvailableSlotExcludeSlots(self)
    local original_fun = self.GetNextAvailableSlot   
    self.GetNextAvailableSlot = function(self,item)
        local prefabname = nil
        if item.components.stackable ~= nil then
            prefabname = item.prefab
            --check for stacks that aren't full
            for k, v in pairs(self.equipslots) do
                if v.prefab == prefabname and v.components.equippable.equipstack and v.components.stackable and not v.components.stackable:IsFull() then
                    return k, self.equipslots
                end
            end
            for k, v in pairs(self.itemslots) do
                if v.prefab == prefabname and v.components.stackable and not v.components.stackable:IsFull() then
                    return k, self.itemslots
                end
            end
            local overflow = self:GetOverflowContainer()
            if overflow ~= nil then
                for k, v in pairs(overflow.slots) do
                    if v.prefab == prefabname and v.components.stackable and not v.components.stackable:IsFull() then
                        return k, overflow
                    end
                end
            end
        end

        --check for empty space in the container
        local empty = nil
        -- where I modded
        for k = TUNING.BAN_SLOTS_COUNT, self.maxslots do
            -------
            if self:CanTakeItemInSlot(item, k) and not self.itemslots[k] then
                if prefabname ~= nil then
                    if empty == nil then
                        empty = k
                    end
                else
                    return k, self.itemslots
                end
            end
        end
        return empty, self.itemslots
    end
end
AddComponentPostInit("inventory", GetNextAvailableSlotExcludeSlots)

That's my way to do it ↑↑↑ , but I have no able to make it a Client Only Mod .

So I ask some other way, and make sure it could work client only

Link to comment
Share on other sites

10 hours ago, PotterLee said:

I have no able to make it a Client Only Mod .

So I ask some other way, and make sure it could work client only

The only way to make it a client only mod is to have the client poll/hook into inventory pickup events and have it manually move the items through an RPC call.

All components are controlled by the server and the client manipulates them via inputs from RPCs.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...