This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

Events.ObjectCreatedCallback cannot detect IPlayer

Here you can find all solved gameplay problems and bugs (beginning from Pre-Alpha 1.8.8).
Forum rules
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
Locked
NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

Events.ObjectCreatedCallback cannot detect IPlayer

Post by NearHuscarl » Fri Mar 25, 2022 6:11 pm

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) => { /* ... */ });
0 x
Image

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Fri Apr 18, 2025 11:39 am

Added to version 1.4.1, Events.PlayerCreatedCallback
0 x
Gurt

Locked