SpecT Posted May 3, 2015 Share Posted May 3, 2015 (edited) Hello guys! I'm wondering how it is possible to bind 2 keys to do one function. But to let it call the function they have to be pressed both of them. For example ctrl + p then it will call the function. Thanks in advance! Edited May 3, 2015 by Guest Link to comment
WhoAmI Posted May 3, 2015 Share Posted May 3, 2015 function playerPressedKey ( button, press ) if ( button == "lctrl" ) then setElementData ( localPlayer, "lctrl", press and true or false ); end if ( button == "p" and press ) then local pressed = getElementData ( localPlayer, "lctrl" ); if ( pressed ) then -- ctrl + p combination was pressed end end end addEventHandler ( "onClientKey", root, playerPressedKey ); Maybe it is faster way to do that, but that's only my example. Link to comment
SpecT Posted May 3, 2015 Author Share Posted May 3, 2015 (edited) function playerPressedKey ( button, press ) if ( button == "lctrl" ) then setElementData ( localPlayer, "lctrl", press and true or false ); end if ( button == "p" and press ) then local pressed = getElementData ( localPlayer, "lctrl" ); if ( pressed ) then -- ctrl + p combination was pressed end end end addEventHandler ( "onClientKey", root, playerPressedKey ); Maybe it is faster way to do that, but that's only my example. Oh, thanks I just made something similar and it worked. Thanks anyway! And I have got another question: I searched in the wiki for a function to get players copied text (clipboard) but there is no function like this because of security reasons. So I want to make a dxEdit bar where I could paste my text ... Is there any way to make it so I will be able to paste the text I copied - just like in GUI. Edited May 3, 2015 by Guest Link to comment
TAPL Posted May 3, 2015 Share Posted May 3, 2015 See the example in the wiki. https://wiki.multitheftauto.com/wiki/GetKeyState Link to comment
WhoAmI Posted May 3, 2015 Share Posted May 3, 2015 CTRL + C -> guiGetText -> setElementData CTRL + V -> getElementData -> guiSetText Link to comment
delete Posted May 3, 2015 Share Posted May 3, 2015 (edited) function bind() bindKey("p", "down", chatFunction) end function unbind() unbindKey("p", "down", chatFunction) end bindKey ( "ctrl", "down", bind) bindKey ( "lshift", "up", unbind) Edit: oops my bad i posted it late. Edited May 3, 2015 by Guest Link to comment
SpecT Posted May 3, 2015 Author Share Posted May 3, 2015 (edited) CTRL + C -> guiGetText -> setElementDataCTRL + V -> getElementData -> guiSetText Yeah, but I wanna do it in dx ... Is it possible? Tell me if it's not then I will do it with GUI .. PS: I mean: just like setClipboard but getClipboard somehow. I want to let it take what I copied for example youtube link and paste it in the edit box (DX). PS: I'm not using GUI's editbox. Edited May 3, 2015 by Guest Link to comment
WhoAmI Posted May 3, 2015 Share Posted May 3, 2015 It is, because you are using gui's editbox while creating dxEditbox. Well, or only I am using it... Link to comment
Walid Posted May 3, 2015 Share Posted May 3, 2015 Hello guys!I'm wondering how it is possible to bind 2 keys to do one function. But to let it call the function they have to be pressed both of them. For example ctrl + p then it will call the function. Thanks in advance! about your first question it can be like this : function example(key) if (key == "p") then if (getKeyState("lctrl")) then -- You code here end end end bindKey("p", "down", example) About second question : Yes you can use setClipboard() Link to comment
SpecT Posted May 3, 2015 Author Share Posted May 3, 2015 Hello guys!I'm wondering how it is possible to bind 2 keys to do one function. But to let it call the function they have to be pressed both of them. For example ctrl + p then it will call the function. Thanks in advance! about your first question it can be like this : function example(key) if (key == "p") then if (getKeyState("lctrl")) then -- You code here end end end bindKey("p", "down", example) About second question : Yes you can use setClipboard() About my first question I already made it. And about my second question: You didn't get it right. I want when I'm in-game to get player's copied text (for example youtube link) and paste it in-game in dxEditBox. My question is: How to get player's clipboard (When you copy with ctrl + c) ? Link to comment
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