OnPlayerChat

Hello,
I am working on a little Rust plugin that tell the number of connected players when a user says "!pop" in the chat.
It works, but the server print the number of connected player BEFORE the player message.
Here is the code :

 void OnPlayerChat(BasePlayer player, string message)   {
            if (message.Contains("!pop") || message.Contains("!player")) {
                var playerCount = BasePlayer.activePlayerList.Count;
                PrintToChat("<color=#FF7400>[SERVER]</color> There are currently <color=green>"+playerCount+"</color> players online");
            }
}​

Here is the execution:


Do you know how I can have the player message ("!pop") before the server print the answer ("there are 2 players connected")

Thank you
Michael

Hi,
the image isn't loading for me, but I guess this could work for you?

        void OnPlayerChat(BasePlayer player, string message, ConVar.Chat.ChatChannel channel)
        {
            if (message != "!pop" && message != "!player")
                return;

            timer.Once(0.01f, () =>
            {
                Server.Broadcast($"There are currently {BasePlayer.activePlayerList.Count} players");
            });
            
        }
​

Thank you, you are a genius !! It works perfectly :)