Tamasu Posted October 14, 2019 Posted October 14, 2019 Hello, 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: System.Reflection.TargetParameterCountException HResult=0x8002000E Nachricht(Message) = Parameter count mismatch. Quelle(Source) = System.Private.CoreLib Stapelüberwachung(StackOverflow): 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: [ServerEvent(Event.PlayerDisconnected)] 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 Tamasu
MrPancakers Posted October 15, 2019 Posted October 15, 2019 What happens when you use the example on the wiki. I don't personally use C# so this might not change anything but the message says parameter count mismatch and the OnPlayerDisconnected event has 3, player, disconnectype and reason, do you not need all 3? 1
Tamasu Posted October 15, 2019 Author Posted October 15, 2019 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? Tamasu
runamaus Posted October 15, 2019 Posted October 15, 2019 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: 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. 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 Runa
Tamasu Posted October 15, 2019 Author Posted October 15, 2019 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. Tamasu
runamaus Posted October 18, 2019 Posted October 18, 2019 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 ... I started studying aswell shortly, but I have chosen IT-Security over Computer Science Best wishes Runa
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now