local PLUGIN = PLUGIN


util.AddNetworkString("INVENTORY.ValidateItemData")

function PLUGIN:InitializedPlugins()
    for b, c in pairs(ix.stalker.slots) do
        local d, d2 = c[1], c[2]
        ix.inventory.Register(b, d, d2, true)
    end
end

function PLUGIN:OnCharacterCreated(a, b)
    local d = b:GetID()

    for d2, d3 in pairs(ix.stalker.slots) do
        ix.inventory.New(d, d2, function(d4)
            table.insert(b.vars.inv, d4)
            d4:AddReceiver(a)
            d4:Sync(a)
        end)
    end
end

function PLUGIN:CanTransferItem(a, b, c)
    if c and c.vars and ix.stalker.slots[c.vars.isBag] then
        local d2 = a.slot
        if d2 and string.find(c.vars.isBag, d2) then
            local d3 = c:GetItems()
            if d3 and table.Count(d3) > 0 then
                return false
            end
            local status = hook.Run("NewCanTransferItem", a, b, c)
            if status == false then
                return false
            end

            return true
        else
            local status = hook.Run("NewCanTransferItem", a, b, c)
            if status == false then
                return false
            end

            return false
        end
    else
        return true
    end
end

function PLUGIN:OnItemTransferred(a, b, c)
    local d2 = a.player or a:GetOwner()

    if b and b.vars and ix.stalker.slots[b.vars.isBag] then
        if not a then
            return
        end

        if a.ActionEquipment then
            a:ActionEquipment(false)
        end

        // net.Start("ri")
        // net.Send(d2)
    end

    if c and c.vars and ix.stalker.slots[c.vars.isBag] then
        if not a then
            return
        end

        if a.ActionEquipment then
            a:ActionEquipment(true)
        end

        // net.Start("ri")
        // net.Send(d2)
    end
end
