Cadu12 Posted April 30, 2011 Posted April 30, 2011 function PlayerPressedKey() outputChatBox("You pressed!") end addEventHandler("onClientKey", getRootElement(), PlayerPressedKey) https://wiki.multitheftauto.com/wiki/OnClientKey This event doesnt work for me, i did debugscript 3 but nothing Im adding my own dxgui (login panel) Ingame nick: Cadu12
Cadu12 Posted April 30, 2011 Author Posted April 30, 2011 It's only supported in 1.1. Then tell me how? Ingame nick: Cadu12
Cadu12 Posted April 30, 2011 Author Posted April 30, 2011 Text editor (no GUI) There is no event keyboard.... Ingame nick: Cadu12
Moderators Citizen Posted April 30, 2011 Moderators Posted April 30, 2011 Try to make your own event. I already make this event for the 1.0.5 and it's work I can show you if you want The rEvolution is coming ...
Cadu12 Posted April 30, 2011 Author Posted April 30, 2011 Show me, thank you =D Here image for user panel: http://img26.imageshack.us/i/loginpanel.png/ Ingame nick: Cadu12
Moderators Citizen Posted April 30, 2011 Moderators Posted April 30, 2011 addEvent("onClientKeyPressed", true ) setElementData( getLocalPlayer(), "PRESSED", "none" ) function keyPressed( ) local lastKey = getElementData( getLocalPlayer(), "PRESSED" ) if ( not (lastKey == "none") ) then if ( not getKeyState( ""..lastKey ) ) then triggerEvent( "onClientKeyPressed", getRootElement(), tostring(lastKey) ) setElementData( getLocalPlayer(), "PRESSED", "none" ) end end for k=97, 122 do local letter = string.char(k) local state = getKeyState( ""..letter ) if ( state ) then setElementData( getLocalPlayer(), "PRESSED", tostring(letter) ) break end end end addEventHandler( "onClientPreRender", getRootElement(), keyPressed ) function test05( letter ) outputChatBox(""..letter ) end addEventHandler("onClientKeyPressed", getRootElement(), test05 ) The rEvolution is coming ...
Cadu12 Posted April 30, 2011 Author Posted April 30, 2011 Hmmm doesnt work for Caps ? becuase login have caps and lowers Ingame nick: Cadu12
DiSaMe Posted April 30, 2011 Posted April 30, 2011 Why not to simply use a table of keys from https://wiki.multitheftauto.com/wiki/Key_names , cycle through it binding them to a function and trigger a custom event from that function? -
Cadu12 Posted April 30, 2011 Author Posted April 30, 2011 Eh, we cant add caps? If players Caps Lock is on it makes string upper Ingame nick: Cadu12
Moderators Citizen Posted May 2, 2011 Moderators Posted May 2, 2011 Hmmm doesnt work for Caps ? becuase login have caps and lowers keyTable = { "mouse1", "mouse2", "mouse3", "mouse4", "mouse5", "mouse_wheel_up", "mouse_wheel_down", "arrow_l", "arrow_u", "arrow_r", "arrow_d", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "num_0", "num_1", "num_2", "num_3", "num_4", "num_5", "num_6", "num_7", "num_8", "num_9", "num_mul", "num_add", "num_sep", "num_sub", "num_div", "num_dec", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "backspace", "tab", "lalt", "ralt", "enter", "space", "pgup", "pgdn", "end", "home", "insert", "delete", "lshift", "rshift", "lctrl", "rctrl", "[", "]", "pause", "capslock", "scroll", ";", ",", "-", ".", "/", "#", "\\", "=" } function keyPressed( ) local lastKey = getElementData( getLocalPlayer(), "PRESSED" ) if ( not (lastKey == "none") ) then if ( not getKeyState( ""..lastKey ) ) then local nlet = string.byte(""..lastKey) if ( nlet >= 97 and nlet <= 122 )then if ( getKeyState( "lshift" ) or getKeyState( "rshift" ) ) then lastKey = string.upper(tostring(lastKey)) end end triggerEvent( "onClientKeyPressed", getRootElement(), lastKey ) setElementData( getLocalPlayer(), "PRESSED", "none" ) end end for k,i in ipairs( keyTable ) do local letter = tostring(keyTable[k]) local state = getKeyState( ""..letter ) if ( state ) then setElementData( getLocalPlayer(), "PRESSED", tostring(letter) ) break end end end addEventHandler( "onClientPreRender", getRootElement(), keyPressed ) function test05( letter ) outputChatBox(""..letter ) end addEventHandler("onClientKeyPressed", getRootElement(), test05 ) The rEvolution is coming ...
Moderators Citizen Posted May 5, 2011 Moderators Posted May 5, 2011 Hmmmm doesnt work I have tested it, and it's work ! And it's in client-side The rEvolution is coming ...
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