Jump to content

Help! Not work "removeEventHandler"


Hugos

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!

Link to comment
  • Scripting Moderators
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
Link to comment
  • Scripting Moderators
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
Link to comment
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!

Link to comment

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