A simple static EventLog class for the HUD. It stores messages in a static List<string>, exposes Add to append a message (and also logs it to the developer console), and Clear to empty the list.
using Sandbox;
using System.Collections.Generic;
public static class EventLog
{
// This holds all the messages so your UI can read them later
public static List<string> Messages { get; private set; } = new();
public static void Add( string message )
{
// 1. Prints it to the player HUD log system (we hook this up to your UI later)
Messages.Add( message );
// 2. Also prints it to the developer console so you can see it right now
Log.Info( message );
}
public static void Clear()
{
Messages.Clear();
}
}