[C#] Callback in EventHandler

Hello, any idea how to make this small piece of code to work?

Also, I’ve seen GetConvarInt in Lua and no idea how would I want to use it in C#, I haven’t found any documention about this command and what does it even do.

I’ve tried CallbackDelegate but that was just a random code which doesn’t work apparently. Thanks!

1 Like

Thanks to @Damien on the fivem discord I got it working.
You should use this instead Action<Player, string, CallbackDelegate>, the Player is well for your player, the string is for the player’s name and the CallbackDelegate acts as a function. As written on the wiki (https://wiki.fivem.net/wiki/Event:PlayerConnecting) the event in Lua takes 3 parameters :

  1. source: The player identifier of the connecting player. (implicit global)
  2. playerName: The name of the connecting player.
  3. setKickReason: A function that can be used to set a custom reason when canceling the event.

So I guess every time there’s a Lua function it requires to be called in a CallbackDelegate, you were just missing the Player argument, that’s just a reference for people encountering the issue!

you seem to be bad at searching: Native Reference - Cfx.re Docs

and what happens when you use this + how about dynamic (also you forgot to call CANCEL_EVENT so setKickReason won’t do anything)?