Jump to content
RAGE Multiplayer Community

Events dosn't trigger.


Pintex
 Share

Recommended Posts

using System;
using GTANetworkAPI;

namespace roleplay
{
    public class Main : Script
    {

        public Main()
        {
            
        }

        [ServerEvent(Event.PlayerSpawn)]
        public void OnPlayerConnected(Client player)
        {
            NAPI.Util.ConsoleOutput("Roleplay wurde sasd!");
        }
        [ServerEvent(Event.ResourceStart)]
        public void OnResourceStart()
        {
            NAPI.Util.ConsoleOutput("Roleplay wurde gestartet!");
        }

	}

}

This is my code and the onPlayerConnected Event make nothing.
I don't know why.
I hope you can help me!
Thank you.

Link to comment
Share on other sites

  • 2 weeks later...

Hey,

I'll just reply here rather than creating new thread.


I have a problem where i use Player Connected and Player Disconnected event,
PlayerConnected does not trigger
PlayerDisconnected crash server when leaving, it also leaves log:

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

Did something changed with the parameters for PlayerDisconnected?

using GTANetworkAPI;

namespace roleplay
{
    class ConnectionHandler : Script
    {
        
        [ServerEvent(Event.PlayerConnected)]
        public void OnPlayerConnected(Client player)
        {
            NAPI.Util.ConsoleOutput("Connected");
        }

        [ServerEvent(Event.PlayerDisconnected)]
        public void OnPlayerDisconnected(Client player, DisconnectionType type, string reason)
        {
            switch (type)
            {
                case DisconnectionType.Left:
                    NAPI.Chat.SendChatMessageToAll("~b~" + player.Name + "~w~ has quit the server.");
                    break;

                case DisconnectionType.Timeout:
                    NAPI.Chat.SendChatMessageToAll("~b~" + player.Name + "~w~ has timed out.");
                    break;

                case DisconnectionType.Kicked:
                    NAPI.Chat.SendChatMessageToAll("~b~" + player.Name + "~w~ has been kicked for " + reason);
                    break;
            }
        }
    }
}

Anyone with the same bug? I don't use this events anywhere else in project.

  • Like 1
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
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...