Pintex

Events dosn't trigger.

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

I got the same problem like @Rafikus. Event.PlayerConnected doesn´t trigger and Event.PlayerDisconnected crashes the server.

Anyone an idea how to fix this?

Share this post


Link to post
Share on other sites
14 minutes ago, Flashrex said:

I got the same problem like @Rafikus. Event.PlayerConnected doesn´t trigger and Event.PlayerDisconnected crashes the server.

Anyone an idea how to fix this?

I got an answer here.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.