VonHornmeister Posted April 4, 2018 Posted April 4, 2018 (edited) My server cant seem to receive the data I send from client-side. Server-side 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 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? FIXED: Server-side code using GTANetworkAPI; public class LoginEvents : Script { [RemoteEvent("Login")] // <= I was missing that part public void LoginEvent(Client player, string test) { API.ConsoleOutput("Pressed: " + test); } } Client-side code mp.events.add('logInRequest', function() { const credentials = JSON.parse(arguments[0]); mp.events.callRemote("Login", credentials.email, credentials.password); }); Edited April 4, 2018 by VonHornmeister Fixed
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