1. hello this works fine but the last update destroys it.

    here is my code.
    Code:
    void OnPlayerChat(ConsoleSystem.Arg arg)
            {
                var message = arg.GetString(0);
                if (message.Contains("!players"))
                {
                    var playerCount = BasePlayer.activePlayerList.Count;
                    if (playerCount > 1)
                        rust.BroadcastChat($"There are currently {playerCount} players online.");
                    else
                        rust.BroadcastChat("There is currently 1 player online.");               
                }
            }

    ERROR says



    Code:
    Failed to call hook 'OnPlayerChat' on plugin 'PlayerCount v1.0.3' (NullReferenceException: Object reference not set to an instance of an object)...........

    hope someone can help.
    thanks
     
  2. Wulf

    Wulf Community Admin

    You're sending the message as a prefix, you need to send it as the message.

    rust.BroadcastChat(null, "There is currently 1 player online.");