Skip to content
RustPluginGenerator
CS0117Oxide + Carbon

Fix CS0117: 'BasePlayer' does not contain a definition for 'activePlayers' (Oxide)

The plugin references a static member of BasePlayer that does not exist — activePlayers was never a real API name. The list of online players is BasePlayer.activePlayerList, and once you use that the file compiles and loads.

Server console
Error while compiling OnlineCount:
[1] 'BasePlayer' does not contain a definition for 'activePlayers' at 14:54

Why it happens

CS0117 means you named a member on a type and Roslyn could not find any field, property or method with that name on it. Here the type is BasePlayer and the name is activePlayers. Rust exposes the online player collection as the static field BasePlayer.activePlayerList (a ListHashSet<BasePlayer>); there is no activePlayers. This usually comes from memory, from an old snippet, or from mixing up the name with the per-player instance properties (displayName, userID) that hang off each BasePlayer object rather than the class. Because the mistake is a member lookup, not a namespace problem, the compiler points at the exact line and column where the bad name sits. It is a compile-time error: Oxide drops that one file from the batch, logs the numbered message, and the plugin is not loaded until the name is corrected. Carbon reports the same error with its own format.

How to fix it

  1. Open the file and go to the line and column from the log (20:42 in the example). You will see something like BasePlayer.activePlayers or foreach (var p in BasePlayer.activePlayers).
  2. Replace activePlayers with activePlayerList. Note it is a field on the type, not a method, so no parentheses.
  3. Check the declared type of what you iterate: activePlayerList yields BasePlayer, so the loop variable should be BasePlayer (or use var).
  4. If you also need sleeping bodies, that is BasePlayer.sleepingPlayerList, again a static field.
  5. Save the file. Oxide recompiles automatically; run oxide.reload OnlineCount if you want to force it.
  6. Confirm success: the console prints Loaded plugin OnlineCount v1.0.0 by RustPluginGenerator and no Error while compiling line for the file.

Before and after

BeforeFails
using System.Collections.Generic;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Online Count", "RustPluginGenerator", "1.0.0")]
    [Description("Shows how many players are currently online.")]
    public class OnlineCount : RustPlugin
    {
        private void OnServerInitialized()
        {
            int count = 0;

            foreach (BasePlayer player in BasePlayer.activePlayers)
            {
                if (player == null || !player.IsConnected)
                    continue;

                count++;
            }

            PrintWarning("Online players: " + count);
        }

        [ChatCommand("online")]
        private void CmdOnline(BasePlayer player, string command, string[] args)
        {
            if (player == null)
                return;

            List<BasePlayer> online = new List<BasePlayer>();

            foreach (BasePlayer target in BasePlayer.activePlayers)
            {
                if (target == null || !target.IsConnected)
                    continue;

                online.Add(target);
            }

            player.ChatMessage("Online right now: " + online.Count);

            foreach (BasePlayer target in online)
            {
                if (target == null)
                    continue;

                player.ChatMessage("- " + target.displayName);
            }
        }
    }
}
AfterFixed
using System.Collections.Generic;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Online Count", "RustPluginGenerator", "1.0.0")]
    [Description("Shows how many players are currently online.")]
    public class OnlineCount : RustPlugin
    {
        private void OnServerInitialized()
        {
            int count = 0;

            foreach (BasePlayer player in BasePlayer.activePlayerList)
            {
                if (player == null || !player.IsConnected)
                    continue;

                count++;
            }

            PrintWarning("Online players: " + count);
        }

        [ChatCommand("online")]
        private void CmdOnline(BasePlayer player, string command, string[] args)
        {
            if (player == null)
                return;

            List<BasePlayer> online = new List<BasePlayer>();

            foreach (BasePlayer target in BasePlayer.activePlayerList)
            {
                if (target == null || !target.IsConnected)
                    continue;

                online.Add(target);
            }

            player.ChatMessage("Online right now: " + online.Count);

            foreach (BasePlayer target in online)
            {
                if (target == null)
                    continue;

                player.ChatMessage("- " + target.displayName);
            }
        }
    }
}

FAQ

What is the correct way to loop over online players?

Use foreach (BasePlayer player in BasePlayer.activePlayerList) and null-check inside the loop. The list is a static field on BasePlayer, so you access it through the type, not through an instance. For sleeping players use BasePlayer.sleepingPlayerList.

Why does the error show a line and column instead of the code?

Oxide prints numbered Roslyn diagnostics in the form [1] <message> at <line>:<column>. The code itself is not repeated in the console. Move to that position in the file; the unresolved member name is what the compiler could not resolve.

Is CS0117 the same as CS1061?

No. CS0117 fires when a member you name does not exist on a type at all, while CS1061 fires when the member is reached through an instance and is missing. Both are name mistakes; the fix is checking the actual API member name.

The plugin still does not show up after I fixed it. What now?

Check the newest entries in oxide/logs and look for any other compile error for the same file. One file with several errors reports them all at once; only when the Error while compiling block is gone does Loaded plugin ... appear.

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