Hey there!

I have spotted a race condition when a player disconnects while a "gametip" is shown in:

  • SendToastToActivePlayers
The problem is how the timer is used to hide the game tip, and "timer.Once(gameTipDuration, () =>" is used several times (19x) in the plugin source, so it is not only 1 place where it can occur. Should the player disconnect while the timer runs, it will throw this error:

Timer of 20s has failed in 'Guess The Number v2.2.3 by Mabel' [callback] (Object reference not set to an instance of an object) at void BasePlayer.SendConsoleCommand(string command, params object[] obj) at void Oxide.Plugins.GuessTheNumber.SendToastToActivePlayers(string messageKey)+() => { } in /home/container/carbon/plugins/GuessTheNumber.cs:line 1080 at Timer Oxide.Plugins.Timers.In(float time, Action action)+() => { } in /__w/Carbon/Carbon/Carbon.Core/Carbon.Components/Carbon.Common/src/Oxide/Libraries/Timer.cs:line 50

Hint: Your line numbers will differ - I have added a few lines to your plugin source to have hooks for my Discord logging.

The timer should be called like this to prevent this race condition:


        // Capture the player's ID to safely check later
        string playerId = player.UserIDString;

        timer.Once(gameTipDuration, () =>
        {
            BasePlayer target = BasePlayer.FindByID(playerId);
            if (target != null && target.IsConnected)
            {
                target.SendConsoleCommand("gametip.hidegametip");
            }
        });​