Sign in to follow this  
sancio

CEF question

Recommended Posts

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 by sancio

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.