sancio Posted November 24, 2018 Share Posted November 24, 2018 (edited) Hey guys, Im creating notifications and cant get the reason why im getting 'undefined' in the message of notification. client-side notify.js script: let notifyBrowser = null; mp.events.add( 'receiveNotify', (msg, type, position, time) => { if (notifyBrowser == null ) { notifyBrowser = mp.browsers.new("package://gamemode/modules/UI/notifications/index.html"); notifyBrowser.execute(`sendNotify('${msg}', '${type}', '${position}', ${time})`); } else { notifyBrowser.destroy(); notifyBrowser = null; mp.events.call('receiveNotify', msg, type, position, time); } }, 'deleteNotify', () => { if (notifyBrowser != null) { notifyBrowser.destroy(); notifyBrowser = null; } } ); server-side: notice.js module.exports = { sendNotify: function (player, msg = "", type = "", position = "bottom-right", time = 1500) { player.call('receiveNotify', msg, type, position, time); }, sendNotifyToAll: function (msg, type, position = 'bottom-right', time = 1500) { mp.players.forEach ( (player, id) => { player.call('receiveNotify', msg, type, position, time); }); } }; and where Im using that: gm.notification = require('./notifications/notice.js'); gm.notification.sendNotify(player, "Sėkmingai prisijunget prie savo paskyros!", "success", "bottom-right", 1500); CEF html code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="../assets/css/uikit.css"> </head> <body> <script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"> </script> <script src="../assets/js/uikit.js"></script> <script src="../assets/js/uikit-icons.js"></script> <script type="text/javascript"> function sendNotify(msg, type, position, time) { UIkit.notification({ message: msg, status: type, pos: position, timeout: time }); setTimeout(function() { mp.trigger('deleteNotify'); }, time); } </script> </body> </html> I tried to debug so I get msg - [object Object], type - undefined, position - undefined, time - undefined. Some ideas? Screenshot: https://prnt.sc/lmedav it doesn't even change position of this notify. Edited November 24, 2018 by sancio Link to comment Share on other sites More sharing options...
sancio Posted November 24, 2018 Author Share Posted November 24, 2018 Fixed! Close the topic. Link to comment Share on other sites More sharing options...
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