Jump to content

cancelevent


HUNGRY:3

Recommended Posts

Posted

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 ) 

Posted
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 ) 

what event are you trying to cancel? You can only cancel the events that are handled originally by gta

Posted

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 ) 

Posted
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

Posted
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.

Posted

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 ) 

Posted
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

Posted

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!

Posted
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

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...