Remco1337 Posted February 5, 2020 Share Posted February 5, 2020 (edited) Server side: mp.events.addCommand('createfaction', (player) => { if (player.data.adminLevel < 3) return gm.functions.returnUnauthorizedAdmin(player); player.call('openCreateFaction'); }); Clientside: // Factions var createFactionBrowser = null; mp.gui.cursor.show(true, true); mp.events.add("openCreateFaction", () => { mp.gui.chat.push("Opened faction creation!"); createFactionBrowser = mp.browsers.new("package://factions/create.html"); mp.gui.chat.activate(false); mp.gui.cursor.show(true, true); }); It shows the message and opens the browser but the controls won't be frozen and the cursor won't show. Edited February 5, 2020 by Remco1337 Link to comment Share on other sites More sharing options...
xForcer Posted February 7, 2020 Share Posted February 7, 2020 (edited) This happens because of these lines mp.gui.chat.activate(false); mp.gui.cursor.show(true, true); If they are next to each other, your cursor will not appear. We need a solution! Edit: @MrPancakers told me to use a timeout/timer and it WORKS! TL;DR: Use a timeout of 1ms to show the cursor after deactivating chat input Edited February 8, 2020 by xForcer Link to comment Share on other sites More sharing options...
Vernetti Posted February 17, 2020 Share Posted February 17, 2020 В 08.02.2020 в 02:45, xForcer сказал: This happens because of these lines mp.gui.chat.activate(false); mp.gui.cursor.show(true, true); If they are next to each other, your cursor will not appear. We need a solution! Edit: @MrPancakers told me to use a timeout/timer and it WORKS! TL;DR: Use a timeout of 1ms to show the cursor after deactivating chat input Timeout ? Maybe better using render event like this ? let stateCursor = true; mp.events.add(RageEnums.EventKey.RENDER, () => { if (mp.keys.isDown(0x12)) { if (!stateCursor) { mp.gui.cursor.show(true, true); stateCursor = true; } } else { if (stateCursor) { mp.gui.cursor.show(false, false); stateCursor = false; } } }); and u don't need to disable chat to show cursor Link to comment Share on other sites More sharing options...
xForcer Posted February 17, 2020 Share Posted February 17, 2020 8 minutes ago, Vernetti said: Timeout ? Maybe better using render event like this ? let stateCursor = true; mp.events.add(RageEnums.EventKey.RENDER, () => { if (mp.keys.isDown(0x12)) { if (!stateCursor) { mp.gui.cursor.show(true, true); stateCursor = true; } } else { if (stateCursor) { mp.gui.cursor.show(false, false); stateCursor = false; } } }); and u don't need to disable chat to show cursor The author asked for chatInput to be disabled and cursor shown when he has the browser opened. The solution I provided works perfectly for his use case, I myself am using it. You want him to press ALT key manually just to show the cursor after disabling the chatInput? Really? Link to comment Share on other sites More sharing options...
Vernetti Posted February 17, 2020 Share Posted February 17, 2020 (edited) 1 час назад, xForcer сказал: The author asked for chatInput to be disabled and cursor shown when he has the browser opened. The solution I provided works perfectly for his use case, I myself am using it. You want him to press ALT key manually just to show the cursor after disabling the chatInput? Really? anyway render event is more effective here instead of timer export default new class Cursor { constructor() { this.state = false; mp.events.add("render", () => { if (this.state === true) { mp.gui.cursor.show(true, true); mp.gui.chat.show(false); } else { mp.gui.cursor.show(false, false); mp.gui.chat.show(true); } }); } show() { !this.state ? this.state = true : null; } hide() { this.state ? this.state = false : null; } } Edited February 17, 2020 by Vernetti 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