Page 1 of 1

Events.ObjectCreatedCallback cannot detect IPlayer

Posted: Fri Mar 25, 2022 6:11 pm
by NearHuscarl
I cannot use Events.ObjectCreatedCallback to detect whether a new player is spawned. Minimal code example:

Code: Select all

Events.ObjectCreatedCallback.Start(os =>
{
    foreach (var o in os)
    {
        if (o is IPlayer)
        {
            Game.WriteToConsole(o.Name);
        }
    }
});
By the way, I'd want to have a separate event to detect if a new player is spawned since I am not interested in listening to hundreds of other objects. Something like:

Code: Select all

Events.PlayerCreatedCallback.Start((IPlayer[] players) => { /* ... */ });