Jump to content

Recommended Posts

Posted (edited)

Hello, I'm trying to create key binds, following this: https://wiki.rage.mp/index.php?title=Key::bind

In clientside, I have this (client_packages/index.js)

// Key F2 Press
mp.keys.bind(0x71, true, function() {
    mp.events.callRemote('keypress:F4'); // Calling server event "keypress:F2"
    mp.gui.chat.push('F2 key is pressed.');
});

This shows the message "F2 key is pressed" on the chat.

Serverside I have this (packages/index.js)

mp.events.add("keypress:F2", (player) => {
	player.outputChatBox("Server response: OK");
});

But this is not working, like it's not calling the event.

Anyone knows why it's happening? I've tried everything and nothing it's working...

Edited by hdrtop
Posted

You are calling the wrong event on the client-side.

replace

mp.events.callRemote('keypress:F4');

to

mp.events.callRemote('keypress:F2');

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...