1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. GTA Network forum is now in archive mode.

Listening for client event in server

Discussion in 'Scripting Help' started by VonHornmeister, Apr 4, 2018.

  1. VonHornmeister

    VonHornmeister New Member

    Messages:
    1
    Likes Received:
    0
    Joined:
    Apr 4, 2018
    My server cant seem to receive the data I send from client-side.

    Server-side
    Code:
    using GTANetworkAPI;
    
    namespace Login {
    public class Login : Script
    {
        public Login(API api)
        {
            /*
            Errors I get =>
            
             CS1061: 'API' does not contain a definition for 'onClientEventTrigger' and no extension method 'onClientEventTrigger' accepting a first argument of type 'API' could be found (are you missing a using directive
            or an assembly reference?)
           -> login.cs:7
    
            CS0103: The name 'OnClientEventTrigger' does not exist in the current context
           -> login.cs:7
             */
             API.onClientEventTrigger += OnClientEventTrigger;
             API.ConsoleOutput("Started");
        }
    
        public void OnClientEvent(Client player, string eventName, params object[] arguments)
        {
            API.ConsoleOutput("PRessed");
            if (eventName == "Login")
          {
                    API.ConsoleOutput(eventName);
                foreach(var item in arguments)
                {
                    API.ConsoleOutput(item.ToString());
                }
                API.SendChatMessageToPlayer(player, "Test");
          }
        }
      }
    }
    Client-side
    Code:
    mp.events.add('logInRequest', function() {
        const credentials = JSON.parse(arguments[0]);
    
        //API.triggerServerEvent("OnExample", credentials.email, credentials.password); <= gives me error that API is not defined
        mp.events.callRemote("OnExample", credentials.email, credentials.password); // <= Wont send or server cant receive
    });
    Any ideas?
     
  2. Darkmen

    Darkmen New Member

    Messages:
    1
    Likes Received:
    0
    Joined:
    Oct 18, 2018
    API is not job, please, use NAPI
     

Share This Page