HUNGRY:3 Posted April 15, 2015 Share Posted April 15, 2015 hello just asking can I cancelevent when player click the "u" key Link to comment
HUNGRY:3 Posted April 15, 2015 Author Share Posted April 15, 2015 ok I tried but idk here's code something wrong? function test(theButton, theState, thePlayer) if getElementData( thePlayer,"omg") == false then if theButton == "u" and theState == "down" then cancelEvent() end end addEventHandler( "onElementClicked", getRootElement(), test ) Link to comment
jingzhi Posted April 15, 2015 Share Posted April 15, 2015 ok I tried but idkhere's code something wrong? function test(theButton, theState, thePlayer) if getElementData( thePlayer,"omg") == false then if theButton == "u" and theState == "down" then cancelEvent() end end addEventHandler( "onElementClicked", getRootElement(), test ) what event are you trying to cancel? You can only cancel the events that are handled originally by gta Link to comment
HUNGRY:3 Posted April 15, 2015 Author Share Posted April 15, 2015 ok look I created a panel when player click u I want to cancel opening when it getElementData( thePlayer,"omg") == false Link to comment
xXMADEXx Posted April 15, 2015 Share Posted April 15, 2015 I don't believe that cancelEvent works with this event. Link to comment
HUNGRY:3 Posted April 15, 2015 Author Share Posted April 15, 2015 then what should I use? Link to comment
SpecT Posted April 15, 2015 Share Posted April 15, 2015 Try this. Hope that I'm not wrong. addEventHandler( "onClientKey", root, function(button,press) if button == "u" then if getElementData( source,"omg") == false then cancelEvent() end end end ) Link to comment
ALw7sH Posted April 15, 2015 Share Posted April 15, 2015 Try this. Hope that I'm not wrong. addEventHandler( "onClientKey", root, function(button,press) if button == "u" then if getElementData( source,"omg") == false then cancelEvent() end end end ) Actully this wont do what he want to do Link to comment
SpecT Posted April 15, 2015 Share Posted April 15, 2015 Try this. Hope that I'm not wrong. addEventHandler( "onClientKey", root, function(button,press) if button == "u" then if getElementData( source,"omg") == false then cancelEvent() end end end ) Actully this wont do what he want to do Oh now I got what actually he wanted to do. Well he should put that check (for the "omg") in the function where he bound the key to open/close the panel. Link to comment
HUNGRY:3 Posted April 16, 2015 Author Share Posted April 16, 2015 oh okay thanks toni for saying that now it's working Link to comment
The Don Posted April 16, 2015 Share Posted April 16, 2015 another code addEventHandler("onClientKey", root, function ( Button ) if Button then if Button == "F1" then cancelEvent() outputChatBox("You can't press that key now !",255,0,0) end end end ) Link to comment
ALw7sH Posted April 16, 2015 Share Posted April 16, 2015 another code addEventHandler("onClientKey", root, function ( Button ) if Button then if Button == "F1" then cancelEvent() outputChatBox("You can't press that key now !",255,0,0) end end end ) if Button then ??? why you are checking the button if this event triggered when button clicked Link to comment
SpecT Posted April 16, 2015 Share Posted April 16, 2015 Lel ... as ALw7sH said why the hell you need to check if there is any button when actually you click a button. And all you did is added a message *facepalm* . I'm sure that the topic maker knows how to do this if he wants ... Anyway, You are welcome! Link to comment
The Don Posted April 16, 2015 Share Posted April 16, 2015 if Button then if Button == "F1" then ------------------------ if Button and Button == "F1" then it is all works , and if i delete if Button then + the end the script will not work very well 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