Sign in to follow this  
Hugos

Help! Not work "removeEventHandler"

Recommended Posts

I have such a function:

function btn_edit(button)
    if button == "left" then
        name = guiCreateEdit(0, 0, 0, 0, "", false)
        setTimer(function()
            dxDrawText(guiGetText(name), 455, 316, 690, 346, tocolor(255, 255, 255), 1, Font13, "left", "center", clip, wordBreak, true) 
            guiFocus(name)
            guiSetAlpha(name, 0)
            guiEditSetMaxLength(name, 32)
        end, 1, 0)
    end
end

( addEventHandler("onClientGUIClick", btn, btn_edit)  )

Does not work "removeEventHandler". In another function, when I click I hide all the specified functions except this one.
I can't understand why she's not hiding. Help, please!

Share this post


Link to post
Posted (edited)
6 minutes ago, Hugos said:

I have such a function:


function btn_edit(button)
    if button == "left" then
        name = guiCreateEdit(0, 0, 0, 0, "", false)
        setTimer(function()
            dxDrawText(guiGetText(name), 455, 316, 690, 346, tocolor(255, 255, 255), 1, Font13, "left", "center", clip, wordBreak, true) 
            guiFocus(name)
            guiSetAlpha(name, 0)
            guiEditSetMaxLength(name, 32)
        end, 1, 0)
    end
end

( addEventHandler("onClientGUIClick", btn, btn_edit)  )

Does not work "removeEventHandler". In another function, when I click I hide all the specified functions except this one.
I can't understand why she's not hiding. Help, please!

Any errors/warnings?

Show removeEventHandler line.

 

Edited by majqq

Share this post


Link to post
6 minutes ago, majqq said:

Any errors/warnings?

Show removeEventHandler line.

 

I use:

removeEventHandler("onClientGUIClick", btn, btn_edit)

But the function and the text is not hiding
 

Share this post


Link to post
3 minutes ago, Hugos said:

I use:


removeEventHandler("onClientGUIClick", btn, btn_edit)

But the function and the text is not hiding
 

I believe that's happening because timer is going all the time, removing event handler doesn't make that timer will be destroyed. Timer is set for 1 ms interval, and unlimited times to execute.

https://wiki.multitheftauto.com/wiki/SetTimer

Try to assign timer to variable, and kill it after removing event handler, with:

https://wiki.multitheftauto.com/wiki/KillTimer

  • Thanks 1

Share this post


Link to post
33 minutes ago, majqq said:

I believe that's happening because timer is going all the time, removing event handler doesn't make that timer will be destroyed. Timer is set for 1 ms interval, and unlimited times to execute.

https://wiki.multitheftauto.com/wiki/SetTimer

Try to assign timer to variable, and kill it after removing event handler, with:

https://wiki.multitheftauto.com/wiki/KillTimer

Oh, Thank!

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.