HUNGRY:3 Posted April 15, 2015 Posted April 15, 2015 hello just asking can I cancelevent when player click the "u" key
HUNGRY:3 Posted April 15, 2015 Author 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 )
jingzhi Posted April 15, 2015 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
HUNGRY:3 Posted April 15, 2015 Author 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
xXMADEXx Posted April 15, 2015 Posted April 15, 2015 I don't believe that cancelEvent works with this event.
SpecT Posted April 15, 2015 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 )
ALw7sH Posted April 15, 2015 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
SpecT Posted April 15, 2015 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.
HUNGRY:3 Posted April 16, 2015 Author Posted April 16, 2015 oh okay thanks toni for saying that now it's working
The Don Posted April 16, 2015 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 )
ALw7sH Posted April 16, 2015 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
SpecT Posted April 16, 2015 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!
The Don Posted April 16, 2015 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
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