Jump to content

Recommended Posts

Posted (edited)
// SERVER SIDE

mysql.connection.query(`INSERT INTO users(login, password, email) VALUES('${login}', '${password}', '${email}')`, function(err, results) {
  if(err) {
  	console.log(err);
  }

  console.log('success reg'); // This log run
  player.call("loginHandler", ["success reg"]);
});

// CLIENT SIDE

mp.events.add("loginHandler", (handle) => {
  // this code don't work
  loginBrowser.destroy();
  mp.gui.chat.push("Login successful");
  mp.gui.chat.activate(true);
  mp.gui.cursor.show(false, false);
});

Why this code don't work? I don't understand why the event is not triggered

Edited by mbsnero
Posted

Without specifying your file structure, all I can assume is your clientside code hasn't been referenced and therefore you're gamemode cannot see that event. Is the code inside index.js in your client_packages folder? If not, have you used require('path/to/directory')? If you did that, then your path may be incorrect.

Posted (edited)
8 hours ago, MrPancakers said:

Without specifying your file structure, all I can assume is your clientside code hasn't been referenced and therefore you're gamemode cannot see that event. Is the code inside index.js in your client_packages folder? If not, have you used require('path/to/directory')? If you did that, then your path may be incorrect.

// It's index.js
require('./login.js');
mp.gui.chat.show(true);
mp.gui.chat.activate(false);

// It's login.js, and this file connected in index.js.
// THIS CODE WORKS
var loginBrowser = mp.browsers.new("package://login/index.html");
mp.gui.cursor.show(true, true);
mp.events.add("loginDataToServer", (type, login, password, email) => {
  mp.events.callRemote("sendDataToServer", type, login, password, email);
});

//THIS CODE DON'T WORKS
mp.events.add("loginHandler", (handle) => {
  loginBrowser.destroy();
  mp.gui.chat.push("Login successful");
  mp.gui.chat.activate(true);
  mp.gui.cursor.show(false, false);
});

No, everything is connected and working, only this event does not work

Edited by mbsnero

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.
×
×
  • Create New...