Jump to content

C# Server Crash onPlayerDisconnect Event


Recommended Posts



Im scripting a gamemode for Rage MP with c# and run into a problem which i cant fix.

Everytime a player disconnects from my server my whole server crashes with the exception:

  Nachricht(Message) = Parameter count mismatch.
  Quelle(Source) = System.Private.CoreLib
   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at GTANetworkInternals.EventHandler.Parse(Event _event, Object[] arguments)

My code:

        public void OnPlayerDisconnected(Client player)
            NAPI.Util.ConsoleOutput(player.SocialClubName + " has left");

If I add the parameter DisconnectionType it dosent changes, still crashes.

ServerEvents like Event.OnPlayerConnected work perfectly.

What I already tried:
My Bootstrapper.dll is refered from newest bridge-zip, no nuget used
Rage-MP Bridge has the newest Bootstrapper.dll at runtime folder
My Rage-MP (Client & Server) is at the newest version
Changed .NET Core Framework, dosent matter
Visual Studio and all other programs used are up to date (VS19)


What can I do to fix this? Nobody from our team (3-persons) could fix this, everyone has the same issue.

I hope you can help me
I'm looking forward to helpful answers




Link to comment
Share on other sites

Thank you for your reply.

Now it works. Sometimes the simplest things are the hardest to see, Thanks. But why is it needed to always have a third parameter with "string reason" when there is no reason when a player disconnects?

Also the method takes very long to complete. When i close GTA it takes like 10-15 seconds until the message "player disconnected" gets written.
Is this regular or am i missing something?


Link to comment
Share on other sites

Hello Tamasu,

first a hint from a person who has worked as a developer: Read the error messages. In 99% of the cases they already tell you whats the problem. In this case the interesting point was "Nachricht(Message) = Parameter count mismatch" which tells you, that the server is using more or less parameters than you use in your code. If you looked this up in the Wiki, you'd see, that the Server is always firing the event with three parameters as all three of them are defined as required. This should answer your first question. The reason parameter only gets filled, if the player was kicked or banned.

The reason for having to wait 10-15 seconds until the player disconnected gets written is the way you quit the game:

  1. If you quit the intended way by RageMP (F1 -> Quit), the Event is fired immediately since it sends the right message to the Server before quitting the game normally like GTA 5 would.
  2. If you quit the intended way by GTA 5, no Message will be send to the server. For this reason, after a few seconds, the server will notice that you are disconnected and a timeout will occur.


Hope this was helpful for you. If you have further questions, feel free to hit me up with a message. I also understand German, which seems to be your native language.

Best wishes


Link to comment
Share on other sites

Hi runamaus,

thanks for your answer and your help. Now I can better understand why it takes some time until the method is completed.

Didn't knew what parameter count mismatch meant. Just started to go more in-depth-c#, I learned basic java at school.
I checked the wiki but I thought it isnt needed because my code never checked something with reason and it was always null. (Haven't tried to kick myself, lol.)

Also thanks for your tips for insight of a developer. I just started to study Applied Computer Science in Germany. :)


Link to comment
Share on other sites

Hey Tamasu,

you are welcome. :) If you ever need some help understanding such issues, feel free to hit me up at discord if you want to: csruna#0001 ... :D I started studying aswell shortly, but I have chosen IT-Security over Computer Science :D

Best wishes


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...