Sign in to follow this  
Stuyk

Code Snippets

Recommended Posts

Basically just post code snippets that you may find useful. Try to explain what it does and where it belongs. I'll start.

 

OnKeyDown function for Clientside to get exact string versions of keys.

// Bind all the keys available.
for(let i = 1; i <= 0xFE; i++) 
{ 
	mp.keys.bind(i, true, () => mp.events.call("keydown", i)); 
}

// Every time a key is pressed it gets sent to this event.
mp.events.add("keydown", (i) => {
    mp.gui.chat.push(String.fromCharCode(i)); // Use this to get the key in plain text.
});
  
// Credits to George since this is actually really freaking useful for non-cef based input.

 

  • Like 1

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.