keymetaphore Posted November 24, 2017 Share Posted November 24, 2017 Alright, hi. So, I'm creating a small DX HUD that opens when you switch a weapon and closes after some time (indicating the current weapon and the other ones, but that's not so important here). I did create most of it, but I am having trouble with removing it. So here goes the code. function prepareInfo () -- here is the info that prepares everything, mostly not nesesscary dxValue = 100 -- this is the value (one of the possible ones) that would get defined above and is correct local callfunction = function () weaponfunc(dxCount) end addEventHandler("onClientRender", root, callfunction) -- you may see this weird, but it's just so I can pass the variable setTimer(function () if removeEventHandler( "onClientRender", root, function () weaponfunc(dxCount) end ) then outputChatBox("Handler Removed") end end, 3000, 1) -- So right here we set the timer to remove the onClientRender event (and also outputChatBox just to see that the function gets called end function weaponfunc (dxCount) -- here would be the dxDrawRectangle(), not needed here, function works, it just doesn't remove end Link to comment
Moderators IIYAMA Posted November 24, 2017 Moderators Share Posted November 24, 2017 Remove removeEventHandler( "onClientRender", root, callfunction ) Link to comment
Scripting Moderators thisdp Posted November 24, 2017 Scripting Moderators Share Posted November 24, 2017 (edited) function testRender() print("render~") end addEventHandler("onClientRender",root,testRender) setTimer(function() removeEventHandler("onClientRender",root,testRender) print("Handler Removed") end,5000,1) removeEventHandler means to detach the function from the handler. Edited November 24, 2017 by thisdp 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