Rafikus

Event PlayerConnected not triggering

Recommended Posts

Hey,

Im new to the RAGE-MP.
I started moving from GT-MP and have issue with events. PlayerConnected doesn't trigger also PlayerDisconnected tells me that i have wrong number of parameters dispite using sample code.

using GTANetworkAPI;

namespace RP
{
    public class ConnectionHandler : Script
    {
        [ServerEvent(Event.PlayerConnected)]
        public void OnPlayerConnect(Client player)
        {
            NAPI.Util.ConsoleOutput("Connected");
            World.Players.Add(player, new Player(player));
        }

        [ServerEvent(Event.PlayerDisconnected)]
        public void OnPlayerDisconnect(Client player, DisconnectionType type, string reason)
        {
            if(type == DisconnectionType.Left)
                NAPI.Chat.SendChatMessageToAll("~b~" + player.Name + "~w~ left. " + reason);

            World.Players.Remove(player);
        }
    }
}

I downloaded GTANetworkAPI version 3.6 as NuGet Package

  • Like 2

Share this post


Link to post
Share on other sites

If you're using 0.3.6 Nuget, make sure to copy the Bootstrapper from runtimes folder into the path where the Nuget package is installed.

  • Like 3

Share this post


Link to post
Share on other sites
47 minutes ago, Xabi said:

If you're using 0.3.6 Nuget, make sure to copy the Bootstrapper from runtimes folder into the path where the Nuget package is installed.

By runtimes you mean RAGEMP\server-files\bridge\runtime\runtimes or RAGEMP\server-files\bridge\runtime ?
The only Bootstrapper i have is located at RAGEMP\server-files\bridge\runtime, and it's weight is the same as in Nuget package.

I replaced it and nothing changed.

Edited by Rafikus

Share this post


Link to post
Share on other sites
6 minutes ago, Rafikus said:

By runtimes you mean RAGEMP\server-files\bridge\runtime\runtimes or RAGEMP\server-files\bridge\runtime ?
The only Bootstrapper i have is located at RAGEMP\server-files\bridge\runtime, and it's weight is the same as in Nuget package.

I replaced it and nothing changed.

Yes, that's the one i mean. You replaced the one located on the Nuget package's path, right? And after doing that, did you compile your gamemode?

  • Like 3

Share this post


Link to post
Share on other sites
3 minutes ago, Xabi said:

Yes, that's the one i mean. You replaced the one located on the Nuget package's path, right? And after doing that, did you compile your gamemode?

I thought i did replace it. I did now. Rebuilded my gamemode and now it works.

Thank you very much.

Is that written somewhere in wiki? If no, how do you know that you need to do this?

Share this post


Link to post
Share on other sites
4 minutes ago, Rafikus said:

I thought i did replace it. I did now. Rebuilded my gamemode and now it works.

Thank you very much.

Is that written somewhere in wiki? If no, how do you know that you need to do this?

It's the solution George gave on Discord, seems that there were some issues with 0.3.6 Nuget package.

  • Like 3

Share this post


Link to post
Share on other sites
On 11/28/2018 at 1:17 AM, Xabi said:

If you're using 0.3.6 Nuget, make sure to copy the Bootstrapper from runtimes folder into the path where the Nuget package is installed.

Same issue here. But this doesn't helped. 

 

Started to throw that exception:


==================[9.12.2018 14:38:03]==================
System.Reflection.TargetParameterCountException: Parameter count mismatch.
   at object[] System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
=========================================================
 

Share this post


Link to post
Share on other sites

I have followed this, even done a successful rebuild of the solution, but events still wont be triggered. @Xabi any thoughts? 

Share this post


Link to post
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.