Skip to content
RustPluginGenerator
CS0201Oxide + Carbon

Fix CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement (Oxide)

CS0201 means the compiler found an expression that produces a value but nothing consumes it, so the line does nothing. In Oxide plugins this is almost always a missing assignment operator, e.g. writing `item.amount * 2;` instead of `item.amount *= 2;`.

Server console
Error while compiling GatherBoost:
[1] Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement at 36:13

Why it happens

Roslyn only accepts a limited set of expressions as standalone statements: assignments, method calls, ++/--, await and new. A bare arithmetic or comparison line such as item.amount * 2;, player.health + 50; or a == b; is a value-producing expression with no effect, so it is rejected. In plugin code this usually happens when an admin intends to modify a value but forgets the assignment half of the operator, or when a leftover scratch line from debugging stays in the file after the real logic was moved somewhere else. The compiler reports the line and column of the offending expression (here 25:13), and Oxide prints the numbered message under Error while compiling GatherBoost: while the plugin stays unloaded.

How to fix it

  1. Read the line and column in the Oxide message (at 25:13) and open that line in the .cs file.
  2. Decide what the expression was supposed to do. If it should change a value, add the assignment: item.amount *= 2;, player.health += 25f;, block.health = 500f;.
  3. If the line was only a leftover calculation or comparison, delete it or assign its result to a variable you actually use, e.g. int doubled = item.amount * 2;.
  4. If the line was meant to call a method but the parentheses are missing, add them: item.MarkDirty(); rather than item.MarkDirty;.
  5. Save the file so Oxide recompiles it automatically, or run oxide.reload GatherBoost. The load succeeds when you see Loaded plugin GatherBoost v1.0.0 by RustPluginGenerator and no Error while compiling block.

Before and after

BeforeFails
using System.Collections.Generic;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("GatherBoost", "RustPluginGenerator", "1.0.0")]
    [Description("Doubles the amount of resources a player gathers")]
    public class GatherBoost : RustPlugin
    {
        private const string PermBoost = "gatherboost.use";
        private const string PermAll = "gatherboost.all";

        private void Init()
        {
            permission.RegisterPermission(PermBoost, this);
            permission.RegisterPermission(PermAll, this);
        }

        private void OnDispenserGather(ResourceDispenser dispenser, BaseEntity entity, Item item)
        {
            var player = entity as BasePlayer;
            if (player == null || item == null)
            {
                return;
            }

            if (!permission.UserHasPermission(player.UserIDString, PermBoost))
            {
                if (player.currentTeam == 0)
                {
                    return;
                }
            }

            item.amount * 2;
            player.ChatMessage("Gathered " + item.amount + " x " + item.info.displayName.english);
        }
    }
}
AfterFixed
using System.Collections.Generic;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("GatherBoost", "RustPluginGenerator", "1.0.0")]
    [Description("Doubles the amount of resources a player gathers")]
    public class GatherBoost : RustPlugin
    {
        private const string PermBoost = "gatherboost.use";
        private const string PermAll = "gatherboost.all";

        private void Init()
        {
            permission.RegisterPermission(PermBoost, this);
            permission.RegisterPermission(PermAll, this);
        }

        private void OnDispenserGather(ResourceDispenser dispenser, BaseEntity entity, Item item)
        {
            var player = entity as BasePlayer;
            if (player == null || item == null)
            {
                return;
            }

            if (!permission.UserHasPermission(player.UserIDString, PermBoost))
            {
                if (player.currentTeam == 0)
                {
                    return;
                }
            }

            item.amount *= 2;
            player.ChatMessage("Gathered " + item.amount + " x " + item.info.displayName.english);
        }
    }
}

FAQ

Why did the compiler accept `item.amount *= 2;` but not `item.amount * 2;`?

*= is an assignment, which is one of the statement forms the C# grammar allows. * alone just computes a number and throws it away, so Roslyn rejects it as a statement. Use the compound operator when you want to modify the existing value.

The line looks like a real function call. Why is it still CS0201?

Check for missing parentheses or a typo in the member name. item.MarkDirty; is a member access expression, not a call, and it also triggers CS0201. Writing item.MarkDirty(); turns it into a call statement. A misspelled method name usually produces CS1061 instead.

Does CS0201 affect the other plugins on my server?

No. Oxide drops only the file that failed from the compile batch and loads the rest. CS0201 is a compile-time error, so GatherBoost is never loaded; fix the line, save, and Oxide recompiles that single file.

Can a warning line in the console point me to the file?

Yes. The block starts with Error while compiling <PluginName>: and each numbered entry ends with line and column. The exact source text is not printed in the console for Oxide; open the file at the reported line, or check oxide/logs if you need the full compiler output.

Different error?

Paste the full console output and get the cause and a fix in plain English.

Open the error explainer

Skip the debugging

Generated plugins are compiled before you get them, and compiler errors are fixed automatically.

Generate a plugin

2 free plugins a month, no card.

Last updated Oct 26, 2026.

Get plugins that compile first time

Generate