mbsnero Posted December 16, 2019 Posted December 16, 2019 (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 December 16, 2019 by mbsnero
MrPancakers Posted December 17, 2019 Posted December 17, 2019 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.
mbsnero Posted December 17, 2019 Author Posted December 17, 2019 (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 December 17, 2019 by mbsnero
Doom Posted December 19, 2019 Posted December 19, 2019 Where do you get the player object from in your server-side code?
mbsnero Posted December 20, 2019 Author Posted December 20, 2019 thanks) I thought it was a global variable
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