[Help] [C#] Messages while connecting

I’ve been looking at https://wiki.fivem.net/wiki/Event:PlayerConnecting
And I can’t for the life of me figure out how to convert the 20 seconds lua example to c#
Anyone able to help me with this?

It seems like the deferring logic does not exist in c#
When I do BaseScript.Delay’s it just waits in the background but the game does start loading everything, getting past it.

use dynamic for the deferrals. It works.

Same as the lua example does:

EventHandlers.Add("playerConnecting", new Action<Player, string, dynamic, dynamic>(HandlePlayerConnecting));
 
private void HandlePlayerConnecting([FromSource]Player player, string playerName, dynamic kickCallback, dynamic deferral)
{
    for(int i = 0; i < 20; i++)
    {
        deferral.update("Hi!");
        Delay(1000);
    }

    deferral.done();
}

/me facepalms

I totally missed that last parameter

Thanks guys!

Off topic, but haven’t seen much about it: is there a benefit to using C# ? I’m familiar with the language but have been using Lua just because I can make quick edits in vi on my server without recompiling. But if there’s an optimization benefit, I may make the switch.

Afaik C# execute native calls faster than lua, but needs more RAM.