Mateox Posted March 31, 2019 Share Posted March 31, 2019 Hi, I recently came back to RAGE mp, before that I used GTA:MP. Events like: OnPlayerConnected, OnPlayerSpawn do not work in C# for me. The only event I can handle is OnResourceStart. Sometime, when player closes the game, server throws an exception: Unhandled Exception: System.Reflection.TargetParameterCountException: Parameter count mismatch. 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) To fix this issue I have tried both Linux and Windows servers. I have also tried to copy Bootstrap.dll from server's runtime the resource Link to comment Share on other sites More sharing options...
Division Posted March 31, 2019 Share Posted March 31, 2019 (edited) thats because your parameters given into your method when the server is triggering the event does not match with the expected ones. You have to do: (C#) [ServerEvent(Event.PlayerConnect)] public void OnPlayerConnect(Client player) { //logic } If you do not enter the client parameter, you'll get this error message like you've pasted. Edited March 31, 2019 by Division Link to comment Share on other sites More sharing options...
Mateox Posted March 31, 2019 Author Share Posted March 31, 2019 Thanks for the reply @Division. Well, unfortunately that's exactly what I have in my code. But it has to be something wrong with the code or another dll file because original resource 'welcomemessages' which basically is sending message when I am connecting, is working fine. Link to comment Share on other sites More sharing options...
Division Posted March 31, 2019 Share Posted March 31, 2019 are you using c# on server-side? If so, are you referencing your classes with GtaNetworkAPI.Script? Link to comment Share on other sites More sharing options...
Mateox Posted March 31, 2019 Author Share Posted March 31, 2019 Yes, let me post my code 😅 using GTANetworkAPI; namespace GLP { public class Main : Script { private Authorisation.Authenticator authenticator; [ServerEvent(Event.ResourceStart)] public void ResourceStart() { StartAuthenticator(); } [ServerEvent(Event.PlayerConnected)] public void OnPlayerConnected(Client player) { NAPI.Log.Exception("PlayerConnected"); authenticator.PlayerConnected(player); } [ServerEvent(Event.PlayerSpawn)] public void OnPlayerSpawn(Client player) { NAPI.Log.Exception("PlayerSpawned"); authenticator.PlayerSpawned(player); } #region authentication private void StartAuthenticator() { authenticator = new Authorisation.Authenticator(this); } #endregion authentication } } Actually should... Authenticator class also be referencing to Script? Link to comment Share on other sites More sharing options...
Division Posted March 31, 2019 Share Posted March 31, 2019 That all looks fine. No need to reference Script to Authenticator because you're already in that event when you use this class. How do you know ResourceStart is working? Have you done an output for test, if this gamemode is loading? You need to define this in meta.xml file Link to comment Share on other sites More sharing options...
Mateox Posted March 31, 2019 Author Share Posted March 31, 2019 I went through this tutorial It allowed me to put a break points. OnResourceStart triggers the break point but other events don't. That's why I put the logging just to make sure. Ok, missing reference to Script was the problem! Thank's for helping me out 😉 Link to comment Share on other sites More sharing options...
MiMIMi Posted April 1, 2019 Share Posted April 1, 2019 Had exact same problem. What I did is I copied bootstrapper from RageMP runtimes to NuGet package and it worked perfectly. Link to comment Share on other sites More sharing options...
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