Skip to main content

mp.gui.emmit

The client → CEF-page bridge. Runs a JavaScript string inside the active browser page — the primary way a gamemode's clientside drives its UI.

mp.gui.emmit(js)​

Executes js in the context of the current CEF browser. Use it to call functions your interface exposes on window (routing, screen fades, data updates, custom events).

// switch the visible view
mp.gui.emmit(`window.router.setView("Auth")`);

// fade the UI overlay out to reveal the page
mp.gui.emmit(`window.FadeScreen(false, 1000)`);

// push data into the page
mp.gui.emmit(`window.charStore.setMoney(${JSON.stringify(money)})`);

// fire a page-side event
mp.gui.emmit(`window.events.callEvent("cef.blackjack.bet", ${bet})`);

Because the argument is a JS string, interpolate values with JSON.stringify to keep quoting and escaping correct.

Page → client​

Inside the CEF page, window.mp lets your interface talk back to the client:

// in your interface HTML/JS
window.mp.trigger("client.auth.login", username, password); // fire a client event
window.mp.events.callRemote("account.save", data); // relay to the server
window.mp.events.add("client.charStore.Money", (v) => { /* client called us */ });

window.mp.trigger / window.mp.events.callRemote route to the client's event system; mp.gui.emmit(...) from the client runs JS back in the page. Together they form the two-way UI bridge.

Input focus​

When the cursor is visible (mp.gui.cursor.visible = true) the CEF overlay holds input focus, so keyboard and mouse reach the page (login fields, menu navigation). Hide the cursor to return control to the game.